diff options
Diffstat (limited to 'src/input')
-rw-r--r-- | src/input/inputactionmap.h | 24 | ||||
-rw-r--r-- | src/input/inputmanager.cpp | 44 | ||||
-rw-r--r-- | src/input/joystick.cpp | 4 | ||||
-rw-r--r-- | src/input/key.h | 2 | ||||
-rw-r--r-- | src/input/keyboardconfig.cpp | 15 | ||||
-rw-r--r-- | src/input/keyboardconfig.h | 4 | ||||
-rw-r--r-- | src/input/keyinput.h | 10 | ||||
-rw-r--r-- | src/input/mouseinput.h | 5 | ||||
-rw-r--r-- | src/input/pages/other.cpp | 2 | ||||
-rw-r--r-- | src/input/touch/multitouchmanager.cpp | 4 | ||||
-rw-r--r-- | src/input/touch/multitouchmanager.h | 4 |
11 files changed, 66 insertions, 52 deletions
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index 85595d43b..44cc82845 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -316,9 +316,9 @@ static const InputActionData inputActionData addKey(SDLK_ESCAPE), #if defined(USE_SDL2) && defined(ANDROID) addKey(SDLK_AC_BACK), -#else +#else // defined(USE_SDL2) && defined(ANDROID) emptyKey, -#endif +#endif // defined(USE_SDL2) && defined(ANDROID) Input::GRP_DEFAULT, &Actions::quit, InputAction::NO_VALUE, 50, @@ -2311,9 +2311,9 @@ static const InputActionData inputActionData {"keyIgnoreInput1", #ifdef USE_SDL2 emptyKey, -#else +#else // USE_SDL2 addKey(SDLK_LSUPER), -#endif +#endif // USE_SDL2 emptyKey, Input::GRP_DEFAULT, &Actions::ignoreInput, @@ -2325,9 +2325,9 @@ static const InputActionData inputActionData {"keyIgnoreInput2", #ifdef USE_SDL2 emptyKey, -#else +#else // USE_SDL2 addKey(SDLK_RSUPER), -#endif +#endif // USE_SDL2 emptyKey, Input::GRP_DEFAULT, &Actions::ignoreInput, @@ -2637,9 +2637,9 @@ static const InputActionData inputActionData addKey(SDLK_ESCAPE), #if defined(USE_SDL2) && defined(ANDROID) addKey(SDLK_AC_BACK), -#else +#else // defined(USE_SDL2) && defined(ANDROID) emptyKey, -#endif +#endif // defined(USE_SDL2) && defined(ANDROID) Input::GRP_GUICHAN, nullptr, InputAction::NO_VALUE, 50, @@ -3503,16 +3503,16 @@ static const InputActionData inputActionData Input::GRP_DEFAULT, #if defined USE_OPENGL && defined DEBUG_SDLFONT &Actions::testSdlFont, -#else +#else // defined USE_OPENGL && defined DEBUG_SDLFONT nullptr, -#endif +#endif // defined USE_OPENGL && defined DEBUG_SDLFONT InputAction::NO_VALUE, 50, InputCondition::INGAME, #if defined USE_OPENGL && defined DEBUG_SDLFONT "testsdlfont", -#else +#else // defined USE_OPENGL && defined DEBUG_SDLFONT "", -#endif +#endif // defined USE_OPENGL && defined DEBUG_SDLFONT UseArgs_false, Protected_true}, {"keyEnableHightlight", diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index d07522146..a916776c0 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -33,7 +33,7 @@ #include "input/keyboardconfig.h" #ifdef USE_SDL2 #include "input/touch/multitouchmanager.h" -#endif +#endif // USE_SDL2 #include "input/touch/touchmanager.h" @@ -129,9 +129,11 @@ void InputManager::retrieve() restrict2 #ifdef USE_SDL2 const std::string cf = std::string("sdl2") + inputActionData[i].configField; -#else +#else // USE_SDL2 + const std::string cf = inputActionData[i].configField; -#endif +#endif // USE_SDL2 + InputFunction &restrict kf = mKey[i]; if (!cf.empty()) { @@ -191,9 +193,11 @@ void InputManager::store() const restrict2 #ifdef USE_SDL2 const std::string cf = std::string("sdl2") + inputActionData[i].configField; -#else +#else // USE_SDL2 + const std::string cf = inputActionData[i].configField; -#endif +#endif // USE_SDL2 + if (!cf.empty()) { std::string keyStr; @@ -268,10 +272,12 @@ void InputManager::resetKey(const InputActionT i) restrict2 val0.value = -1; if (val1.value == SDL_SCANCODE_UNKNOWN) val1.value = -1; -#else +#else // USE_SDL2 + val0.value = kd.defaultValue1; val1.value = kd.defaultValue2; -#endif +#endif // USE_SDL2 + updateKeyString(key, CAST_SIZE(i)); } @@ -343,7 +349,7 @@ void InputManager::callbackNewKey() restrict2 { #ifndef DYECMD mSetupInput->newKeyCallback(mNewKeyIndex); -#endif +#endif // DYECMD } bool InputManager::isActionActive(const InputActionT index) const restrict2 @@ -570,13 +576,14 @@ bool InputManager::handleAssignKey(const SDL_Event &restrict event, } return false; } -#else +#else // DYECMD + bool InputManager::handleAssignKey(const SDL_Event &restrict event A_UNUSED, const InputTypeT type A_UNUSED) restrict2 { return false; } -#endif +#endif // DYECMD bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2 { @@ -605,7 +612,8 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2 BLOCK_END("InputManager::handleEvent") return true; } -#endif +#endif // DYECMD + break; } case SDL_KEYUP: @@ -639,14 +647,15 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2 case SDL_FINGERUP: multiTouchManager.handleFingerUp(event); break; -#else +#else // USE_SDL2 #ifdef ANDROID case SDL_ACCELEROMETER: { break; } -#endif -#endif +#endif // ANDROID +#endif // USE_SDL2 + default: break; } @@ -689,8 +698,9 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2 { break; } -#endif -#endif +#endif // USE_SDL2 +#endif // ANDROID + default: break; } @@ -779,7 +789,7 @@ void InputManager::updateConditionMask() restrict2 mMask |= InputCondition::NOFOLLOW; mMask |= InputCondition::NOBLOCK; } -#endif +#endif // DYECMD if (!settings.awayMode) mMask |= InputCondition::NOAWAY; diff --git a/src/input/joystick.cpp b/src/input/joystick.cpp index eb816c239..5c91edd43 100644 --- a/src/input/joystick.cpp +++ b/src/input/joystick.cpp @@ -198,7 +198,7 @@ void Joystick::logic() logger->log("axis 3 pos: %d", SDL_JoystickGetAxis(mJoystick, 3)); if (SDL_JoystickGetAxis(mJoystick, 4)) logger->log("axis 4 pos: %d", SDL_JoystickGetAxis(mJoystick, 4)); -#endif +#endif // DEBUG_JOYSTICK if (!mDirection && mHaveHats) { @@ -224,7 +224,7 @@ void Joystick::logic() #ifdef DEBUG_JOYSTICK if (mActiveButtons[i]) logger->log("button: %d", i); -#endif +#endif // DEBUG_JOYSTICK } } else diff --git a/src/input/key.h b/src/input/key.h index c0cc37b00..42440721f 100644 --- a/src/input/key.h +++ b/src/input/key.h @@ -71,7 +71,7 @@ // that windows define with Guichan. #if defined (_WIN32) && defined(DELETE) #undef DELETE -#endif +#endif // defined (_WIN32) && defined(DELETE) /** * Represents a key or a character. diff --git a/src/input/keyboardconfig.cpp b/src/input/keyboardconfig.cpp index 888b86724..ecd563656 100644 --- a/src/input/keyboardconfig.cpp +++ b/src/input/keyboardconfig.cpp @@ -63,13 +63,14 @@ int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event) { #ifdef USE_SDL2 return event.key.keysym.scancode; -#else +#else // USE_SDL2 + if (event.key.keysym.sym) return CAST_S32(event.key.keysym.sym); else if (event.key.keysym.scancode > 1) return -event.key.keysym.scancode; return 0; -#endif +#endif // USE_SDL2 } InputActionT KeyboardConfig::getKeyIndex(const SDL_Event &event, const int grp) @@ -92,9 +93,10 @@ std::string KeyboardConfig::getKeyName(const int key) #ifdef USE_SDL2 return SDL_GetKeyName(SDL_GetKeyFromScancode( static_cast<SDL_Scancode>(key))); -#else +#else // USE_SDL2 + return SDL_GetKeyName(static_cast<SDLKey>(key)); -#endif +#endif // USE_SDL2 } // TRANSLATORS: long key name, should be short @@ -151,9 +153,10 @@ SDLKey KeyboardConfig::getKeyFromEvent(const SDL_Event &event) { #ifdef USE_SDL2 return event.key.keysym.scancode; -#else +#else // USE_SDL2 + return event.key.keysym.sym; -#endif +#endif // USE_SDL2 } KeysVector *KeyboardConfig::getActionVector(const SDL_Event &event) diff --git a/src/input/keyboardconfig.h b/src/input/keyboardconfig.h index 6d7830ee7..3b9610141 100644 --- a/src/input/keyboardconfig.h +++ b/src/input/keyboardconfig.h @@ -26,12 +26,12 @@ #ifdef USE_SDL2 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wswitch-default" -#endif +#endif // USE_SDL2 #include <SDL_stdinc.h> _SDL_stdinc_h #ifdef USE_SDL2 #pragma GCC diagnostic pop -#endif +#endif // USE_SDL2 #include <SDL_keyboard.h> #include "sdlshared.h" diff --git a/src/input/keyinput.h b/src/input/keyinput.h index d582303a0..cd5235575 100644 --- a/src/input/keyinput.h +++ b/src/input/keyinput.h @@ -84,7 +84,7 @@ class KeyInput final mType(KeyEventType::PRESSED), #ifdef USE_SDL2 mText(), -#endif +#endif // USE_SDL2 mActionId(InputAction::UNDEFINED_VALUE) { } @@ -93,7 +93,7 @@ class KeyInput final mType(k.mType), #ifdef USE_SDL2 mText(k.mText), -#endif +#endif // USE_SDL2 mActionId(k.mActionId) { } @@ -104,7 +104,7 @@ class KeyInput final mType = k.mType; #ifdef USE_SDL2 mText = k.mText; -#endif +#endif // USE_SDL2 mActionId = k.mActionId; return *this; } @@ -152,7 +152,7 @@ class KeyInput final { return mText; } -#endif +#endif // USE_SDL2 protected: /** @@ -167,7 +167,7 @@ class KeyInput final #ifdef USE_SDL2 std::string mText; -#endif +#endif // USE_SDL2 InputActionT mActionId; }; diff --git a/src/input/mouseinput.h b/src/input/mouseinput.h index e4efa93c9..a8a948cf3 100644 --- a/src/input/mouseinput.h +++ b/src/input/mouseinput.h @@ -173,13 +173,14 @@ class MouseInput final int getTouchY() const A_WARN_UNUSED { return mRealY; } -#else +#else // ANDROID + int getTouchX() const A_WARN_UNUSED { return mX; } int getTouchY() const A_WARN_UNUSED { return mY; } -#endif +#endif // ANDROID protected: /** diff --git a/src/input/pages/other.cpp b/src/input/pages/other.cpp index 3a0ab3154..997bec32a 100644 --- a/src/input/pages/other.cpp +++ b/src/input/pages/other.cpp @@ -390,7 +390,7 @@ SetupActionData setupActionDataOther[] = InputAction::TEST_SDL_FONT, "", }, -#endif +#endif // defined USE_OPENGL && defined DEBUG_SDLFONT { // TRANSLATORS: input action name N_("Upload main config"), diff --git a/src/input/touch/multitouchmanager.cpp b/src/input/touch/multitouchmanager.cpp index b608b0085..b268df0e5 100644 --- a/src/input/touch/multitouchmanager.cpp +++ b/src/input/touch/multitouchmanager.cpp @@ -24,7 +24,7 @@ #include "render/graphics.h" #include "gui/sdlinput.h" -#endif +#endif // USE_SDL2 #include "debug.h" MultiTouchManager multiTouchManager; @@ -85,4 +85,4 @@ void MultiTouchManager::checkDevice(const long touchId, } } } -#endif +#endif // USE_SDL2 diff --git a/src/input/touch/multitouchmanager.h b/src/input/touch/multitouchmanager.h index 25b56d3d8..a9323991c 100644 --- a/src/input/touch/multitouchmanager.h +++ b/src/input/touch/multitouchmanager.h @@ -27,7 +27,7 @@ #ifdef USE_SDL2 union SDL_Event; -#endif +#endif // USE_SDL2 struct MultiTouchEvent final { @@ -59,7 +59,7 @@ class MultiTouchManager final void checkDevice(const long touchId, const long fingerId); -#endif +#endif // USE_SDL2 private: MultiTouchDevicesMap mEvents; |