Merge pull request #12756 from sonninnos/winraw-alt-sticky
(WINRAW) Alt sticky fix
This commit is contained in:
commit
1661d4e969
|
@ -1113,16 +1113,26 @@ static LRESULT CALLBACK wnd_proc_winraw_common_internal(HWND hwnd,
|
||||||
taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_CLIP_WINDOW
|
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
|
#ifdef HAVE_CLIP_WINDOW
|
||||||
if (input_mouse_grabbed())
|
if (input_mouse_grabbed())
|
||||||
win32_clip_window(true);
|
win32_clip_window(true);
|
||||||
|
#endif
|
||||||
|
#if !defined(_XBOX)
|
||||||
|
if (winraw_handle_message(message, wparam, lparam))
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
|
#ifdef HAVE_CLIP_WINDOW
|
||||||
if (input_mouse_grabbed())
|
if (input_mouse_grabbed())
|
||||||
win32_clip_window(false);
|
win32_clip_window(false);
|
||||||
break;
|
|
||||||
#endif
|
#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 */
|
case WM_DISPLAYCHANGE: /* fix size after display mode switch when using SR */
|
||||||
win32_resize_after_display_change(hwnd);
|
win32_resize_after_display_change(hwnd);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -79,6 +79,7 @@ typedef struct
|
||||||
|
|
||||||
/* TODO/FIXME - static globals */
|
/* TODO/FIXME - static globals */
|
||||||
static winraw_mouse_t *g_mice = NULL;
|
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)]])
|
#define WINRAW_KEYBOARD_PRESSED(wr, key) (wr->keyboard.keys[rarch_keysym_lut[(enum retro_key)(key)]])
|
||||||
|
|
||||||
|
@ -362,9 +363,9 @@ static void winraw_update_mouse_state(winraw_input_t *wr,
|
||||||
|
|
||||||
if (!EqualRect(&wr->active_rect, &wr->prev_rect))
|
if (!EqualRect(&wr->active_rect, &wr->prev_rect))
|
||||||
{
|
{
|
||||||
if (wr->rect_delay < 10 )
|
if (wr->rect_delay < 10)
|
||||||
{
|
{
|
||||||
RARCH_LOG("[CRT][WINRAW]: Resize RECT delay for absolute co-ords - %d \n", wr->rect_delay);
|
RARCH_DBG("[CRT][WINRAW]: Resize RECT delay for absolute co-ords - %d \n", wr->rect_delay);
|
||||||
winraw_init_mouse_xy_mapping(wr); /* Triggering fewer times seems to fix the issue. Forcing resize while resolution is changing */
|
winraw_init_mouse_xy_mapping(wr); /* Triggering fewer times seems to fix the issue. Forcing resize while resolution is changing */
|
||||||
wr->rect_delay ++;
|
wr->rect_delay ++;
|
||||||
}
|
}
|
||||||
|
@ -372,7 +373,7 @@ static void winraw_update_mouse_state(winraw_input_t *wr,
|
||||||
{
|
{
|
||||||
int bottom = wr->prev_rect.bottom;
|
int bottom = wr->prev_rect.bottom;
|
||||||
int right = wr->prev_rect.right;
|
int right = wr->prev_rect.right;
|
||||||
RARCH_LOG("[CRT][WINRAW]: Resizing RECT for absolute coordinates to match new resolution - %dx%d\n", right ,bottom);
|
RARCH_DBG("[CRT][WINRAW]: Resizing RECT for absolute coordinates to match new resolution - %dx%d\n", right ,bottom);
|
||||||
wr->active_rect = wr->prev_rect;
|
wr->active_rect = wr->prev_rect;
|
||||||
winraw_init_mouse_xy_mapping(wr);
|
winraw_init_mouse_xy_mapping(wr);
|
||||||
wr->rect_delay = 0;
|
wr->rect_delay = 0;
|
||||||
|
@ -398,19 +399,10 @@ static void winraw_update_mouse_state(winraw_input_t *wr,
|
||||||
InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX);
|
InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX);
|
||||||
InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY);
|
InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY);
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
if (!GetCursorPos(&crs_pos))
|
if (!GetCursorPos(&crs_pos))
|
||||||
{
|
RARCH_DBG("[WINRAW]: GetCursorPos failed with error %lu.\n", GetLastError());
|
||||||
RARCH_WARN("[WINRAW]: GetCursorPos failed with error %lu.\n", GetLastError());
|
|
||||||
}
|
|
||||||
else if (!ScreenToClient((HWND)video_driver_window_get(), &crs_pos))
|
else if (!ScreenToClient((HWND)video_driver_window_get(), &crs_pos))
|
||||||
{
|
RARCH_DBG("[WINRAW]: ScreenToClient failed with error %lu.\n", GetLastError());
|
||||||
RARCH_WARN("[WINRAW]: ScreenToClient failed with error %lu.\n", GetLastError());
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (!GetCursorPos(&crs_pos)) { }
|
|
||||||
else if (!ScreenToClient((HWND)video_driver_window_get(), &crs_pos)) { }
|
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mouse->x = crs_pos.x;
|
mouse->x = crs_pos.x;
|
||||||
|
@ -602,6 +594,16 @@ static void winraw_poll(void *data)
|
||||||
wr->mice[i].btn_b4 = g_mice[i].btn_b4;
|
wr->mice[i].btn_b4 = g_mice[i].btn_b4;
|
||||||
wr->mice[i].btn_b5 = g_mice[i].btn_b5;
|
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(
|
static int16_t winraw_input_lightgun_state(
|
||||||
|
@ -883,7 +885,7 @@ static int16_t winraw_input_state(
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RETRO_DEVICE_LIGHTGUN:
|
case RETRO_DEVICE_LIGHTGUN:
|
||||||
switch ( id )
|
switch (id)
|
||||||
{
|
{
|
||||||
/*aiming*/
|
/*aiming*/
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X:
|
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X:
|
||||||
|
@ -945,22 +947,26 @@ static int16_t winraw_input_state(
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_XBOX)
|
#if !defined(_XBOX)
|
||||||
bool winraw_handle_message(UINT message,
|
bool winraw_handle_message(UINT msg,
|
||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wpar, LPARAM lpar)
|
||||||
{
|
{
|
||||||
winraw_input_t *wr = (winraw_input_t*)(LONG_PTR)
|
switch (msg)
|
||||||
GetWindowLongPtr(main_window.hwnd, GWLP_USERDATA);
|
|
||||||
|
|
||||||
switch (message)
|
|
||||||
{
|
{
|
||||||
|
case WM_SETFOCUS:
|
||||||
|
winraw_focus = true;
|
||||||
|
break;
|
||||||
|
case WM_KILLFOCUS:
|
||||||
|
winraw_focus = false;
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_DEVICECHANGE:
|
case WM_DEVICECHANGE:
|
||||||
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 /* 2K */
|
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (wParam == DBT_DEVICEARRIVAL ||
|
if (wpar == DBT_DEVICEARRIVAL ||
|
||||||
wParam == DBT_DEVICEREMOVECOMPLETE)
|
wpar == DBT_DEVICEREMOVECOMPLETE)
|
||||||
{
|
{
|
||||||
PDEV_BROADCAST_HDR pHdr = (PDEV_BROADCAST_HDR)lParam;
|
PDEV_BROADCAST_HDR pHdr = (PDEV_BROADCAST_HDR)lpar;
|
||||||
if (pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
if (pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
||||||
joypad_driver_reinit(wr, NULL);
|
joypad_driver_reinit(NULL, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue