Skip to content

Commit

Permalink
Fix for prev. commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kmatheussen committed Aug 28, 2020
1 parent b028a95 commit 119994f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Qt/Qt_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2435,7 +2435,7 @@ bool Control2Pressed(void){

bool MetaPressed(void){
#if defined(FOR_WINDOWS)
return AnyExtra(tevent.keyswitch); // The other way doesn't work on Windows.
return W_windows_key_down(); // We have to go pretty low-level (WH_KEYBOARD_LL hook) to check if a win key is pressed.
#else
return QApplication::keyboardModifiers() & Qt::MetaModifier;
#endif
Expand Down
15 changes: 11 additions & 4 deletions windows/W_Keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ void OS_WINDOWS_set_on_top_of_everything(void *child_handle){
}
#endif

bool W_windows_key_down(void){
return ATOMIC_GET(left_windows_down) || ATOMIC_GET(right_windows_down);
}

static uint32_t get_keyswitch(void){
uint32_t keyswitch=0;
Expand Down Expand Up @@ -836,6 +839,7 @@ void OS_SYSTEM_EventPreHandler(void *void_event){
if (type==TR_KEYBOARD || type==TR_KEYBOARDUP){
g_last_keyswitch = tevent.keyswitch;
tevent.keyswitch = get_keyswitch();
//printf(" OS_SYSTEM_EventPreHandler: tevent.keyswitch set to %x. META: %x. Left: %d. Right: %d\n", tevent.keyswitch, AnyExtra(tevent.keyswitch), ATOMIC_GET(left_windows_down), ATOMIC_GET(right_windows_down));;
}
}

Expand Down Expand Up @@ -944,11 +948,14 @@ static LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM l

if(p->vkCode==VK_LWIN || p->vkCode==VK_RWIN){// || p->vkCode==VK_RMENU){

if(p->vkCode==VK_LWIN)
if(p->vkCode==VK_LWIN){
ATOMIC_SET(left_windows_down, wParam==WM_KEYDOWN);
else
//printf(" LowLevelKeyboardProc: LEFT DOWN: %d\n", wParam==WM_KEYDOWN);
}else{
ATOMIC_SET(right_windows_down, wParam==WM_KEYDOWN);

//printf(" LowLevelKeyboardProc: RIGHT DOWN: %d\n", wParam==WM_KEYDOWN);
}

#if 0
if(p->vkCode==VK_LWIN && wParam==WM_KEYDOWN)
printf(" 1. Left down\n");
Expand All @@ -961,7 +968,7 @@ static LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM l
#endif

#if 0
// Don't think this is any point.
// Don't think this is any point. (It's not pointless, but we are in a different thread (I think) so we have to do it a different way.)
if (left_windows_down)
tevent.keyswitch |= EVENT_LEFTEXTRA1;
else
Expand Down
2 changes: 1 addition & 1 deletion windows/W_Keyboard_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */


extern LANGSPEC bool W_windows_key_down(void);
extern LANGSPEC void W_KeyboardHandlerShutDown(void);
extern LANGSPEC void W_RegisterRawInputHandler(void *hwnd); // hwnd is g_main_window->effectiveWinId(). Call this function during initialization after g_main_window has started.
extern LANGSPEC bool W_HasDeltaMouse(void);
Expand Down

0 comments on commit 119994f

Please sign in to comment.