void InputManager::retrieve() { for (int i = 0; i < InputAction::TOTAL; i++) { #ifdef USE_SDL2 const std::string cf = std::string("sdl2") + inputActionData[i].configField; #else const std::string cf = inputActionData[i].configField; #endif if (!cf.empty()) { mNameMap[cf] = i; InputFunction &kf = mKey[i]; const std::string keyStr = config.getValue(cf, ""); const size_t keyStrSize = keyStr.size(); if (keyStr.empty()) continue; StringVect keys; splitToStringVector(keys, keyStr, ','); unsigned int i2 = 0; for (StringVectCIter it = keys.begin(), it_end = keys.end(); it != it_end && i2 < inputFunctionSize; ++ it) { std::string keyStr2 = *it; if (keyStrSize < 2) continue; int type = InputType::KEYBOARD; if ((keyStr2[0] < '0' || keyStr2[0] > '9') && keyStr2[0] != '-') { switch (keyStr2[0]) { case 'm': type = InputType::MOUSE; break; case 'j': type = InputType::JOYSTICK; break; default: break; } keyStr2 = keyStr2.substr(1); } const int key = atoi(keyStr2.c_str()); if (key >= -255 && key < SDLK_LAST) { kf.values[i2] = InputItem(type, key); i2 ++; } } } } }
special_move::InputItem SpecialMoveDetectionAspect::extractInputItem(GameState & gs, PlayerReport & rep, PlayerId id) { special_move::InputItem it; InputContainer const & cont = gs.getEngines().inputEngine().getContainerConst(id); if (rep.m_jumpKeyReport.report(cont, it)) return it; if (rep.m_kickKeyReport.report(cont, it)) return it; if (rep.m_rightDirectionReport.report(cont, it)) return it; if (rep.m_leftDirectionReport.report(cont, it)) return it; if (rep.m_upDirectionReport.report(cont, it)) return it; if (rep.m_downDirectionReport.report(cont, it)) return it; // return an undefined to signal we have nothing to report return InputItem(); }
/************************************************* Function: keymain_proc Descroption: Input: None Output: Return: Other: *************************************************/ static INT8U keytimer_proc(void) { INT8U ret = 0; PKEYSTATE Key = getKeyCode(); if(Key != NULL && Key->State == KEY_DOWN) { switch(Key->Code) { case KEY_CODE_MENU: break; case KEY_CODE_OK: if(mEdit == 1) { mEdit = 0; } else { mEdit = 1; } InvalidateRect(NULL); break; case KEY_CODE_0: case KEY_CODE_1: case KEY_CODE_2: case KEY_CODE_3: case KEY_CODE_4: case KEY_CODE_5: case KEY_CODE_6: case KEY_CODE_7: case KEY_CODE_8: case KEY_CODE_9: InputItem(Key->Code); break; case KEY_CODE_LEFT: if(mEdit == 1) { ChangeItem(0); } break; case KEY_CODE_RIGHT: if(mEdit == 1) { ChangeItem(1); } break; case KEY_CODE_POWER: SaveParam(); GuiBackWindow(GUI_SYS_SETTING); break; default: break; } } return ret; }