本文整理汇总了C++中KeyMapping类的典型用法代码示例。如果您正苦于以下问题:C++ KeyMapping类的具体用法?C++ KeyMapping怎么用?C++ KeyMapping使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyMapping类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindKeyMapping
static bool FindKeyMapping(int deviceId, int key, std::vector<int> *psp_button) {
// Brute force, let's optimize later
for (auto iter = g_controllerMap.begin(); iter != g_controllerMap.end(); ++iter) {
for (auto iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2) {
if (*iter2 == KeyDef(deviceId, key)) {
psp_button->push_back(iter->first);
}
}
}
return psp_button->size() > 0;
}
示例2: FindKeyMapping
static bool FindKeyMapping(int deviceId, int key, int *psp_button) {
// Brute force, let's optimize later
for (auto iter = g_controllerMap.begin(); iter != g_controllerMap.end(); ++iter) {
for (auto iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2) {
if (*iter2 == KeyDef(deviceId, key)) {
*psp_button = iter->first;
return true;
}
}
}
return false;
}
示例3: LoadFromIni
// TODO: Make the ini format nicer.
void LoadFromIni(IniFile &file) {
RestoreDefault();
if (!file.HasSection("ControlMapping")) {
return;
}
IniFile::Section *controls = file.GetOrCreateSection("ControlMapping");
for (size_t i = 0; i < ARRAY_SIZE(psp_button_names); i++) {
std::string value;
controls->Get(psp_button_names[i].name.c_str(), &value, "");
// Erase default mapping
g_controllerMap.erase(psp_button_names[i].key);
if (value.empty())
continue;
std::vector<std::string> mappings;
SplitString(value, ',', mappings);
for (size_t j = 0; j < mappings.size(); j++) {
std::vector<std::string> parts;
SplitString(mappings[j], '-', parts);
int deviceId = atoi(parts[0].c_str());
int keyCode = atoi(parts[1].c_str());
SetKeyMapping(psp_button_names[i].key, KeyDef(deviceId, keyCode), false);
}
}
UpdateConfirmCancelKeys();
}
示例4: AxisDef
namespace KeyMap {
KeyDef AxisDef(int deviceId, int axisId, int direction);
struct DefMappingStruct {
int pspKey;
int key;
int direction;
};
KeyMapping g_controllerMap;
static const DefMappingStruct defaultQwertyKeyboardKeyMap[] = {
{CTRL_SQUARE, NKCODE_A},
{CTRL_TRIANGLE, NKCODE_S},
{CTRL_CIRCLE, NKCODE_X},
{CTRL_CROSS, NKCODE_Z},
{CTRL_LTRIGGER, NKCODE_Q},
{CTRL_RTRIGGER, NKCODE_W},
{CTRL_START, NKCODE_SPACE},
#ifdef _WIN32
{CTRL_SELECT, NKCODE_V},
#else
{CTRL_SELECT, NKCODE_ENTER},
#endif
{CTRL_UP , NKCODE_DPAD_UP},
{CTRL_DOWN , NKCODE_DPAD_DOWN},
{CTRL_LEFT , NKCODE_DPAD_LEFT},
{CTRL_RIGHT, NKCODE_DPAD_RIGHT},
{VIRTKEY_AXIS_Y_MAX, NKCODE_I},
{VIRTKEY_AXIS_Y_MIN, NKCODE_K},
{VIRTKEY_AXIS_X_MIN, NKCODE_J},
{VIRTKEY_AXIS_X_MAX, NKCODE_L},
{VIRTKEY_RAPID_FIRE , NKCODE_SHIFT_LEFT},
{VIRTKEY_UNTHROTTLE , NKCODE_TAB},
{VIRTKEY_SPEED_TOGGLE, NKCODE_GRAVE},
{VIRTKEY_PAUSE , NKCODE_ESCAPE},
{VIRTKEY_REWIND , NKCODE_DEL},
};
static const DefMappingStruct defaultAzertyKeyboardKeyMap[] = {
{CTRL_SQUARE, NKCODE_Q},
{CTRL_TRIANGLE, NKCODE_S},
{CTRL_CIRCLE, NKCODE_X},
{CTRL_CROSS, NKCODE_W},
{CTRL_LTRIGGER, NKCODE_A},
{CTRL_RTRIGGER, NKCODE_Z},
{CTRL_START, NKCODE_SPACE},
#ifdef _WIN32
{CTRL_SELECT, NKCODE_V},
#else
{CTRL_SELECT, NKCODE_ENTER},
#endif
{CTRL_UP , NKCODE_DPAD_UP},
{CTRL_DOWN , NKCODE_DPAD_DOWN},
{CTRL_LEFT , NKCODE_DPAD_LEFT},
{CTRL_RIGHT, NKCODE_DPAD_RIGHT},
{VIRTKEY_AXIS_Y_MAX, NKCODE_I},
{VIRTKEY_AXIS_Y_MIN, NKCODE_K},
{VIRTKEY_AXIS_X_MIN, NKCODE_J},
{VIRTKEY_AXIS_X_MAX, NKCODE_L},
{VIRTKEY_RAPID_FIRE , NKCODE_SHIFT_LEFT},
{VIRTKEY_UNTHROTTLE , NKCODE_TAB},
{VIRTKEY_SPEED_TOGGLE, NKCODE_GRAVE},
{VIRTKEY_PAUSE , NKCODE_ESCAPE},
{VIRTKEY_REWIND , NKCODE_DEL},
};
static const DefMappingStruct defaultQwertzKeyboardKeyMap[] = {
{CTRL_SQUARE, NKCODE_A},
{CTRL_TRIANGLE, NKCODE_S},
{CTRL_CIRCLE, NKCODE_X},
{CTRL_CROSS, NKCODE_Y},
{CTRL_LTRIGGER, NKCODE_Q},
{CTRL_RTRIGGER, NKCODE_W},
{CTRL_START, NKCODE_SPACE},
#ifdef _WIN32
{CTRL_SELECT, NKCODE_V},
#else
{CTRL_SELECT, NKCODE_ENTER},
#endif
{CTRL_UP , NKCODE_DPAD_UP},
{CTRL_DOWN , NKCODE_DPAD_DOWN},
{CTRL_LEFT , NKCODE_DPAD_LEFT},
{CTRL_RIGHT, NKCODE_DPAD_RIGHT},
{VIRTKEY_AXIS_Y_MAX, NKCODE_I},
{VIRTKEY_AXIS_Y_MIN, NKCODE_K},
{VIRTKEY_AXIS_X_MIN, NKCODE_J},
{VIRTKEY_AXIS_X_MAX, NKCODE_L},
{VIRTKEY_RAPID_FIRE , NKCODE_SHIFT_LEFT},
{VIRTKEY_UNTHROTTLE , NKCODE_TAB},
{VIRTKEY_SPEED_TOGGLE, NKCODE_GRAVE},
{VIRTKEY_PAUSE , NKCODE_ESCAPE},
{VIRTKEY_REWIND , NKCODE_DEL},
};
static const DefMappingStruct default360KeyMap[] = {
//.........这里部分代码省略.........
示例5: RemoveButtonMapping
void RemoveButtonMapping(int btn) {
for (auto iter = g_controllerMap.begin(); iter != g_controllerMap.end(); ++iter) {
if (iter->first == btn) {
g_controllerMap.erase(iter);
return;
}
}
}
示例6: KeyFromPspButton
// TODO: vector output
bool KeyFromPspButton(int btn, std::vector<KeyDef> *keys) {
for (auto iter = g_controllerMap.begin(); iter != g_controllerMap.end(); ++iter) {
if (iter->first == btn) {
for (auto iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2) {
keys->push_back(*iter2);
}
}
}
return keys->size() > 0;
}
示例7: AxisFromPspButton
bool AxisFromPspButton(int btn, int *deviceId, int *axisId, int *direction) {
for (auto iter = g_controllerMap.begin(); iter != g_controllerMap.end(); ++iter) {
for (auto iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2) {
if (iter->first == btn && iter2->keyCode >= AXIS_BIND_NKCODE_START) {
*deviceId = iter2->deviceId;
*axisId = TranslateKeyCodeToAxis(iter2->keyCode, *direction);
return true;
}
}
}
return false;
}
示例8: RestoreDefault
// 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)) {
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);
}
#elif defined(BLACKBERRY)
std::string name = System_GetProperty(SYSPROP_NAME);
if (IsBlackberryQWERTY(name)) {
SetDefaultKeyMap(DEFAULT_MAPPING_BLACKBERRY_QWERTY, true);
} else {
SetDefaultKeyMap(DEFAULT_MAPPING_PAD, true);
}
#else
SetDefaultKeyMap(DEFAULT_MAPPING_KEYBOARD, true);
SetDefaultKeyMap(DEFAULT_MAPPING_PAD, false);
#endif
}
示例9: RestoreDefault
// 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
}