(WINRAW) Prevent Alt getting stuck when Alt-Tabbing

This commit is contained in:
sonninnos 2021-08-07 04:24:20 +03:00
parent 64244cd73f
commit 079070daf7
2 changed files with 30 additions and 2 deletions

View File

@ -1113,16 +1113,26 @@ static LRESULT CALLBACK wnd_proc_winraw_common_internal(HWND hwnd,
taskbar_is_created = true;
#endif
break;
#ifdef HAVE_CLIP_WINDOW
case WM_SETFOCUS:
#ifdef HAVE_CLIP_WINDOW
if (input_mouse_grabbed())
win32_clip_window(true);
#endif
#if !defined(_XBOX)
if (winraw_handle_message(message, wparam, lparam))
return 0;
#endif
break;
case WM_KILLFOCUS:
#ifdef HAVE_CLIP_WINDOW
if (input_mouse_grabbed())
win32_clip_window(false);
break;
#endif
#if !defined(_XBOX)
if (winraw_handle_message(message, wparam, lparam))
return 0;
#endif
break;
case WM_DISPLAYCHANGE: /* fix size after display mode switch when using SR */
win32_resize_after_display_change(hwnd);
break;

View File

@ -79,6 +79,7 @@ typedef struct
/* TODO/FIXME - static globals */
static winraw_mouse_t *g_mice = NULL;
static bool winraw_focus = false;
#define WINRAW_KEYBOARD_PRESSED(wr, key) (wr->keyboard.keys[rarch_keysym_lut[(enum retro_key)(key)]])
@ -602,6 +603,16 @@ static void winraw_poll(void *data)
wr->mice[i].btn_b4 = g_mice[i].btn_b4;
wr->mice[i].btn_b5 = g_mice[i].btn_b5;
}
/* Prevent LAlt sticky after unfocusing with Alt-Tab */
if (!winraw_focus &&
wr->keyboard.keys[SC_LALT] && !(GetKeyState(VK_MENU) & 0x8000))
{
wr->keyboard.keys[SC_LALT] = 0;
input_keyboard_event(0,
input_keymaps_translate_keysym_to_rk(SC_LALT),
0, 0, RETRO_DEVICE_KEYBOARD);
}
}
static int16_t winraw_input_lightgun_state(
@ -953,6 +964,13 @@ bool winraw_handle_message(UINT message,
switch (message)
{
case WM_SETFOCUS:
winraw_focus = true;
break;
case WM_KILLFOCUS:
winraw_focus = false;
break;
case WM_DEVICECHANGE:
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 /* 2K */
if (wParam == DBT_DEVICEARRIVAL ||