本文整理汇总了C++中KeyMap类的典型用法代码示例。如果您正苦于以下问题:C++ KeyMap类的具体用法?C++ KeyMap怎么用?C++ KeyMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startConsole
void startConsole()
{
//intptr_t serverId = _spawnl(_P_NOWAIT, "TiGaServ.exe", "TiGaServ.exe", "15600" );
//intptr_t clientId = _spawnl(_P_NOWAIT, "TiGaClient.exe", "TiGaServ.exe", "localhost", "15600" );
bool exit = false;
KeyMap keyMap;
MENU_BEGIN('1',"Print menu")
printMenu(keyMap);
MENU_END();
MENU_BEGIN('2',"Start server")
system("start TiGaServ.exe 15600" );
//if( serverId == 0 )
// serverId = _spawnl(_P_NOWAITO, "TiGaServ.exe", "TiGaServ.exe", "15600" );
MENU_END();
MENU_BEGIN('3',"Start client")
system("start TiGaClient.exe 127.0.0.1 15600" );
//size_t id = spawnClient();
//printf("Client %d spawned\n",id);
MENU_END();
MENU_BEGIN(' ',"Exit")
exit = true;
MENU_END();
printMenu(keyMap);
while(exit != true)
{
int ch = getch();
KeyMap::iterator it = keyMap.find(ch);
if( it != keyMap.end() )
it->second.second();
}
}
示例2: getKeys
Penjin::ERRORS KeyMapper::mapMouse(CRuchar id)
{
Penjin::ERRORS result = PENJIN_OK;
string device = "Mouse";
vector<string> keyList = getKeys(device);
for(uint i = 0; i < keyList.size(); ++i)
{
KeyMap* t = NULL;
if(keyList.at(i).find("Button") != keyList.at(i).npos)
{
t = new KeyMapMouseButton(Penjin::StringUtility::stringToInt(getValue(device,keyList.at(i))), keyList.at(i), id);
}
else
{
t = new KeyMapMouseAxis(Penjin::StringUtility::stringToInt(getValue(device,keyList.at(i))), keyList.at(i), id);
}
if(t == NULL)
result = PENJIN_ERROR;
else if(t->isMapValid())
{
keys.push_back(t);
}
else
{
ErrorMan::getInstance()->print(PENJIN_ERROR, "KeyMapper::mapMouse(): ");
delete t;
result = PENJIN_ERROR; // We have to show that something went wrong with the config
}
}
return result;
}
示例3: printMenu
void printMenu(KeyMap & keyMap)
{
for( auto it = keyMap.begin(); it != keyMap.end(); ++it)
{
printf("%c.\t%s\n",it->first, it->second.first);
}
}
示例4: keyIdentifierForEvasKeyName
static String keyIdentifierForEvasKeyName(String& keyName)
{
if (gKeyMap.isEmpty())
createKeyMap();
if (gKeyMap.contains(keyName))
return gKeyMap.get(keyName);
return keyName;
}
示例5: make_key
static rinteger make_key(Env* env, Method* meth, KeyMap& keys) {
KeyMap::iterator iter = keys.find(meth);
if(iter == keys.end()) {
rinteger key = env->integer_new(keys.size());
keys[meth] = key;
return key;
}
return iter->second;
}
示例6: MomentaryUseTool
void Viewer::MomentaryUseTool (const char* keyCode, Event& e) {
Tool* curTool= _editor->GetCurTool();
const char* origCode = curTool->GetControlInfo()->GetKeyCode();
KeyMap* keymap = _editor->GetKeyMap();
if (strcmp(origCode, keyCode) == 0) {
UseTool(CurTool(), e); /* already using this tool */
} else {
keymap->Execute(keyCode); /* engage tool momentarily */
UseTool(CurTool(), e);
keymap->Execute(origCode); /* revert to original tool */
}
}
示例7: pollDevice
void DirectInputRegistry::updateState( osgGA::EventQueue* eventQueue )
{
HRESULT hr;
if ( !_supportDirectInput || !eventQueue ) return;
if ( _keyboard )
{
pollDevice( _keyboard );
char buffer[256] = {0};
hr = _keyboard->GetDeviceState( sizeof(buffer), &buffer );
if ( SUCCEEDED(hr) )
{
for ( KeyMap::iterator itr=g_keyMap.begin(); itr!=g_keyMap.end(); ++itr )
{
KeyValue& key = itr->second;
char value = buffer[itr->first];
if ( key.second==value ) continue;
key.second = value;
if ( value&0x80 )
eventQueue->keyPress( key.first );
else
eventQueue->keyRelease( key.first );
}
}
}
if ( _mouse )
{
pollDevice( _mouse );
DIMOUSESTATE2 mouseState;
hr = _mouse->GetDeviceState( sizeof(DIMOUSESTATE2), &mouseState );
// TODO: add mouse handlers
}
if ( _joystick )
{
pollDevice( _joystick );
osg::ref_ptr<JoystickEvent> event = new JoystickEvent;
hr = _joystick->GetDeviceState( sizeof(DIJOYSTATE2), &(event->_js) );
if ( SUCCEEDED(hr) ) eventQueue->userEvent( event.get() );
}
}
示例8: responseString
status_t Session::provideKeyResponse(const Vector<uint8_t>& response) {
String8 responseString(
reinterpret_cast<const char*>(response.array()), response.size());
KeyMap keys;
Mutex::Autolock lock(mMapLock);
JsonWebKey parser;
if (parser.extractKeysFromJsonWebKeySet(responseString, &keys)) {
for (size_t i = 0; i < keys.size(); ++i) {
const KeyMap::key_type& keyId = keys.keyAt(i);
const KeyMap::value_type& key = keys.valueAt(i);
mKeyMap.add(keyId, key);
}
return android::OK;
} else {
return android::ERROR_DRM_UNKNOWN;
}
}
示例9: write
void MidiInstrument::write(int level, Xml& xml)
{
xml.header();
xml.tag(level, "los version=\"1.0\"");
level++;
xml.nput(level, "<MidiInstrument name=\"%s\" panValue=\"%f\"",
Xml::xmlString(iname()).toLatin1().constData(), m_panValue);
if (_nullvalue != -1)
{
QString nv;
nv.setNum(_nullvalue);
xml.nput(" nullparam=\"%s\"", nv.toLatin1().constData());
}
xml.put(">");
// -------------
// What about Init, Reset, State, and InitScript ?
// -------------
level++;
for (ciPatchGroup g = pg.begin(); g != pg.end(); ++g)
{
PatchGroup* pgp = *g;
const PatchList& pl = pgp->patches;
xml.tag(level, "PatchGroup name=\"%s\"", Xml::xmlString(pgp->name).toLatin1().constData());
level++;
for (ciPatch p = pl.begin(); p != pl.end(); ++p)
(*p)->write(level, xml);
level--;
xml.etag(level, "PatchGroup");
}
for (iMidiController ic = _controller->begin(); ic != _controller->end(); ++ic)
ic->second->write(level, xml);
for(QHash<int, KeyMap*>::const_iterator km = m_keymaps.begin(); km != m_keymaps.end(); ++km)
{
KeyMap *m = km.value();
m->write(level, xml);
}
level--;
xml.etag(level, "MidiInstrument");
level--;
xml.etag(level, "los");
}
示例10:
// Only for debug
void
ClefKeyContext::dumpKeyContext()
{
KeyMaps::iterator i;
KeyMap::iterator j;
std::cout << "Begin of key context dump =================" << std::endl;
for (i = m_keyMaps.begin(); i != m_keyMaps.end(); ++i) {
std::cout << " Track = " << (*i).first << std::endl;
KeyMap *m = (*i).second;
for (j = m->begin(); j != m->end(); ++j) {
std::cout << " Time = " << (*j).first
<< " Key = " << (*j).second.getName() << std::endl;
}
}
std::cout << "End of key context dump =================" << std::endl;
}
示例11: init
bool init()
{
glfwInit();
renderer->init("Pyzzlix", 1280, 720, false);
glfwDisable(GLFW_AUTO_POLL_EVENTS);
glfwSetKeyCallback(&keyCallback);
KeyMap* keymap = KeyMap::getInstance();
keymap->setKey(GLFW_KEY_RIGHT, KEY_RIGHT);
keymap->setKey(GLFW_KEY_LEFT, KEY_LEFT);
keymap->setKey(GLFW_KEY_DOWN, KEY_DOWN);
keymap->setKey(GLFW_KEY_UP, KEY_UP);
keymap->setKey('X', KEY_ROTATE_RIGHT);
keymap->setKey('Z', KEY_ROTATE_LEFT);
sceneHandler->pushScene(scene_maingame);
scene_maingame->startGame();
return true;
}
示例12: test
void KeyMapTest::test() {
IUNIT_FALSE(KeyCode::KEY_UP_ARROW == KeyCode::KEY_DOWN_ARROW);
IUNIT_NOT_NULL(keyMap.getKeyEntry(1));
IUNIT_NULL(keyMap.getKeyEntry(2));
const KeySequenceEntry* entry = keyMap.getKeyEntry(1);
IUNIT_EQ(true, entry->isEntry());
entry = keyMap.getKeyEntry(27);
IUNIT_EQ(false, entry->isEntry());
entry = entry->getKeySequenceEntry(91);
IUNIT_NOT_NULL( entry );
IUNIT_EQ(false, entry->isEntry());
const KeySequenceEntry* tmp = entry->getKeySequenceEntry(65);
IUNIT_NOT_NULL( tmp );
IUNIT_EQ(true, tmp->isEntry());
tmp = entry->getKeySequenceEntry(66);
IUNIT_NOT_NULL( tmp );
IUNIT_EQ(true, tmp->isEntry());
keyMap.deleteKeyCodeSeq(KeyCode::KEY_CTRL_A);
IUNIT_NOT_NULL(keyMap.getKeyEntry(27));
IUNIT_NULL(keyMap.getKeyEntry(1));
}
示例13: createKeyMap
static void createKeyMap()
{
for (unsigned int i = 1; i < 25; i++) {
String key = String::format("F%d", i);
gKeyMap.set(key, key);
}
gKeyMap.set("Alt_L", "Alt");
gKeyMap.set("ISO_Level3_Shift", "Alt");
gKeyMap.set("Menu", "Alt");
gKeyMap.set("Shift_L", "Shift");
gKeyMap.set("Shift_R", "Shift");
gKeyMap.set("Down", "Down");
gKeyMap.set("End", "End");
gKeyMap.set("Return", "Enter");
gKeyMap.set("KP_Enter", "Enter");
gKeyMap.set("Home", "Home");
gKeyMap.set("Insert", "Insert");
gKeyMap.set("Left", "Left");
gKeyMap.set("Down", "Down");
gKeyMap.set("Next", "PageDown");
gKeyMap.set("Prior", "PageUp");
gKeyMap.set("Right", "Right");
gKeyMap.set("Up", "Up");
gKeyMap.set("Delete", "U+007F");
gKeyMap.set("Tab", "U+0009");
gKeyMap.set("ISO_Left_Tab", "U+0009");
}
示例14: mReturnKey
inline bool mReturnKey(const KeyMap& km) { return km.get(Keys::RETURN); }
示例15: mEscKey
inline bool mEscKey(const KeyMap& km) { return km.get(Keys::ESCAPE); }