当前位置: 首页>>代码示例>>C++>>正文


C++ CKeySet类代码示例

本文整理汇总了C++中CKeySet的典型用法代码示例。如果您正苦于以下问题:C++ CKeySet类的具体用法?C++ CKeySet怎么用?C++ CKeySet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CKeySet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

//--------------------------------------------------------------------------
//  Read all keyboard definitions
//--------------------------------------------------------------------------
int CKeyMap::Read (SStream *stream, Tag tag)
{
  int rc = TAG_IGNORED;

  switch (tag) {
  case 'vers':
    // Version
    ReadInt (&vers, stream);
    rc = TAG_READ;
    break;

  case 'kset':
    // KeySet sub-object
    {
      Tag ksetTag;
      ReadTag (&ksetTag, stream);
      CheckSet(ksetTag);
      CKeySet *ks = new CKeySet (ksetTag);
      ReadFrom (ks, stream);
      kset[ks->GetTag()] = ks;
      oset.push_back(ks);
    }
    rc = TAG_READ;
    break;
  }

  if (rc == TAG_IGNORED) {
    globals->logWarning->Write ("CKeyMap::Read : Unknown tag %s", TagToString(tag));
  }

  return rc;
}
开发者ID:FlySimvol,项目名称:FlyLegacy,代码行数:35,代码来源:KeyMap.cpp

示例2: Print

//--------------------------------------------------------------------------
//  Print all keys
//--------------------------------------------------------------------------
void CKeyMap::Print (FILE* f)
{
  // Iterate over keysets
  std::map<Tag,CKeySet*>::iterator i;
  for (i=kset.begin(); i!=kset.end(); i++) {
    CKeySet *pKeySet = i->second;

    // Format key set unique ID
    char s[8];
    TagToString (s, pKeySet->GetTag());
    fprintf (f, "KeySet '%s' %s\n", s, pKeySet->GetName());

    // Iterate over key definitions within the keyset
    std::map<Tag,CKeyDefinition*>::iterator j;
    for (j=pKeySet->dkey.begin(); j!=pKeySet->dkey.end(); j++) {
      CKeyDefinition *pKeyDef = j->second;

      // Format key definition unique ID
      char sId[8];
      TagToString (sId, pKeyDef->GetTag());

      // Format key code
      char sCode[32];
      formatKeyCode (sCode, pKeyDef->GetCode());

      fprintf (f, "  '%s' %-40s  %s\n", sId, pKeyDef->GetName(), sCode);
    }
  }
}
开发者ID:FlySimvol,项目名称:FlyLegacy,代码行数:32,代码来源:KeyMap.cpp

示例3: FindKeySetById

//------------------------------------------------------------------------------
//  Bind keyset with group key to global function f
//------------------------------------------------------------------------------
void CKeyMap::BindGroup(Tag gp,KeyGroupCB f)
{ CKeySet *set = FindKeySetById(gp);
  if (0 == set)   return;
  lgrp  = gp;                     // Remember the group
  set->BindTo(f);
  return;
}
开发者ID:FlySimvol,项目名称:FlyLegacy,代码行数:10,代码来源:KeyMap.cpp

示例4: lua_gettop

