From 012a5c2d60b9223535b218e2ba4b01e6cd1d7ddb Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Thu, 25 Jun 2020 17:24:06 -0700 Subject: [PATCH] WWKeyboardClass::Down now goes through the SDL system for mouse up and down, needs work for other keys. --- code/redalert/gadget.cpp | 5 ++--- code/redalert/io/userinput.cpp | 5 +++-- code/redalert/key.cpp | 8 ++++++++ code/redalert/mapedit.cpp | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/code/redalert/gadget.cpp b/code/redalert/gadget.cpp index adfaabd..71c1d32 100644 --- a/code/redalert/gadget.cpp +++ b/code/redalert/gadget.cpp @@ -499,10 +499,9 @@ KeyNumType GadgetClass::Input(void) ** know the position of the mouse at the exact instant when the click occurred ** rather the the mouse position at the time we get around to this function. */ -// jmarshall +// jmarshall + UserInput.Process_Input( g_globalKeyNumType, g_globalKeyFlags); int flags = g_globalKeyFlags; - UserInput.Process_Input( g_globalKeyNumType, flags ); - // jmarshall end /* diff --git a/code/redalert/io/userinput.cpp b/code/redalert/io/userinput.cpp index 6d661bb..aadd59c 100644 --- a/code/redalert/io/userinput.cpp +++ b/code/redalert/io/userinput.cpp @@ -65,7 +65,7 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags) Keyboard->Put_Element(KN_RMOUSE); - key = KN_RMOUSE; + key = KN_RMOUSE; flags |= GadgetClass::RIGHTPRESS; numFramesLMouse = 0; @@ -75,13 +75,14 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags) case SDL_MOUSEBUTTONUP: if (event.button.button == SDL_BUTTON_LEFT) { Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_RELEASE; - + flags &= GadgetClass::LEFTPRESS; flags |= GadgetClass::LEFTRELEASE; numFramesLMouse = 0; } else if (event.button.button == SDL_BUTTON_RIGHT) { Mouse.Button_Right == MouseButtonState::MOUSE_BUTTON_RELEASE; + flags &= GadgetClass::RIGHTPRESS; flags |= GadgetClass::RIGHTRELEASE; numFramesLMouse = 0; } diff --git a/code/redalert/key.cpp b/code/redalert/key.cpp index 5424cc2..90626c7 100644 --- a/code/redalert/key.cpp +++ b/code/redalert/key.cpp @@ -364,6 +364,14 @@ char WWKeyboardClass::To_ASCII(unsigned short key) *=============================================================================================*/ bool WWKeyboardClass::Down(unsigned short key) { + if (key == KN_LMOUSE) { + return g_globalKeyFlags & GadgetClass::LEFTPRESS; + } + + if (key == KN_RMOUSE) { + return g_globalKeyFlags & GadgetClass::RIGHTPRESS; + } + return(GetAsyncKeyState(key & 0xFF) == 0 ? false : true); } diff --git a/code/redalert/mapedit.cpp b/code/redalert/mapedit.cpp index 7f3a478..f4a5974 100644 --- a/code/redalert/mapedit.cpp +++ b/code/redalert/mapedit.cpp @@ -535,7 +535,7 @@ void MapEditClass::AI(KeyNumType & input, int x, int y) ** Check for mouse motion while left button is down. */ rc = Mouse_Moved(); - if (LMouseDown && rc) { + if (Keyboard->Down(KN_LMOUSE) && rc) { /* ** "Paint" mode: place current object, and restart placement