void RemoveButtonMapping(int btn) { for (auto iter = g_controllerMap.begin(); iter != g_controllerMap.end(); ++iter) { if (iter->first == btn) { g_controllerMap.erase(iter); return; } } }
// 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; }
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; }
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; }
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; }