Fix close inputs being throttled, and speed up scrolling when a key is held (#3515)

* Fix close inputs being throttled, and speed up scrolling when a key is held.

* Fix tabs
This commit is contained in:
Ryan 2018-10-16 10:13:01 -06:00 committed by Deve
parent bf7f734b69
commit 614d4ac2f7
2 changed files with 21 additions and 13 deletions

View File

@ -82,6 +82,7 @@ InputManager::InputManager() : m_mode(BOOTSTRAP),
m_timer_in_use = false; m_timer_in_use = false;
m_master_player_only = false; m_master_player_only = false;
m_timer = 0; m_timer = 0;
m_timer_use_count = 0;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -116,7 +117,7 @@ void InputManager::handleStaticAction(int key, int value)
// When no players... a cutscene // When no players... a cutscene
if (race_manager->getNumPlayers() == 0 && world != NULL && value > 0 && if (race_manager->getNumPlayers() == 0 && world != NULL && value > 0 &&
(key == IRR_KEY_SPACE || key == IRR_KEY_RETURN || (key == IRR_KEY_SPACE || key == IRR_KEY_RETURN ||
key == IRR_KEY_BUTTON_A)) key == IRR_KEY_BUTTON_A))
{ {
world->onFirePressed(NULL); world->onFirePressed(NULL);
@ -823,12 +824,6 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
// ... when in menus // ... when in menus
else else
{ {
// reset timer when released
if (abs(value) == 0 && type == Input::IT_STICKBUTTON)
{
m_timer_in_use = false;
m_timer = 0;
}
// When in master-only mode, we can safely assume that players // When in master-only mode, we can safely assume that players
// are set up, contrarly to early menus where we accept every // are set up, contrarly to early menus where we accept every
@ -860,7 +855,10 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
if (abs(value) > Input::MAX_VALUE*2/3) if (abs(value) > Input::MAX_VALUE*2/3)
{ {
m_timer_in_use = true; m_timer_in_use = true;
m_timer = 0.25;
// After three iterations of the timer, pick up the scrolling pace
m_timer_use_count++;
m_timer = m_timer_use_count > 3 ? 0.05 : 0.25;
} }
// player may be NULL in early menus, before player setup has // player may be NULL in early menus, before player setup has
@ -887,6 +885,14 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
->processGUIAction(action, deviceID, abs(value), type, ->processGUIAction(action, deviceID, abs(value), type,
playerID); playerID);
} }
// reset timer when released
if (abs(value) == 0)
{
m_timer_in_use = false;
m_timer = 0;
m_timer_use_count = 0;
}
} }
} }
else if (type == Input::IT_KEYBOARD) else if (type == Input::IT_KEYBOARD)
@ -1029,7 +1035,7 @@ EventPropagation InputManager::input(const SEvent& event)
// single letter). Same for spacebar. Same for letters. // single letter). Same for spacebar. Same for letters.
if (GUIEngine::isWithinATextBox()) if (GUIEngine::isWithinATextBox())
{ {
if (key == IRR_KEY_BACK || key == IRR_KEY_SPACE || if (key == IRR_KEY_BACK || key == IRR_KEY_SPACE ||
key == IRR_KEY_SHIFT) key == IRR_KEY_SHIFT)
{ {
return EVENT_LET; return EVENT_LET;
@ -1062,7 +1068,7 @@ EventPropagation InputManager::input(const SEvent& event)
// single letter). Same for spacebar. Same for letters. // single letter). Same for spacebar. Same for letters.
if (GUIEngine::isWithinATextBox()) if (GUIEngine::isWithinATextBox())
{ {
if (key == IRR_KEY_BACK || key == IRR_KEY_SPACE || if (key == IRR_KEY_BACK || key == IRR_KEY_SPACE ||
key == IRR_KEY_SHIFT) key == IRR_KEY_SHIFT)
{ {
return EVENT_LET; return EVENT_LET;

View File

@ -46,9 +46,6 @@ public:
BOOTSTRAP BOOTSTRAP
}; };
// to put a delay before a new gamepad axis move is considered in menu
bool m_timer_in_use;
float m_timer;
private: private:
@ -68,6 +65,11 @@ private:
*/ */
int m_mouse_val_x, m_mouse_val_y; int m_mouse_val_x, m_mouse_val_y;
// to put a delay before a new gamepad axis move is considered in menu
bool m_timer_in_use;
int m_timer_use_count;
float m_timer;
void dispatchInput(Input::InputType, int deviceID, int btnID, void dispatchInput(Input::InputType, int deviceID, int btnID,
Input::AxisDirection direction, int value, Input::AxisDirection direction, int value,
bool shift_mask = false); bool shift_mask = false);