void AutoConfForPad(const std::string &name) { ILOG("Autoconfiguring pad for %s", name.c_str()); if (name == "Xbox 360 Pad") { SetDefaultKeyMap(DEFAULT_MAPPING_X360, true); } else { SetDefaultKeyMap(DEFAULT_MAPPING_PAD, true); } }
void AutoConfForPad(const std::string &name) { ILOG("Autoconfiguring pad for %s", name.c_str()); if (name == "Xbox 360 Pad") { SetDefaultKeyMap(DEFAULT_MAPPING_X360, true); } else { SetDefaultKeyMap(DEFAULT_MAPPING_PAD, true); } #ifndef MOBILE_DEVICE // Add a couple of convenient keyboard mappings by default, too. g_controllerMap[VIRTKEY_PAUSE].push_back(KeyDef(DEVICE_ID_KEYBOARD, NKCODE_ESCAPE)); g_controllerMap[VIRTKEY_UNTHROTTLE].push_back(KeyDef(DEVICE_ID_KEYBOARD, NKCODE_TAB)); #endif }
void SetDefaultKeyMap(DefaultMaps dmap, bool replace) { switch (dmap) { case DEFAULT_MAPPING_KEYBOARD: { bool azerty = false; bool qwertz = false; #if defined(SDL) char q, w, y; q = SDL_GetKeyFromScancode(SDL_SCANCODE_Q); w = SDL_GetKeyFromScancode(SDL_SCANCODE_W); y = SDL_GetKeyFromScancode(SDL_SCANCODE_Y); if (q == 'a' && w == 'z' && y == 'y') azerty = true; else if (q == 'q' && w == 'w' && y == 'z') qwertz = true; #elif defined(USING_WIN_UI) HKL localeId = GetKeyboardLayout(0); // TODO: Is this list complete enough? switch ((int)(intptr_t)localeId & 0xFFFF) { case 0x407: qwertz = true; break; case 0x040c: case 0x080c: case 0x1009: azerty = true; break; default: break; } #endif if (azerty) { SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultAzertyKeyboardKeyMap, ARRAY_SIZE(defaultAzertyKeyboardKeyMap), replace); } else if (qwertz) { SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultQwertzKeyboardKeyMap, ARRAY_SIZE(defaultQwertzKeyboardKeyMap), replace); } else { SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultQwertyKeyboardKeyMap, ARRAY_SIZE(defaultQwertyKeyboardKeyMap), replace); } } break; case DEFAULT_MAPPING_X360: SetDefaultKeyMap(DEVICE_ID_X360_0, default360KeyMap, ARRAY_SIZE(default360KeyMap), replace); break; case DEFAULT_MAPPING_SHIELD: SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultShieldKeyMap, ARRAY_SIZE(defaultShieldKeyMap), replace); break; case DEFAULT_MAPPING_PAD: SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultPadMap, ARRAY_SIZE(defaultPadMap), replace); break; case DEFAULT_MAPPING_OUYA: SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultOuyaMap, ARRAY_SIZE(defaultOuyaMap), replace); break; case DEFAULT_MAPPING_XPERIA_PLAY: SetDefaultKeyMap(DEVICE_ID_DEFAULT, defaultXperiaPlay, ARRAY_SIZE(defaultXperiaPlay), replace); break; } UpdateNativeMenuKeys(); }
void SetDefaultKeyMap(DefaultMaps dmap, bool replace) { switch (dmap) { case DEFAULT_MAPPING_KEYBOARD: { bool azerty = false; bool qwertz = false; #ifdef _WIN32 HKL localeId = GetKeyboardLayout(0); // TODO: Is this list complete enough? switch ((int)localeId & 0xFFFF) { case 0x407: qwertz = true; break; case 0x040c: case 0x080c: case 0x1009: azerty = true; break; default: break; } #endif if (azerty) { SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultAzertyKeyboardKeyMap, ARRAY_SIZE(defaultAzertyKeyboardKeyMap), replace); } else if (qwertz) { SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultQwertzKeyboardKeyMap, ARRAY_SIZE(defaultQwertzKeyboardKeyMap), replace); } else { SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultQwertyKeyboardKeyMap, ARRAY_SIZE(defaultQwertyKeyboardKeyMap), replace); } } break; case DEFAULT_MAPPING_X360: SetDefaultKeyMap(DEVICE_ID_X360_0, default360KeyMap, ARRAY_SIZE(default360KeyMap), replace); break; case DEFAULT_MAPPING_SHIELD: SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultShieldKeyMap, ARRAY_SIZE(defaultShieldKeyMap), replace); break; case DEFAULT_MAPPING_BLACKBERRY_QWERTY: SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultBlackberryQWERTYKeyMap, ARRAY_SIZE(defaultBlackberryQWERTYKeyMap), replace); replace = false; case DEFAULT_MAPPING_PAD: SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultPadMap, ARRAY_SIZE(defaultPadMap), replace); break; case DEFAULT_MAPPING_OUYA: SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultOuyaMap, ARRAY_SIZE(defaultOuyaMap), replace); break; case DEFAULT_MAPPING_XPERIA_PLAY: SetDefaultKeyMap(DEVICE_ID_DEFAULT, defaultXperiaPlay, ARRAY_SIZE(defaultXperiaPlay), replace); break; } UpdateConfirmCancelKeys(); }
// Note that it's easy to add other defaults if desired. void RestoreDefault() { g_controllerMap.clear(); #if defined(_WIN32) SetDefaultKeyMap(DEFAULT_MAPPING_KEYBOARD, true); SetDefaultKeyMap(DEFAULT_MAPPING_X360, false); SetDefaultKeyMap(DEFAULT_MAPPING_PAD, false); #elif defined(ANDROID) // Autodetect a few common devices std::string name = System_GetName(); if (name == "NVIDIA:SHIELD") { SetDefaultKeyMap(DEFAULT_MAPPING_SHIELD, true); } else if (name == "OUYA:OUYA Console") { // TODO: check! SetDefaultKeyMap(DEFAULT_MAPPING_OUYA, true); } else if (name == "Sony Ericsson:R800i" || name == "Sony Ericsson:zeus") { SetDefaultKeyMap(DEFAULT_MAPPING_XPERIA_PLAY, true); } else { SetDefaultKeyMap(DEFAULT_MAPPING_PAD, true); } #else SetDefaultKeyMap(DEFAULT_MAPPING_KEYBOARD, true); SetDefaultKeyMap(DEFAULT_MAPPING_PAD, false); #endif }
// Note that it's easy to add other defaults if desired. void RestoreDefault() { g_controllerMap.clear(); #if defined(_WIN32) SetDefaultKeyMap(DEFAULT_MAPPING_KEYBOARD, true); SetDefaultKeyMap(DEFAULT_MAPPING_X360, false); SetDefaultKeyMap(DEFAULT_MAPPING_PAD, false); #elif defined(__ANDROID__) // Autodetect a few common devices std::string name = System_GetProperty(SYSPROP_NAME); if (IsNvidiaShield(name) || IsNvidiaShieldTV(name)) { SetDefaultKeyMap(DEFAULT_MAPPING_SHIELD, true); } else if (IsOuya(name)) { // TODO: check! SetDefaultKeyMap(DEFAULT_MAPPING_OUYA, true); } else if (IsXperiaPlay(name)) { SetDefaultKeyMap(DEFAULT_MAPPING_XPERIA_PLAY, true); } else { SetDefaultKeyMap(DEFAULT_MAPPING_PAD, true); } #else SetDefaultKeyMap(DEFAULT_MAPPING_KEYBOARD, true); SetDefaultKeyMap(DEFAULT_MAPPING_PAD, false); #endif }
void SetDefaultKeyMap(DefaultMaps dmap, bool replace) { switch (dmap) { case DEFAULT_MAPPING_KEYBOARD: SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultKeyboardKeyMap, ARRAY_SIZE(defaultKeyboardKeyMap), replace); break; case DEFAULT_MAPPING_X360: SetDefaultKeyMap(DEVICE_ID_X360_0, default360KeyMap, ARRAY_SIZE(default360KeyMap), replace); break; case DEFAULT_MAPPING_SHIELD: SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultShieldKeyMap, ARRAY_SIZE(defaultShieldKeyMap), replace); break; case DEFAULT_MAPPING_PAD: SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultPadMap, ARRAY_SIZE(defaultPadMap), replace); break; case DEFAULT_MAPPING_OUYA: SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultOuyaMap, ARRAY_SIZE(defaultOuyaMap), replace); break; case DEFAULT_MAPPING_XPERIA_PLAY: SetDefaultKeyMap(DEVICE_ID_DEFAULT, defaultXperiaPlay, ARRAY_SIZE(defaultXperiaPlay), replace); break; } UpdateConfirmCancelKeys(); }