Skip to content

Commit 1b2fed4

Browse files
committed
refactor(input): Move KEY_REPEAT_INTERVAL_MSEC to class enum
1 parent 57e97f5 commit 1b2fed4

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

Generals/Code/GameEngine/Include/GameClient/Keyboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct KeyboardIO
8686
class Keyboard : public SubsystemInterface
8787
{
8888

89-
enum { KEY_REPEAT_DELAY_MSEC = 333 };
89+
enum { KEY_REPEAT_DELAY_MSEC = 333, KEY_REPEAT_INTERVAL_MSEC = 67 }; // ~2 frames at 30 FPS
9090

9191
public:
9292

Generals/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ Bool Keyboard::checkKeyRepeat( void )
219219

220220
// Scan Keyboard status array for first key down
221221
// long enough to repeat
222-
const UnsignedInt KEY_REPEAT_INTERVAL_MSEC = 67; // ~2 frames at 30 FPS
223222
for( key = 0; key < ARRAY_SIZE(m_keyStatus); key++ )
224223
{
225224

@@ -243,7 +242,7 @@ Bool Keyboard::checkKeyRepeat( void )
243242
m_keyStatus[ index ].keyDownTimeMsec = now;
244243

245244
// Set repeated key so it will repeat again after the interval
246-
m_keyStatus[ key ].keyDownTimeMsec = now - (Keyboard::KEY_REPEAT_DELAY_MSEC + KEY_REPEAT_INTERVAL_MSEC);
245+
m_keyStatus[ key ].keyDownTimeMsec = now - (Keyboard::KEY_REPEAT_DELAY_MSEC + Keyboard::KEY_REPEAT_INTERVAL_MSEC);
247246

248247
retVal = TRUE;
249248
break; // exit for key

GeneralsMD/Code/GameEngine/Include/GameClient/Keyboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct KeyboardIO
8686
class Keyboard : public SubsystemInterface
8787
{
8888

89-
enum { KEY_REPEAT_DELAY_MSEC = 333 };
89+
enum { KEY_REPEAT_DELAY_MSEC = 333, KEY_REPEAT_INTERVAL_MSEC = 67 }; // ~2 frames at 30 FPS
9090

9191
public:
9292

GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ Bool Keyboard::checkKeyRepeat( void )
219219

220220
// Scan Keyboard status array for first key down
221221
// long enough to repeat
222-
const UnsignedInt KEY_REPEAT_INTERVAL_MSEC = 67; // ~2 frames at 30 FPS
223222
for( key = 0; key < ARRAY_SIZE(m_keyStatus); key++ )
224223
{
225224

@@ -243,7 +242,7 @@ Bool Keyboard::checkKeyRepeat( void )
243242
m_keyStatus[ index ].keyDownTimeMsec = now;
244243

245244
// Set repeated key so it will repeat again after the interval
246-
m_keyStatus[ key ].keyDownTimeMsec = now - (Keyboard::KEY_REPEAT_DELAY_MSEC + KEY_REPEAT_INTERVAL_MSEC);
245+
m_keyStatus[ key ].keyDownTimeMsec = now - (Keyboard::KEY_REPEAT_DELAY_MSEC + Keyboard::KEY_REPEAT_INTERVAL_MSEC);
247246

248247
retVal = TRUE;
249248
break; // exit for key

0 commit comments

Comments
 (0)