Adds keyboard delay fixes
This commit is contained in:
parent
0ad39d8fb8
commit
e1e010e1dc
17
src/input.cc
17
src/input.cc
|
@ -127,7 +127,20 @@ static unsigned int gLastTickCount;
|
||||||
static unsigned int gStoredTickCount;
|
static unsigned int gStoredTickCount;
|
||||||
static float gTickCountFraction;
|
static float gTickCountFraction;
|
||||||
static time_t gStartTime;
|
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<int>(INPUT_DEFAULT_KEYBOARD_KEY_REPEAT_RATE * gSpeedMulti);
|
||||||
|
gKeyboardKeyRepeatDelay = static_cast<int>(INPUT_DEFAULT_KEYBOARD_KEY_REPEAT_DELAY * gSpeedMulti);
|
||||||
|
gDefaultDelay = false;
|
||||||
|
}
|
||||||
|
|
||||||
// 0x4C8A70
|
// 0x4C8A70
|
||||||
int inputInit(int a1)
|
int inputInit(int a1)
|
||||||
|
@ -178,6 +191,7 @@ int inputInit(int a1)
|
||||||
gStoredTickCount = 0;
|
gStoredTickCount = 0;
|
||||||
gTickCountFraction = 0.0f;
|
gTickCountFraction = 0.0f;
|
||||||
gStartTime = time(NULL);
|
gStartTime = time(NULL);
|
||||||
|
gDefaultDelay = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -659,6 +673,9 @@ unsigned int getTicks()
|
||||||
elapsed *= gSpeedMulti;
|
elapsed *= gSpeedMulti;
|
||||||
elapsed += gTickCountFraction;
|
elapsed += gTickCountFraction;
|
||||||
gTickCountFraction = modff(gTickCountFraction, &gTickCountFraction);
|
gTickCountFraction = modff(gTickCountFraction, &gTickCountFraction);
|
||||||
|
if (gDefaultDelay) SetKeyboardDelay();
|
||||||
|
} else {
|
||||||
|
SetKeyboardDefaultDelay();
|
||||||
}
|
}
|
||||||
|
|
||||||
gStoredTickCount += static_cast<unsigned int>(elapsed);
|
gStoredTickCount += static_cast<unsigned int>(elapsed);
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
|
|
||||||
namespace fallout {
|
namespace fallout {
|
||||||
|
|
||||||
|
#define INPUT_DEFAULT_KEYBOARD_KEY_REPEAT_RATE 80
|
||||||
|
#define INPUT_DEFAULT_KEYBOARD_KEY_REPEAT_DELAY 500
|
||||||
|
|
||||||
typedef void(IdleFunc)();
|
typedef void(IdleFunc)();
|
||||||
typedef void(FocusFunc)(bool focus);
|
typedef void(FocusFunc)(bool focus);
|
||||||
typedef void(TickerProc)();
|
typedef void(TickerProc)();
|
||||||
|
|
Loading…
Reference in New Issue