File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
GeneralsMD/Code/GameEngine/Source/GameClient/Input
Generals/Code/GameEngine/Source/GameClient/Input Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -225,9 +225,13 @@ Bool Keyboard::checkKeyRepeat( void )
225225 if ( BitIsSet ( m_keyStatus[ key ].state , KEY_STATE_DOWN ) )
226226 {
227227
228- UnsignedInt now = timeGetTime ();
228+ const UnsignedInt now = timeGetTime ();
229+ const UnsignedInt keyDownTime = m_keyStatus[ key ].keyDownTimeMsec ;
229230
230- if ( now - m_keyStatus[ key ].keyDownTimeMsec > Keyboard::KEY_REPEAT_DELAY_MSEC )
231+ // Unsigned subtraction handles wraparound correctly
232+ const UnsignedInt elapsedMsec = now - keyDownTime;
233+
234+ if ( elapsedMsec > Keyboard::KEY_REPEAT_DELAY_MSEC )
231235 {
232236 // Add key to this frame
233237 m_keys[ index ].key = (UnsignedByte)key;
Original file line number Diff line number Diff line change @@ -225,9 +225,11 @@ Bool Keyboard::checkKeyRepeat( void )
225225 if ( BitIsSet ( m_keyStatus[ key ].state , KEY_STATE_DOWN ) )
226226 {
227227
228- UnsignedInt now = timeGetTime ();
228+ const UnsignedInt now = timeGetTime ();
229+ const UnsignedInt keyDownTime = m_keyStatus[ key ].keyDownTimeMsec ;
230+ const UnsignedInt elapsedMsec = now - keyDownTime;
229231
230- if ( now - m_keyStatus[ key ]. keyDownTimeMsec > Keyboard::KEY_REPEAT_DELAY_MSEC )
232+ if ( elapsedMsec > Keyboard::KEY_REPEAT_DELAY_MSEC )
231233 {
232234 // Add key to this frame
233235 m_keys[ index ].key = (UnsignedByte)key;
You can’t perform that action at this time.
0 commit comments