diff --git a/code/REDALERT/CONQUER.CPP b/code/REDALERT/CONQUER.CPP index ff2a75a..4787c38 100644 --- a/code/REDALERT/CONQUER.CPP +++ b/code/REDALERT/CONQUER.CPP @@ -1638,7 +1638,7 @@ void Color_Cycle(void) *=============================================================================================*/ void Call_Back(void) { - WWSDL_ProcessEvents(g_globalKeyNumType, g_globalKeyFlags); + Device_Present(); /* ** Music and speech maintenance diff --git a/code/REDALERT/EGOS.CPP b/code/REDALERT/EGOS.CPP index f38f46e..7b42bcc 100644 --- a/code/REDALERT/EGOS.CPP +++ b/code/REDALERT/EGOS.CPP @@ -859,9 +859,9 @@ void Show_Who_Was_Responsible (void) ** If user hits escape then break. */ - KeyNumType _key = KN_NONE; - int _flags; - WWSDL_ProcessEvents(_key, _flags); + g_globalKeyNumType = KN_NONE; + g_globalKeyFlags = 0; + UserInput.Process_Input(); key = Keyboard->Check(); diff --git a/code/REDALERT/GADGET.CPP b/code/REDALERT/GADGET.CPP index 185d008..adfaabd 100644 --- a/code/REDALERT/GADGET.CPP +++ b/code/REDALERT/GADGET.CPP @@ -501,6 +501,8 @@ KeyNumType GadgetClass::Input(void) */ // jmarshall int flags = g_globalKeyFlags; + UserInput.Process_Input( g_globalKeyNumType, flags ); + // jmarshall end /* diff --git a/code/REDALERT/MAPEDDLG.CPP b/code/REDALERT/MAPEDDLG.CPP index 7d80932..41c0b0f 100644 --- a/code/REDALERT/MAPEDDLG.CPP +++ b/code/REDALERT/MAPEDDLG.CPP @@ -652,9 +652,9 @@ int MapEditClass::Pick_Scenario(char const * caption, int & scen_nump, ScenarioP */ bool display = true; while (pickscenerio_process) { - KeyNumType _key; - int _flags; - WWSDL_ProcessEvents(_key, _flags); + g_globalKeyNumType = KN_NONE; + g_globalKeyFlags = 0; + UserInput.Process_Input(); } Imgui_Dialog_Function = nullptr; @@ -1117,9 +1117,10 @@ int MapEditClass::Size_Map(int x, int y, int w, int h) // } // // Show_Mouse(); - KeyNumType _key; - int _types; - WWSDL_ProcessEvents(_key, _types); + + g_globalKeyNumType = KN_NONE; + g_globalKeyFlags = 0; + UserInput.Process_Input(); // display = REDRAW_NONE; @@ -1957,9 +1958,9 @@ int MapEditClass::Scenario_Dialog(void) */ KeyNumType input = KN_NONE; //commands->Input(); - KeyNumType _key; - int _flags; - WWSDL_ProcessEvents(_key, _flags); + g_globalKeyNumType = KN_NONE; + g_globalKeyFlags = 0; + UserInput.Process_Input(); /* ** Process input @@ -2549,9 +2550,9 @@ int MapEditClass::Select_Trigger(void) //// LogicPage->Unlock(); // } - KeyNumType _key; - int _flags; - WWSDL_ProcessEvents(_key, _flags); + g_globalKeyNumType = KN_NONE; + g_globalKeyFlags = 0; + UserInput.Process_Input(); /* ** Get user input diff --git a/code/REDALERT/MAPEDIT.CPP b/code/REDALERT/MAPEDIT.CPP index ff3c30c..06cc48c 100644 --- a/code/REDALERT/MAPEDIT.CPP +++ b/code/REDALERT/MAPEDIT.CPP @@ -1584,11 +1584,16 @@ void MapEditClass::Main_Menu(void) */ Hide_Mouse(); // Do_Menu assumes the mouse is already hidden selection = mainmenu_selection; - KeyNumType _key; - int _flags; - WWSDL_ProcessEvents(_key, _flags); + + g_globalKeyNumType = KN_NONE; + g_globalKeyFlags = 0; + UserInput.Process_Input(); + + Call_Back(); + Show_Mouse(); - if (UnknownKey==KN_ESC || _key == KN_RMOUSE) { + + if (UnknownKey==KN_ESC || g_globalKeyNumType == KN_RMOUSE) { break; } @@ -1702,7 +1707,9 @@ void MapEditClass::Main_Menu(void) case 7: if (Changed) { Imgui_Dialog_Function = nullptr; - WWSDL_ProcessEvents(_key, _flags); + + UserInput.Process_Input(); + rc = WWMessageBox().Process("Save Changes?", TXT_YES, TXT_NO, TXT_CANCEL); HidPage.Clear(); Flag_To_Redraw(true); @@ -1779,12 +1786,16 @@ void MapEditClass::AI_Menu(void) */ Call_Back(); + UserInput.Process_Input(); + /* ** Invoke menu */ Hide_Mouse(); // Do_Menu assumes the mouse is already hidden + selection = Do_Menu(&_menus[0], true); Show_Mouse(); + if (UnknownKey==KN_ESC || UnknownKey==KN_LMOUSE || UnknownKey==KN_RMOUSE) { break; } diff --git a/code/REDALERT/MAPSEL.CPP b/code/REDALERT/MAPSEL.CPP index 9d1989a..023382b 100644 --- a/code/REDALERT/MAPSEL.CPP +++ b/code/REDALERT/MAPSEL.CPP @@ -228,9 +228,12 @@ char const * Map_Selection(void) bool done = 0; MouseType shape = MOUSE_NORMAL; while (!done) { - KeyNumType _key; - int _flags = 0; - WWSDL_ProcessEvents(_key, _flags); + g_globalKeyNumType = KN_NONE; + g_globalKeyFlags = 0; + + UserInput.Process_Input(); + + Call_Back(); #ifdef WIN32 /* @@ -259,24 +262,23 @@ char const * Map_Selection(void) timer = delay; Set_Mouse_Cursor(xspot, yspot, start + frame); } - if (_flags == KN_LMOUSE) { - { - choice = 0; - if (choice != -1) { - done = 1; - selection = choice; + if (g_globalKeyFlags == KN_LMOUSE) + { + choice = 0; + if (choice != -1) { + done = 1; + selection = choice; #ifdef WIN32 - Play_Sample(country1, 255, Options.Normalize_Volume(170)); + Play_Sample(country1, 255, Options.Normalize_Volume(170)); #else - Play_Sample(country1, 255, Options.Normalize_Volume(50)); + Play_Sample(country1, 255, Options.Normalize_Volume(50)); #endif - } else { + } else { #ifdef WIN32 - Play_Sample(scold1, 255, Options.Normalize_Volume(170)); + Play_Sample(scold1, 255, Options.Normalize_Volume(170)); #else - Play_Sample(scold1, 255, Options.Normalize_Volume(50)); + Play_Sample(scold1, 255, Options.Normalize_Volume(50)); #endif - } } } } diff --git a/code/REDALERT/MENUS.CPP b/code/REDALERT/MENUS.CPP index 7c4603c..fd8ffda 100644 --- a/code/REDALERT/MENUS.CPP +++ b/code/REDALERT/MENUS.CPP @@ -443,13 +443,14 @@ int Do_Menu(char const ** strings, bool ) UnknownKey = 0; while (selection == -1) { // jmarshall - KeyNumType _key = KN_NONE; - int _flags; - WWSDL_ProcessEvents(_key, _flags); - Show_Mouse(true); -// jmarshall end + g_globalKeyNumType = KN_NONE; + g_globalKeyFlags = 0; + Call_Back(); - selection = Check_Menu(0, strings, NULL, 0xFFL, 0, _key); + + Show_Mouse(true); + + selection = Check_Menu(0, strings, NULL, 0xFFL, 0, (KeyNumType)g_globalKeyFlags); if (UnknownKey != 0 || UnknownKey == KN_ESC || UnknownKey==KN_LMOUSE || UnknownKey==KN_RMOUSE) break; } Keyboard->Clear(); diff --git a/code/REDALERT/SCORE.CPP b/code/REDALERT/SCORE.CPP index fae61e3..ea2a50c 100644 --- a/code/REDALERT/SCORE.CPP +++ b/code/REDALERT/SCORE.CPP @@ -1427,9 +1427,9 @@ void ScoreClass::Input_Name(char str[], int xpos, int ypos, char const pal[]) // jmarshall - temp disable high school writing. // do { //// jmarshall -// KeyNumType _key; -// int flags; -// WWSDL_ProcessEvents(_key, flags); +// g_globalKeyNumType = KN_NONE; +// g_globalKeyFlags = 0; +// UserInput.Process_Input(); //// jmarshall end // Call_Back(); // Animate_Score_Objs(); diff --git a/code/REDALERT/STARTUP.CPP b/code/REDALERT/STARTUP.CPP index f5febf1..4349196 100644 --- a/code/REDALERT/STARTUP.CPP +++ b/code/REDALERT/STARTUP.CPP @@ -684,9 +684,10 @@ int PASCAL WinMain ( HINSTANCE instance , HINSTANCE , char * command_line , int { Keyboard->Check(); - KeyNumType _key = KN_NONE; - int _flags; - WWSDL_ProcessEvents(_key, _flags); + g_globalKeyNumType = KN_NONE; + g_globalKeyFlags = 0; + + UserInput.Process_Input(); } while (ReadyToQuit == 1); return (EXIT_SUCCESS); @@ -866,10 +867,10 @@ void Emergency_Exit ( int code ) { Keyboard->Check(); - KeyNumType _key = KN_NONE; - int _flags; - WWSDL_ProcessEvents(_key, _flags); - }while (ReadyToQuit == 3); + g_globalKeyNumType = KN_NONE; + g_globalKeyFlags = 0; + UserInput.Process_Input(); + } while (ReadyToQuit == 3); #else //WIN32 diff --git a/code/REDALERT/WINSTUB.CPP b/code/REDALERT/WINSTUB.CPP index 0b988dd..770911b 100644 --- a/code/REDALERT/WINSTUB.CPP +++ b/code/REDALERT/WINSTUB.CPP @@ -886,7 +886,7 @@ void __cdecl SetPalette(unsigned char *palette, long, unsigned long) void WWSDL_ProcessEvents(KeyNumType& key, int& flags, bool presentBuffer) { - UserInput.Process_Input(key, flags, presentBuffer); + //UserInput.Process_Input(key, flags); } #ifndef NDEBUG diff --git a/code/REDALERT/io/UserInput.cpp b/code/REDALERT/io/UserInput.cpp index 6fc66d8..7c602f3 100644 --- a/code/REDALERT/io/UserInput.cpp +++ b/code/REDALERT/io/UserInput.cpp @@ -3,7 +3,7 @@ extern KeyboardClass * Keyboard; -void UserInputClass::Process_Input(KeyNumType& key, int& flags, bool presentBuffer) +void UserInputClass::Process_Input(KeyNumType& key, int& flags) { bool leftMouseProcessed = false; SDL_GetMouseState(&Mouse.X, &Mouse.Y); @@ -50,17 +50,23 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags, bool presentBuff if (event.button.button == SDL_BUTTON_LEFT) { Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_DOWN; + key = KN_LMOUSE; flags = GadgetClass::LEFTPRESS; + + Keyboard->Put_Element(KN_LMOUSE); + leftMouseProcessed = true; numFramesLMouse++; - key = KN_LMOUSE; } else if (event.button.button == SDL_BUTTON_RIGHT) { Mouse.Button_Right == MouseButtonState::MOUSE_BUTTON_DOWN; - numFramesLMouse = 0; - flags = GadgetClass::RIGHTPRESS; + Keyboard->Put_Element(KN_RMOUSE); + key = KN_RMOUSE; + flags = GadgetClass::RIGHTPRESS; + + numFramesLMouse = 0; } break; @@ -138,9 +144,4 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags, bool presentBuff Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_HOLD; flags = GadgetClass::LEFTHELD; } - - if (presentBuffer) - { - Device_Present(); - } } \ No newline at end of file diff --git a/code/REDALERT/io/UserInput.h b/code/REDALERT/io/UserInput.h index 7f405e2..2ef72f3 100644 --- a/code/REDALERT/io/UserInput.h +++ b/code/REDALERT/io/UserInput.h @@ -7,6 +7,9 @@ #include "examples/imgui_impl_sdl.h" +extern KeyNumType g_globalKeyNumType; +extern int g_globalKeyFlags; + // Mapping of SDL KeyCode values to internal KeyNumType std::map const sdl_keyMapping = { { SDLK_a, KN_A }, @@ -101,7 +104,7 @@ class UserInputClass INPUT_ACTION_MOUSE, } InputAction; - void UserInputClass::Process_Input(KeyNumType& key, int& flags, bool presentBuffer = true); + void UserInputClass::Process_Input(KeyNumType& key = g_globalKeyNumType, int& flags = g_globalKeyFlags); InputAction LastAction;