Skip to content

Commit f23ac79

Browse files
committed
refactor(input): Move KEY_REPEAT_INTERVAL_MSEC constant to improve code clarity
1 parent 54e20f5 commit f23ac79

File tree

2 files changed

+4
-4
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameClient/Input
  • Generals/Code/GameEngine/Source/GameClient/Input

2 files changed

+4
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ Bool Keyboard::checkKeyRepeat( void )
225225

226226
// Scan Keyboard status array for first key down
227227
// long enough to repeat
228+
const UnsignedInt KEY_REPEAT_INTERVAL_MSEC = 67; // ~2 frames at 30 FPS
228229
UnsignedInt now = timeGetTime();
229230
for( key = 0; key < ARRAY_SIZE(m_keyStatus); key++ )
230231
{
@@ -246,8 +247,7 @@ Bool Keyboard::checkKeyRepeat( void )
246247
for( index = 0; index< NUM_KEYS; index++ )
247248
m_keyStatus[ index ].sequence = m_inputFrame;
248249

249-
// Set repeated key so it will repeat again after a short interval
250-
const UnsignedInt KEY_REPEAT_INTERVAL_MSEC = 67; // ~2 frames at 30 FPS
250+
// Set repeated key so it will repeat again after the interval
251251
m_keyStatus[ key ].keyDownTimeMsec = now - (Keyboard::KEY_REPEAT_DELAY_MSEC - KEY_REPEAT_INTERVAL_MSEC);
252252

253253
retVal = TRUE;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ Bool Keyboard::checkKeyRepeat( void )
225225

226226
// Scan Keyboard status array for first key down
227227
// long enough to repeat
228+
const UnsignedInt KEY_REPEAT_INTERVAL_MSEC = 67; // ~2 frames at 30 FPS
228229
UnsignedInt now = timeGetTime();
229230
for( key = 0; key < ARRAY_SIZE(m_keyStatus); key++ )
230231
{
@@ -246,8 +247,7 @@ Bool Keyboard::checkKeyRepeat( void )
246247
for( index = 0; index< NUM_KEYS; index++ )
247248
m_keyStatus[ index ].sequence = m_inputFrame;
248249

249-
// Set repeated key so it will repeat again after a short interval
250-
const UnsignedInt KEY_REPEAT_INTERVAL_MSEC = 67; // ~2 frames at 30 FPS
250+
// Set repeated key so it will repeat again after the interval
251251
m_keyStatus[ key ].keyDownTimeMsec = now - (Keyboard::KEY_REPEAT_DELAY_MSEC - KEY_REPEAT_INTERVAL_MSEC);
252252

253253
retVal = TRUE;

0 commit comments

Comments
 (0)