File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
GeneralsMD/Code/GameEngine/Source/GameClient/Input
Generals/Code/GameEngine/Source/GameClient/Input Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -220,13 +220,14 @@ Bool Keyboard::checkKeyRepeat( void )
220220 // Scan Keyboard status array for first key down
221221 // long enough to repeat
222222 const UnsignedInt KEY_REPEAT_INTERVAL_MSEC = 67 ; // ~2 frames at 30 FPS
223+ UnsignedInt now = timeGetTime ();
223224 for ( key = 0 ; key < ARRAY_SIZE (m_keyStatus); key++ )
224225 {
225226
226227 if ( BitIsSet ( m_keyStatus[ key ].state , KEY_STATE_DOWN ) )
227228 {
228229
229- if ( timeGetTime () - m_keyStatus[ key ].keyDownTimeMsec > Keyboard::KEY_REPEAT_DELAY_MSEC )
230+ if ( now - m_keyStatus[ key ].keyDownTimeMsec > Keyboard::KEY_REPEAT_DELAY_MSEC )
230231 {
231232 // Add key to this frame
232233 m_keys[ index ].key = (UnsignedByte)key;
@@ -236,8 +237,12 @@ Bool Keyboard::checkKeyRepeat( void )
236237 // Set End Flag
237238 m_keys[ ++index ].key = KEY_NONE;
238239
240+ // Set all keys as new to prevent multiple keys repeating
241+ for ( index = 0 ; index< NUM_KEYS; index++ )
242+ m_keyStatus[ index ].keyDownTimeMsec = now;
243+
239244 // Set repeated key so it will repeat again after the interval
240- m_keyStatus[ key ].keyDownTimeMsec = timeGetTime () - (Keyboard::KEY_REPEAT_DELAY_MSEC + KEY_REPEAT_INTERVAL_MSEC);
245+ m_keyStatus[ key ].keyDownTimeMsec = now - (Keyboard::KEY_REPEAT_DELAY_MSEC + KEY_REPEAT_INTERVAL_MSEC);
241246
242247 retVal = TRUE ;
243248 break ; // exit for key
Original file line number Diff line number Diff line change @@ -220,13 +220,14 @@ Bool Keyboard::checkKeyRepeat( void )
220220 // Scan Keyboard status array for first key down
221221 // long enough to repeat
222222 const UnsignedInt KEY_REPEAT_INTERVAL_MSEC = 67 ; // ~2 frames at 30 FPS
223+ UnsignedInt now = timeGetTime ();
223224 for ( key = 0 ; key < ARRAY_SIZE (m_keyStatus); key++ )
224225 {
225226
226227 if ( BitIsSet ( m_keyStatus[ key ].state , KEY_STATE_DOWN ) )
227228 {
228229
229- if ( timeGetTime () - m_keyStatus[ key ].keyDownTimeMsec > Keyboard::KEY_REPEAT_DELAY_MSEC )
230+ if ( now - m_keyStatus[ key ].keyDownTimeMsec > Keyboard::KEY_REPEAT_DELAY_MSEC )
230231 {
231232 // Add key to this frame
232233 m_keys[ index ].key = (UnsignedByte)key;
@@ -236,8 +237,12 @@ Bool Keyboard::checkKeyRepeat( void )
236237 // Set End Flag
237238 m_keys[ ++index ].key = KEY_NONE;
238239
240+ // Set all keys as new to prevent multiple keys repeating
241+ for ( index = 0 ; index< NUM_KEYS; index++ )
242+ m_keyStatus[ index ].keyDownTimeMsec = now;
243+
239244 // Set repeated key so it will repeat again after the interval
240- m_keyStatus[ key ].keyDownTimeMsec = timeGetTime () - (Keyboard::KEY_REPEAT_DELAY_MSEC + KEY_REPEAT_INTERVAL_MSEC);
245+ m_keyStatus[ key ].keyDownTimeMsec = now - (Keyboard::KEY_REPEAT_DELAY_MSEC + KEY_REPEAT_INTERVAL_MSEC);
241246
242247 retVal = TRUE ;
243248 break ; // exit for key
You can’t perform that action at this time.
0 commit comments