diff options
Diffstat (limited to 'src/joystick.cpp')
-rw-r--r-- | src/joystick.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/joystick.cpp b/src/joystick.cpp index 2bd8b582a..3222c9825 100644 --- a/src/joystick.cpp +++ b/src/joystick.cpp @@ -275,7 +275,7 @@ KeysVector *Joystick::getActionVector(const SDL_Event &event) return nullptr; } -int Joystick::getButtonFromEvent(const SDL_Event &event) +int Joystick::getButtonFromEvent(const SDL_Event &event) const { if (event.jbutton.which != mNumber) return -1; @@ -284,6 +284,9 @@ int Joystick::getButtonFromEvent(const SDL_Event &event) bool Joystick::isActionActive(int index) const { + if (!validate()) + return false; + const KeyFunction &key = inputManager.getKey(index); for (size_t i = 0; i < KeyFunctionSize; i ++) { @@ -298,3 +301,11 @@ bool Joystick::isActionActive(int index) const } return false; } + +bool Joystick::validate() const +{ + if (mCalibrating || !mEnabled || !mCalibrated) + return false; + + return (mUseInactive || Client::getInputFocused()); +} |