diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-09-10 01:11:39 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-09-10 01:11:39 +0300 |
commit | 7fd1401d915ee91c808695ca1f3647ca7a258a1f (patch) | |
tree | d1aa0867879ea2ebb3ecd2910ef02ce09cb764d0 /src/input/inputmanager.cpp | |
parent | 481ea0b776bbab92b500540f59c5a191c6e93cba (diff) | |
download | plus-7fd1401d915ee91c808695ca1f3647ca7a258a1f.tar.gz plus-7fd1401d915ee91c808695ca1f3647ca7a258a1f.tar.bz2 plus-7fd1401d915ee91c808695ca1f3647ca7a258a1f.tar.xz plus-7fd1401d915ee91c808695ca1f3647ca7a258a1f.zip |
Allow trigger input action on key press or/and release.
By default all actions triggered on press key.
Diffstat (limited to 'src/input/inputmanager.cpp')
-rw-r--r-- | src/input/inputmanager.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index 42a4e3b25..cf8c75cd6 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -603,7 +603,7 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2 #endif // USE_SDL2 keyboard.refreshActiveKeys(); - updateConditionMask(); + updateConditionMask(true); if (handleAssignKey(event, InputType::KEYBOARD)) { BLOCK_END("InputManager::handleEvent") @@ -637,13 +637,13 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2 #endif // USE_SDL2 keyboard.refreshActiveKeys(); - updateConditionMask(); + updateConditionMask(false); keyboard.handleDeActicateKey(event); break; } case SDL_JOYBUTTONDOWN: { - updateConditionMask(); + updateConditionMask(true); // joystick.handleActicateButton(event); if (handleAssignKey(event, InputType::JOYSTICK)) { @@ -654,7 +654,7 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2 } case SDL_JOYBUTTONUP: { - updateConditionMask(); + updateConditionMask(false); // joystick.handleDeActicateButton(event); break; } @@ -693,6 +693,7 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2 switch (event.type) { case SDL_KEYDOWN: + case SDL_KEYUP: if (triggerAction(keyboard.getActionVector(event))) { BLOCK_END("InputManager::handleEvent") @@ -735,7 +736,7 @@ void InputManager::handleRepeat() joystick->handleRepeat(time); } -void InputManager::updateConditionMask() restrict2 +void InputManager::updateConditionMask(const bool pressed) restrict2 { mMask = 1; if (keyboard.isEnabled()) @@ -823,6 +824,10 @@ void InputManager::updateConditionMask() restrict2 { mMask |= InputCondition::NOTARGET; } + if (pressed == true) + mMask |= InputCondition::KEY_DOWN; + else + mMask |= InputCondition::KEY_UP; } bool InputManager::checkKey(const InputActionData *restrict const key) const |