diff --git a/Generals/Code/GameEngine/Include/GameClient/KeyDefs.h b/Generals/Code/GameEngine/Include/GameClient/KeyDefs.h index a6e19e19bc..3c9f14394d 100644 --- a/Generals/Code/GameEngine/Include/GameClient/KeyDefs.h +++ b/Generals/Code/GameEngine/Include/GameClient/KeyDefs.h @@ -102,7 +102,7 @@ /** The key tables */ //============================================================================= -enum KeyDefType CPP_11(: Int) +enum KeyDefType CPP_11(: UnsignedByte) { // keypad keys ---------------------------------------------------------------- KEY_KP0 = DIK_NUMPAD0, @@ -224,10 +224,15 @@ enum KeyDefType CPP_11(: Int) // specials ------------------------------------------------------------------- KEY_NONE = 0x00, ///< to report end of key stream - KEY_LOST = 0xFF ///< to report lost keyboard focus + KEY_LOST = 0xFF, ///< to report lost keyboard focus }; +enum +{ + KEY_COUNT = 256 +}; + // state for keyboard IO ------------------------------------------------------ enum { diff --git a/Generals/Code/GameEngine/Include/GameClient/Keyboard.h b/Generals/Code/GameEngine/Include/GameClient/Keyboard.h index 638df5a3a3..5e21e33e5f 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Keyboard.h +++ b/Generals/Code/GameEngine/Include/GameClient/Keyboard.h @@ -65,13 +65,15 @@ struct KeyboardIO { - enum StatusType + enum StatusType CPP_11(: UnsignedByte) { STATUS_UNUSED = 0x00, // Key has not been used STATUS_USED = 0x01 // Key has been eaten }; - UnsignedByte key; // key data + void setUsed() { status = STATUS_USED; } + + UnsignedByte key; // KeyDefType, key data UnsignedByte status; // StatusType, above UnsignedShort state; // KEY_STATE_* in KeyDefs.h UnsignedInt sequence; // sequence info from DirectX used for order @@ -91,7 +93,7 @@ class Keyboard : public SubsystemInterface Keyboard( void ); virtual ~Keyboard( void ); - // you may extend the functionanilty of these for your device + // you may extend the functionality of these for your device virtual void init( void ); /**< initialize the keyboard, only extend this functionality, do not replace */ virtual void reset( void ); ///< Reset keyboard system @@ -111,10 +113,11 @@ class Keyboard : public SubsystemInterface // access methods for key data void resetKeys( void ); ///< reset the state of the keys KeyboardIO *getFirstKey( void ); ///< get first key ready for processing - void setKeyStatusData( UnsignedByte key, + KeyboardIO *findKey( KeyDefType key, KeyboardIO::StatusType status ); ///< get key ready for processing, can return NULL + void setKeyStatusData( KeyDefType key, KeyboardIO::StatusType data ); ///< set key status - WideChar translateKey( WideChar keyCode ); ///< translte key code to printable UNICODE char - WideChar getPrintableKey( UnsignedByte key, Int state ); + WideChar translateKey( WideChar keyCode ); ///< translate key code to printable UNICODE char + WideChar getPrintableKey( KeyDefType key, Int state ); enum { MAX_KEY_STATES = 3}; protected: @@ -126,10 +129,10 @@ class Keyboard : public SubsystemInterface void initKeyNames( void ); ///< initialize the key names table void updateKeys( void ); ///< update the state of our key data Bool checkKeyRepeat( void ); ///< check for repeating keys - UnsignedByte getKeyStatusData( UnsignedByte key ); ///< get key status - Bool getKeyStateBit( UnsignedByte key, Int bit ); ///< get key state bit - UnsignedInt getKeySequenceData( UnsignedByte key ); ///< get key sequence - void setKeyStateData( UnsignedByte key, UnsignedByte data ); ///< get key state + UnsignedByte getKeyStatusData( KeyDefType key ); ///< get key status + Bool getKeyStateBit( KeyDefType key, Int bit ); ///< get key state bit + UnsignedInt getKeySequenceData( KeyDefType key ); ///< get key sequence + void setKeyStateData( KeyDefType key, UnsignedByte data ); ///< get key state UnsignedShort m_modifiers; // internal keyboard data members @@ -142,13 +145,12 @@ class Keyboard : public SubsystemInterface //Bool m_rControlState; // 1 if right control is down //Bool m_lAltState; // 1 if left alt is down //Bool m_rAltState; // 1 if right alt is down - UnsignedByte m_shift2Key; // what key is the secondary shift key + KeyDefType m_shift2Key; // what key is the secondary shift key enum { NUM_KEYS = 256 }; KeyboardIO m_keys[ NUM_KEYS ]; ///< the keys - KeyboardIO m_keyStatus[ NUM_KEYS ]; ///< the key status flags + KeyboardIO m_keyStatus[ KEY_COUNT ]; ///< the key status flags - enum { KEY_NAMES_COUNT = 256 }; struct { @@ -156,7 +158,7 @@ class Keyboard : public SubsystemInterface WideChar shifted; WideChar shifted2; - } m_keyNames[ KEY_NAMES_COUNT ]; + } m_keyNames[ KEY_COUNT ]; UnsignedInt m_inputFrame; ///< frame input was gathered on }; diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp index b1f1ec6366..12f22f49c1 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp @@ -79,6 +79,7 @@ #include "GameClient/GameWindowManager.h" #include "GameClient/Gadget.h" #include "GameClient/GameText.h" +#include "GameClient/Keyboard.h" #include "GameClient/MapUtil.h" #include "GameClient/Shell.h" #include "GameClient/KeyDefs.h" @@ -640,6 +641,18 @@ void PlayMovieAndBlock(AsciiString movieTitle) TheWritableGlobalData->m_loadScreenRender = TRUE; while (videoStream->frameIndex() < videoStream->frameCount() - 1) { + // TheSuperHackers @feature User can now skip video by pressing ESC + if (TheKeyboard) + { + TheKeyboard->UPDATE(); + KeyboardIO *io = TheKeyboard->findKey(KEY_ESC, KeyboardIO::STATUS_UNUSED); + if (io && BitIsSet(io->state, KEY_STATE_DOWN)) + { + io->setUsed(); + break; + } + } + TheGameEngine->serviceWindowsOS(); if(!videoStream->isFrameReady()) diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp index d35381fe44..9b4547a6cf 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp @@ -727,7 +727,7 @@ WindowMsgHandledType GadgetListBoxInput( GameWindow *window, UnsignedInt msg, continue; for(j = 0; j < TheKeyboard->MAX_KEY_STATES; ++j) { - if(dString->getText().getCharAt(0) == TheKeyboard->getPrintableKey(mData1, j)) + if(dString->getText().getCharAt(0) == TheKeyboard->getPrintableKey((KeyDefType)mData1, j)) { list->selectPos = position; Int prevPos = getListboxTopEntry(list); diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp index bc158c26a4..5515b6cc21 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp @@ -66,6 +66,7 @@ #include "Common/AudioAffect.h" #include "GameClient/LoadScreen.h" +#include "GameClient/Keyboard.h" #include "GameClient/Shell.h" #include "GameClient/GameWindowManager.h" #include "GameClient/GadgetProgressBar.h" @@ -490,6 +491,18 @@ void SinglePlayerLoadScreen::init( GameInfo *game ) Int shiftedPercent = -FRAME_FUDGE_ADD + 1; while (m_videoStream->frameIndex() < m_videoStream->frameCount() - 1 ) { + // TheSuperHackers @feature User can now skip video by pressing ESC + if (TheKeyboard) + { + TheKeyboard->UPDATE(); + KeyboardIO *io = TheKeyboard->findKey(KEY_ESC, KeyboardIO::STATUS_UNUSED); + if (io && BitIsSet(io->state, KEY_STATE_DOWN)) + { + io->setUsed(); + break; + } + } + TheGameEngine->serviceWindowsOS(); if(!m_videoStream->isFrameReady()) diff --git a/Generals/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp b/Generals/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp index 081242411a..3705c791c2 100644 --- a/Generals/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp @@ -50,7 +50,7 @@ Keyboard *TheKeyboard = NULL; void Keyboard::createStreamMessages( void ) { - // santiy + // sanity if( TheMessageStream == NULL ) return; @@ -89,6 +89,7 @@ void Keyboard::createStreamMessages( void ) } // next key please + key->setUsed(); key++; } @@ -213,7 +214,7 @@ Bool Keyboard::checkKeyRepeat( void ) // Scan Keyboard status array for first key down // long enough to repeat - for( key = 0; key < 256; key++ ) + for( key = 0; key < ARRAY_SIZE(m_keyStatus); key++ ) { if( BitIsSet( m_keyStatus[ key ].state, KEY_STATE_DOWN ) ) @@ -261,7 +262,7 @@ void Keyboard::initKeyNames( void ) /* * Initialize the keyboard key-names array. */ - for( i = 0; i < KEY_NAMES_COUNT; i++ ) + for( i = 0; i < ARRAY_SIZE(m_keyNames); i++ ) { m_keyNames[ i ].stdKey = L'\0'; @@ -765,10 +766,24 @@ KeyboardIO *Keyboard::getFirstKey( void ) return &m_keys[ 0 ]; } +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +KeyboardIO *Keyboard::findKey( KeyDefType key, KeyboardIO::StatusType status ) +{ + for (KeyboardIO *io = getFirstKey(); io->key != KEY_NONE; ++io) + { + if (io->key == key && io->status == status) + { + return io; + } + } + return NULL; +} + //------------------------------------------------------------------------------------------------- /** return the key status for the specified key */ //------------------------------------------------------------------------------------------------- -UnsignedByte Keyboard::getKeyStatusData( UnsignedByte key ) +UnsignedByte Keyboard::getKeyStatusData( KeyDefType key ) { return m_keyStatus[ key ].status; } @@ -776,7 +791,7 @@ UnsignedByte Keyboard::getKeyStatusData( UnsignedByte key ) //------------------------------------------------------------------------------------------------- /** Get the key state data as a Bool for the specified key */ //------------------------------------------------------------------------------------------------- -Bool Keyboard::getKeyStateBit( UnsignedByte key, Int bit ) +Bool Keyboard::getKeyStateBit( KeyDefType key, Int bit ) { return (m_keyStatus[ key ].state & bit) ? 1 : 0; } @@ -784,7 +799,7 @@ Bool Keyboard::getKeyStateBit( UnsignedByte key, Int bit ) //------------------------------------------------------------------------------------------------- /** return the sequence data for the given key */ //------------------------------------------------------------------------------------------------- -UnsignedInt Keyboard::getKeySequenceData( UnsignedByte key ) +UnsignedInt Keyboard::getKeySequenceData( KeyDefType key ) { return m_keyStatus[ key ].sequence; } @@ -792,7 +807,7 @@ UnsignedInt Keyboard::getKeySequenceData( UnsignedByte key ) //------------------------------------------------------------------------------------------------- /** set the key status data */ //------------------------------------------------------------------------------------------------- -void Keyboard::setKeyStatusData( UnsignedByte key, KeyboardIO::StatusType data ) +void Keyboard::setKeyStatusData( KeyDefType key, KeyboardIO::StatusType data ) { m_keyStatus[ key ].status = data; } @@ -800,7 +815,7 @@ void Keyboard::setKeyStatusData( UnsignedByte key, KeyboardIO::StatusType data ) //------------------------------------------------------------------------------------------------- /** set the key state data */ //------------------------------------------------------------------------------------------------- -void Keyboard::setKeyStateData( UnsignedByte key, UnsignedByte data ) +void Keyboard::setKeyStateData( KeyDefType key, UnsignedByte data ) { m_keyStatus[ key ].state = data; } @@ -973,9 +988,9 @@ Bool Keyboard::isAlt() } -WideChar Keyboard::getPrintableKey( UnsignedByte key, Int state ) +WideChar Keyboard::getPrintableKey( KeyDefType key, Int state ) { - if((key < 0 || key >=KEY_NAMES_COUNT) || ( state < 0 || state >= MAX_KEY_STATES)) + if((key < 0 || key >= ARRAY_SIZE(m_keyNames)) || ( state < 0 || state >= MAX_KEY_STATES)) return L'\0'; if(state == 0) return m_keyNames[key].stdKey; @@ -983,6 +998,4 @@ WideChar Keyboard::getPrintableKey( UnsignedByte key, Int state ) return m_keyNames[key].shifted; else return m_keyNames[key].shifted2; - - } diff --git a/Generals/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp b/Generals/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp index 355c037b5a..637450e48f 100644 --- a/Generals/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp @@ -98,7 +98,7 @@ GameMessageDisposition HotKeyTranslator::translateGameMessage(const GameMessage } if(newModState != 0) return disp; - WideChar key = TheKeyboard->getPrintableKey(msg->getArgument(0)->integer, 0); + WideChar key = TheKeyboard->getPrintableKey((KeyDefType)msg->getArgument(0)->integer, 0); UnicodeString uKey; uKey.concat(key); AsciiString aKey; diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/KeyDefs.h b/GeneralsMD/Code/GameEngine/Include/GameClient/KeyDefs.h index 8d61ed62d3..9f1978d20e 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/KeyDefs.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/KeyDefs.h @@ -102,7 +102,7 @@ /** The key tables */ //============================================================================= -enum KeyDefType CPP_11(: Int) +enum KeyDefType CPP_11(: UnsignedByte) { // keypad keys ---------------------------------------------------------------- KEY_KP0 = DIK_NUMPAD0, @@ -224,10 +224,15 @@ enum KeyDefType CPP_11(: Int) // specials ------------------------------------------------------------------- KEY_NONE = 0x00, ///< to report end of key stream - KEY_LOST = 0xFF ///< to report lost keyboard focus + KEY_LOST = 0xFF, ///< to report lost keyboard focus }; +enum +{ + KEY_COUNT = 256 +}; + // state for keyboard IO ------------------------------------------------------ enum { diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Keyboard.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Keyboard.h index 770a7338fd..99a4cd54ce 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/Keyboard.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Keyboard.h @@ -65,13 +65,15 @@ struct KeyboardIO { - enum StatusType + enum StatusType CPP_11(: UnsignedByte) { STATUS_UNUSED = 0x00, // Key has not been used STATUS_USED = 0x01 // Key has been eaten }; - UnsignedByte key; // key data + void setUsed() { status = STATUS_USED; } + + UnsignedByte key; // KeyDefType, key data UnsignedByte status; // StatusType, above UnsignedShort state; // KEY_STATE_* in KeyDefs.h UnsignedInt sequence; // sequence info from DirectX used for order @@ -91,7 +93,7 @@ class Keyboard : public SubsystemInterface Keyboard( void ); virtual ~Keyboard( void ); - // you may extend the functionanilty of these for your device + // you may extend the functionality of these for your device virtual void init( void ); /**< initialize the keyboard, only extend this functionality, do not replace */ virtual void reset( void ); ///< Reset keyboard system @@ -111,10 +113,11 @@ class Keyboard : public SubsystemInterface // access methods for key data void resetKeys( void ); ///< reset the state of the keys KeyboardIO *getFirstKey( void ); ///< get first key ready for processing - void setKeyStatusData( UnsignedByte key, + KeyboardIO *findKey( KeyDefType key, KeyboardIO::StatusType status ); ///< get key ready for processing, can return NULL + void setKeyStatusData( KeyDefType key, KeyboardIO::StatusType data ); ///< set key status - WideChar translateKey( WideChar keyCode ); ///< translte key code to printable UNICODE char - WideChar getPrintableKey( UnsignedByte key, Int state ); + WideChar translateKey( WideChar keyCode ); ///< translate key code to printable UNICODE char + WideChar getPrintableKey( KeyDefType key, Int state ); enum { MAX_KEY_STATES = 3}; protected: @@ -126,10 +129,10 @@ class Keyboard : public SubsystemInterface void initKeyNames( void ); ///< initialize the key names table void updateKeys( void ); ///< update the state of our key data Bool checkKeyRepeat( void ); ///< check for repeating keys - UnsignedByte getKeyStatusData( UnsignedByte key ); ///< get key status - Bool getKeyStateBit( UnsignedByte key, Int bit ); ///< get key state bit - UnsignedInt getKeySequenceData( UnsignedByte key ); ///< get key sequence - void setKeyStateData( UnsignedByte key, UnsignedByte data ); ///< get key state + UnsignedByte getKeyStatusData( KeyDefType key ); ///< get key status + Bool getKeyStateBit( KeyDefType key, Int bit ); ///< get key state bit + UnsignedInt getKeySequenceData( KeyDefType key ); ///< get key sequence + void setKeyStateData( KeyDefType key, UnsignedByte data ); ///< get key state UnsignedShort m_modifiers; // internal keyboard data members @@ -142,13 +145,12 @@ class Keyboard : public SubsystemInterface //Bool m_rControlState; // 1 if right control is down //Bool m_lAltState; // 1 if left alt is down //Bool m_rAltState; // 1 if right alt is down - UnsignedByte m_shift2Key; // what key is the secondary shift key + KeyDefType m_shift2Key; // what key is the secondary shift key enum { NUM_KEYS = 256 }; KeyboardIO m_keys[ NUM_KEYS ]; ///< the keys - KeyboardIO m_keyStatus[ NUM_KEYS ]; ///< the key status flags + KeyboardIO m_keyStatus[ KEY_COUNT ]; ///< the key status flags - enum { KEY_NAMES_COUNT = 256 }; struct { @@ -156,7 +158,7 @@ class Keyboard : public SubsystemInterface WideChar shifted; WideChar shifted2; - } m_keyNames[ KEY_NAMES_COUNT ]; + } m_keyNames[ KEY_COUNT ]; UnsignedInt m_inputFrame; ///< frame input was gathered on }; diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp index f57594d24e..d1edfbd099 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp @@ -82,6 +82,7 @@ #include "GameClient/GameWindowManager.h" #include "GameClient/Gadget.h" #include "GameClient/GameText.h" +#include "GameClient/Keyboard.h" #include "GameClient/MapUtil.h" #include "GameClient/Shell.h" #include "GameClient/KeyDefs.h" @@ -734,6 +735,18 @@ void PlayMovieAndBlock(AsciiString movieTitle) TheWritableGlobalData->m_loadScreenRender = TRUE; while (videoStream->frameIndex() < videoStream->frameCount() - 1) { + // TheSuperHackers @feature User can now skip video by pressing ESC + if (TheKeyboard) + { + TheKeyboard->UPDATE(); + KeyboardIO *io = TheKeyboard->findKey(KEY_ESC, KeyboardIO::STATUS_UNUSED); + if (io && BitIsSet(io->state, KEY_STATE_DOWN)) + { + io->setUsed(); + break; + } + } + TheGameEngine->serviceWindowsOS(); if(!videoStream->isFrameReady()) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp index 147c7368ba..783f360723 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp @@ -727,7 +727,7 @@ WindowMsgHandledType GadgetListBoxInput( GameWindow *window, UnsignedInt msg, continue; for(j = 0; j < TheKeyboard->MAX_KEY_STATES; ++j) { - if(dString->getText().getCharAt(0) == TheKeyboard->getPrintableKey(mData1, j)) + if(dString->getText().getCharAt(0) == TheKeyboard->getPrintableKey((KeyDefType)mData1, j)) { list->selectPos = position; Int prevPos = getListboxTopEntry(list); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp index 5c8bc3430b..19cb7a2aea 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp @@ -71,6 +71,7 @@ #include "GameClient/GameText.h" #include "GameClient/GameWindowManager.h" #include "GameClient/GameWindowTransitions.h" +#include "GameClient/Keyboard.h" #include "GameClient/LoadScreen.h" #include "GameClient/MapUtil.h" #include "GameClient/Mouse.h" @@ -533,6 +534,18 @@ void SinglePlayerLoadScreen::init( GameInfo *game ) Int shiftedPercent = -FRAME_FUDGE_ADD + 1; while (m_videoStream->frameIndex() < m_videoStream->frameCount() - 1 ) { + // TheSuperHackers @feature User can now skip video by pressing ESC + if (TheKeyboard) + { + TheKeyboard->UPDATE(); + KeyboardIO *io = TheKeyboard->findKey(KEY_ESC, KeyboardIO::STATUS_UNUSED); + if (io && BitIsSet(io->state, KEY_STATE_DOWN)) + { + io->setUsed(); + break; + } + } + TheGameEngine->serviceWindowsOS(); if(!m_videoStream->isFrameReady()) @@ -1047,6 +1060,18 @@ void ChallengeLoadScreen::init( GameInfo *game ) Int shiftedPercent = -FRAME_FUDGE_ADD + 1; while (m_videoStream->frameIndex() < m_videoStream->frameCount() - 1 ) { + // TheSuperHackers @feature User can now skip video by pressing ESC + if (TheKeyboard) + { + TheKeyboard->UPDATE(); + KeyboardIO *io = TheKeyboard->findKey(KEY_ESC, KeyboardIO::STATUS_UNUSED); + if (io && BitIsSet(io->state, KEY_STATE_DOWN)) + { + io->setUsed(); + break; + } + } + TheGameEngine->serviceWindowsOS(); if(!m_videoStream->isFrameReady()) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp index a2e67445d1..5a642bdff8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp @@ -50,7 +50,7 @@ Keyboard *TheKeyboard = NULL; void Keyboard::createStreamMessages( void ) { - // santiy + // sanity if( TheMessageStream == NULL ) return; @@ -89,6 +89,7 @@ void Keyboard::createStreamMessages( void ) } // next key please + key->setUsed(); key++; } @@ -213,7 +214,7 @@ Bool Keyboard::checkKeyRepeat( void ) // Scan Keyboard status array for first key down // long enough to repeat - for( key = 0; key < 256; key++ ) + for( key = 0; key < ARRAY_SIZE(m_keyStatus); key++ ) { if( BitIsSet( m_keyStatus[ key ].state, KEY_STATE_DOWN ) ) @@ -261,7 +262,7 @@ void Keyboard::initKeyNames( void ) /* * Initialize the keyboard key-names array. */ - for( i = 0; i < KEY_NAMES_COUNT; i++ ) + for( i = 0; i < ARRAY_SIZE(m_keyNames); i++ ) { m_keyNames[ i ].stdKey = L'\0'; @@ -765,10 +766,24 @@ KeyboardIO *Keyboard::getFirstKey( void ) return &m_keys[ 0 ]; } +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +KeyboardIO *Keyboard::findKey( KeyDefType key, KeyboardIO::StatusType status ) +{ + for (KeyboardIO *io = getFirstKey(); io->key != KEY_NONE; ++io) + { + if (io->key == key && io->status == status) + { + return io; + } + } + return NULL; +} + //------------------------------------------------------------------------------------------------- /** return the key status for the specified key */ //------------------------------------------------------------------------------------------------- -UnsignedByte Keyboard::getKeyStatusData( UnsignedByte key ) +UnsignedByte Keyboard::getKeyStatusData( KeyDefType key ) { return m_keyStatus[ key ].status; } @@ -776,7 +791,7 @@ UnsignedByte Keyboard::getKeyStatusData( UnsignedByte key ) //------------------------------------------------------------------------------------------------- /** Get the key state data as a Bool for the specified key */ //------------------------------------------------------------------------------------------------- -Bool Keyboard::getKeyStateBit( UnsignedByte key, Int bit ) +Bool Keyboard::getKeyStateBit( KeyDefType key, Int bit ) { return (m_keyStatus[ key ].state & bit) ? 1 : 0; } @@ -784,7 +799,7 @@ Bool Keyboard::getKeyStateBit( UnsignedByte key, Int bit ) //------------------------------------------------------------------------------------------------- /** return the sequence data for the given key */ //------------------------------------------------------------------------------------------------- -UnsignedInt Keyboard::getKeySequenceData( UnsignedByte key ) +UnsignedInt Keyboard::getKeySequenceData( KeyDefType key ) { return m_keyStatus[ key ].sequence; } @@ -792,7 +807,7 @@ UnsignedInt Keyboard::getKeySequenceData( UnsignedByte key ) //------------------------------------------------------------------------------------------------- /** set the key status data */ //------------------------------------------------------------------------------------------------- -void Keyboard::setKeyStatusData( UnsignedByte key, KeyboardIO::StatusType data ) +void Keyboard::setKeyStatusData( KeyDefType key, KeyboardIO::StatusType data ) { m_keyStatus[ key ].status = data; } @@ -800,7 +815,7 @@ void Keyboard::setKeyStatusData( UnsignedByte key, KeyboardIO::StatusType data ) //------------------------------------------------------------------------------------------------- /** set the key state data */ //------------------------------------------------------------------------------------------------- -void Keyboard::setKeyStateData( UnsignedByte key, UnsignedByte data ) +void Keyboard::setKeyStateData( KeyDefType key, UnsignedByte data ) { m_keyStatus[ key ].state = data; } @@ -973,9 +988,9 @@ Bool Keyboard::isAlt() } -WideChar Keyboard::getPrintableKey( UnsignedByte key, Int state ) +WideChar Keyboard::getPrintableKey( KeyDefType key, Int state ) { - if((key < 0 || key >=KEY_NAMES_COUNT) || ( state < 0 || state >= MAX_KEY_STATES)) + if((key < 0 || key >= ARRAY_SIZE(m_keyNames)) || ( state < 0 || state >= MAX_KEY_STATES)) return L'\0'; if(state == 0) return m_keyNames[key].stdKey; @@ -983,6 +998,4 @@ WideChar Keyboard::getPrintableKey( UnsignedByte key, Int state ) return m_keyNames[key].shifted; else return m_keyNames[key].shifted2; - - } diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp index e71399c7e8..9e8ffd3a1c 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp @@ -98,7 +98,7 @@ GameMessageDisposition HotKeyTranslator::translateGameMessage(const GameMessage } if(newModState != 0) return disp; - WideChar key = TheKeyboard->getPrintableKey(msg->getArgument(0)->integer, 0); + WideChar key = TheKeyboard->getPrintableKey((KeyDefType)msg->getArgument(0)->integer, 0); UnicodeString uKey; uKey.concat(key); AsciiString aKey;