int LuaUnsyncedRead::GetKeyBindings(lua_State* L)
{
	const int args = lua_gettop(L); // number of arguments
	if ((args != 1) || !lua_isstring(L, 1)) {
		luaL_error(L, "Incorrect arguments to GetKeyBindings(\"keyset\")");
	}
	const string keysetStr = lua_tostring(L, 1);
	CKeySet ks;
	if (!ks.Parse(keysetStr)) {
		return 0;
	}
	const CKeyBindings::ActionList&	actions = keyBindings->GetActionList(ks);
	lua_newtable(L);
	for (int i = 0; i < (int)actions.size(); i++) {
		const Action& action = actions[i];
		lua_pushnumber(L, i + 1);
		lua_newtable(L);
		lua_pushstring(L, action.command.c_str());
		lua_pushstring(L, action.extra.c_str());
		lua_rawset(L, -3);
		lua_rawset(L, -3);
	}
	lua_pushstring(L, "n");
	lua_pushnumber(L, actions.size());
	lua_rawset(L, -3);
	return 1;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:27,代码来源:LuaUnsyncedRead.cpp

示例5: if

const CKeyBindings::ActionList&
	CKeyBindings::GetActionList(const CKeySet& ks) const
{
	static const ActionList empty;
	const ActionList* alPtr = NULL;

	if (ks.AnyMod()) {
		KeyMap::const_iterator it = bindings.find(ks);
		if (it == bindings.end()) {
			alPtr = &empty;
		} else {
			alPtr = &(it->second);
		}
	}
	else {
		// have to check for an AnyMod keyset as well as the normal one
		CKeySet anyMod = ks;
		anyMod.SetAnyBit();
		KeyMap::const_iterator nit = bindings.find(ks);
		KeyMap::const_iterator ait = bindings.find(anyMod);
		const bool haveNormal = (nit != bindings.end());
		const bool haveAnyMod = (ait != bindings.end());
		if (!haveNormal && !haveAnyMod) {
			alPtr = &empty;
		}
		else if (haveNormal && !haveAnyMod) {
			alPtr = &(nit->second);
		}
		else if (!haveNormal && haveAnyMod) {
			alPtr = &(ait->second);
		}
		else {
			// combine the two lists (normal first)
			static ActionList merged;
			merged = nit->second;
			const ActionList& aal = ait->second;
			for (int i = 0; i < (int)aal.size(); ++i) {
				merged.push_back(aal[i]);
			}
			alPtr = &merged;
		}
	}

	if (LOG_IS_ENABLED(L_DEBUG)) {
		const bool isEmpty = (alPtr == &empty);
		LOG_L(L_DEBUG, "GetAction: %s (0x%03X)%s",
				ks.GetString(false).c_str(), ks.Key(),
				(isEmpty ? "  EMPTY" : ""));
		if (!isEmpty) {
			const ActionList& al = *alPtr;
			for (size_t i = 0; i < al.size(); ++i) {
				LOG_L(L_DEBUG, "  %s  \"%s\"",
						al[i].command.c_str(), al[i].rawline.c_str());
			}
		}
	}

	return *alPtr;
}
开发者ID:Arkazon,项目名称:spring,代码行数:59,代码来源:KeyBindings.cpp

示例6: SetDefaultValues

//------------------------------------------------------------------------------
//  Reset all keys to default values
//------------------------------------------------------------------------------
void CKeyMap::SetDefaultValues(CKeyFile *def)
{ std::map<Tag,CKeySet*>::iterator i;
  for (i=kset.begin(); i!=kset.end(); i++) {
      CKeySet *ks = i->second;
      ks->SetDefaultValues(def);
    }
 return; 
}
开发者ID:FlySimvol,项目名称:FlyLegacy,代码行数:11,代码来源:KeyMap.cpp

示例7: Assign

//------------------------------------------------------------------------------
//  Assign code to key definition
//------------------------------------------------------------------------------
void  CKeyMap::Assign(int cde,CKeyDefinition *kdf)
{ Tag ks = kdf->GetSet();
  kdf->SetCode(cde);
  std::map<Tag,CKeySet*>::iterator it = kset.find(ks);
  if (it == kset.end())   return;
  CKeySet *set = (*it).second;
  set->StoreKeyDef(kdf);
  return;
}
开发者ID:FlySimvol,项目名称:FlyLegacy,代码行数:12,代码来源:KeyMap.cpp

示例8: FindKeyDefinitionById

//------------------------------------------------------------------------------
//  Locate a key definition by  key identifier only
//  NOTE:  Group are searched from upper group(menus,..) to lower group (aircraft)
//------------------------------------------------------------------------------
CKeyDefinition* CKeyMap::FindKeyDefinitionById (Tag id)
{ CKeyDefinition *rc = NULL;
  for (U_INT k=0; k< oset.size();k++)
  { CKeySet *ks         = oset[k];
    CKeyDefinition* kdf = ks->GetKeyByTag(id);
    if (0 == kdf) continue;
    return kdf;
  }
  return 0;
}
开发者ID:FlySimvol,项目名称:FlyLegacy,代码行数:14,代码来源:KeyMap.cpp

示例9: FindKeyDefinitionByCode

//------------------------------------------------------------------------------
//  Locate a key definition by  keyboard code only
//------------------------------------------------------------------------------
CKeyDefinition* CKeyMap::FindKeyDefinitionByCode (int iCode, Tag &setTagOut)
{ setTagOut = 0;
  std::map<Tag,CKeySet*>::iterator i;
  for (i=kset.begin(); i!=kset.end(); i++)
  { CKeySet *set = i->second;
    CKeyDefinition *kdf = set->GetKeyByCode(iCode);
    if (0 == kdf)     continue;
    setTagOut = set->GetTag();
    return kdf;
  }
 return 0;
}
开发者ID:FlySimvol,项目名称:FlyLegacy,代码行数:15,代码来源:KeyMap.cpp

示例10: AddKeySymbol

bool CKeyBindings::AddKeySymbol(const string& keysym, const string& code)
{
	CKeySet ks;
	if (!ks.Parse(code)) {
		logOutput.Print("AddKeySymbol: could not parse key: %s\n", code.c_str());
		return false;
	}
	if (!keyCodes->AddKeySymbol(keysym, ks.Key())) {
		logOutput.Print("AddKeySymbol: could not add: %s\n", keysym.c_str());
		return false;
	}
	return true;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:13,代码来源:KeyBindings.cpp

示例11: AddNamedKeySet

bool CKeyBindings::AddNamedKeySet(const string& name, const string& keystr)
{
	CKeySet ks;
	if (!ks.Parse(keystr)) {
		printf("AddNamedKeySet: could not parse keyset: %s\n", keystr.c_str());
		return false;
	}
	if ((ks.Key() < 0) || !CKeyCodes::IsValidLabel(name)) {
		printf("AddNamedKeySet: bad custom keyset name: %s\n", name.c_str());
		return false;
	}
	namedKeySets[name] = ks;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:13,代码来源:KeyBindings.cpp

示例12: AddKeySymbol

bool CKeyBindings::AddKeySymbol(const string& keysym, const string& code)
{
	CKeySet ks;
	if (!ks.Parse(code)) {
		LOG_L(L_WARNING, "AddKeySymbol: could not parse key: %s", code.c_str());
		return false;
	}
	if (!keyCodes->AddKeySymbol(keysym, ks.Key())) {
		LOG_L(L_WARNING, "AddKeySymbol: could not add: %s", keysym.c_str());
		return false;
	}
	return true;
}
开发者ID:Arkazon,项目名称:spring,代码行数:13,代码来源:KeyBindings.cpp

示例13: SwapCode

//------------------------------------------------------------------------------
//  Swap key code
//------------------------------------------------------------------------------
void CKeyMap::SwapCode(CKeyDefinition *kdf,int nc)
{ Tag ks = kdf->GetSet();
  int cd = kdf->GetCode();
  kdf->SetCode(0);
  std::map<Tag,CKeySet*>::iterator it = kset.find(ks);
  if (it != kset.end())      return;   // No set
  CKeySet *set = (*it).second;
  set->ClearCode(cd);
  //---Set the new code ----------------------------
  kdf->SetCode(nc);
  set->StoreKeyDef(kdf);
  return;
}
开发者ID:FlySimvol,项目名称:FlyLegacy,代码行数:16,代码来源:KeyMap.cpp

示例14: SetFakeMetaKey

bool CKeyBindings::SetFakeMetaKey(const string& keystr)
{
	CKeySet ks;
	if (StringToLower(keystr) == "none") {
		fakeMetaKey = -1;
		return true;
	}
	if (!ks.Parse(keystr)) {
		logOutput.Print("SetFakeMetaKey: could not parse key: %s\n", keystr.c_str());
		return false;
	}
	fakeMetaKey = ks.Key();
	return true;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:14,代码来源:KeyBindings.cpp

示例15: SetFakeMetaKey

bool CKeyBindings::SetFakeMetaKey(const string& keystr)
{
	CKeySet ks;
	if (StringToLower(keystr) == "none") {
		fakeMetaKey = -1;
		return true;
	}
	if (!ks.Parse(keystr)) {
		LOG_L(L_WARNING, "SetFakeMetaKey: could not parse key: %s", keystr.c_str());
		return false;
	}
	fakeMetaKey = ks.Key();
	return true;
}
开发者ID:Arkazon,项目名称:spring,代码行数:14,代码来源:KeyBindings.cpp


注:本文中的CKeySet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。