diff --git a/src/input.cc b/src/input.cc index 8fc65a8..9f61565 100644 --- a/src/input.cc +++ b/src/input.cc @@ -127,7 +127,20 @@ static unsigned int gLastTickCount; static unsigned int gStoredTickCount; static float gTickCountFraction; static time_t gStartTime; +static bool gDefaultDelay; +static void SetKeyboardDefaultDelay() { + if (gDefaultDelay) return; + gDefaultDelay = true; + gKeyboardKeyRepeatRate = INPUT_DEFAULT_KEYBOARD_KEY_REPEAT_RATE; + gKeyboardKeyRepeatDelay = INPUT_DEFAULT_KEYBOARD_KEY_REPEAT_DELAY; +} + +static void SetKeyboardDelay() { + gKeyboardKeyRepeatRate = static_cast(INPUT_DEFAULT_KEYBOARD_KEY_REPEAT_RATE * gSpeedMulti); + gKeyboardKeyRepeatDelay = static_cast(INPUT_DEFAULT_KEYBOARD_KEY_REPEAT_DELAY * gSpeedMulti); + gDefaultDelay = false; +} // 0x4C8A70 int inputInit(int a1) @@ -178,6 +191,7 @@ int inputInit(int a1) gStoredTickCount = 0; gTickCountFraction = 0.0f; gStartTime = time(NULL); + gDefaultDelay = true; return 0; } @@ -659,6 +673,9 @@ unsigned int getTicks() elapsed *= gSpeedMulti; elapsed += gTickCountFraction; gTickCountFraction = modff(gTickCountFraction, &gTickCountFraction); + if (gDefaultDelay) SetKeyboardDelay(); + } else { + SetKeyboardDefaultDelay(); } gStoredTickCount += static_cast(elapsed); diff --git a/src/input.h b/src/input.h index 8288687..1f820bf 100644 --- a/src/input.h +++ b/src/input.h @@ -5,6 +5,9 @@ namespace fallout { +#define INPUT_DEFAULT_KEYBOARD_KEY_REPEAT_RATE 80 +#define INPUT_DEFAULT_KEYBOARD_KEY_REPEAT_DELAY 500 + typedef void(IdleFunc)(); typedef void(FocusFunc)(bool focus); typedef void(TickerProc)();