mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-25 20:32:22 +00:00
(WIN32) Cursor clipping for grabbed mouse
This commit is contained in:
parent
94446ab488
commit
e39ade0f05
@ -1018,6 +1018,9 @@ static LRESULT CALLBACK wnd_proc_common_internal(HWND hwnd,
|
||||
taskbar_is_created = true;
|
||||
#endif
|
||||
break;
|
||||
case WM_SETFOCUS:
|
||||
win32_clip_window(input_mouse_grabbed());
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, message, wparam, lparam);
|
||||
@ -1124,6 +1127,9 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
|
||||
taskbar_is_created = true;
|
||||
#endif
|
||||
break;
|
||||
case WM_SETFOCUS:
|
||||
win32_clip_window(input_mouse_grabbed());
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, message, wparam, lparam);
|
||||
@ -1531,6 +1537,30 @@ void win32_check_window(void *data,
|
||||
#endif
|
||||
}
|
||||
|
||||
void win32_clip_window(bool state)
|
||||
{
|
||||
#if !defined(_XBOX)
|
||||
RECT clip_rect;
|
||||
|
||||
if (state && main_window.hwnd)
|
||||
{
|
||||
PWINDOWINFO info;
|
||||
info = malloc(sizeof(*info));
|
||||
info->cbSize = sizeof(PWINDOWINFO);
|
||||
|
||||
if (GetWindowInfo(main_window.hwnd, info))
|
||||
clip_rect = info->rcClient;
|
||||
|
||||
free(info);
|
||||
info = NULL;
|
||||
}
|
||||
else
|
||||
GetWindowRect(GetDesktopWindow(), &clip_rect);
|
||||
|
||||
ClipCursor(&clip_rect);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool win32_suppress_screensaver(void *data, bool enable)
|
||||
{
|
||||
#if !defined(_XBOX)
|
||||
|
@ -98,6 +98,8 @@ HWND win32_get_window(void);
|
||||
|
||||
bool win32_has_focus(void *data);
|
||||
|
||||
void win32_clip_window(bool grab);
|
||||
|
||||
void win32_check_window(void *data,
|
||||
bool *quit,
|
||||
bool *resize, unsigned *width, unsigned *height);
|
||||
|
@ -1007,6 +1007,10 @@ static void dinput_grab_mouse(void *data, bool state)
|
||||
(DISCL_EXCLUSIVE | DISCL_FOREGROUND) :
|
||||
(DISCL_NONEXCLUSIVE | DISCL_FOREGROUND));
|
||||
IDirectInputDevice8_Acquire(di->mouse);
|
||||
|
||||
#ifndef _XBOX
|
||||
win32_clip_window(state);
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint64_t dinput_get_capabilities(void *data)
|
||||
|
@ -25,6 +25,10 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _XBOX
|
||||
#include "../../gfx/common/win32_common.h"
|
||||
#endif
|
||||
|
||||
#include "../input_keymaps.h"
|
||||
|
||||
#include "../../configuration.h"
|
||||
@ -874,17 +878,21 @@ static uint64_t winraw_get_capabilities(void *u)
|
||||
(1 << RETRO_DEVICE_LIGHTGUN);
|
||||
}
|
||||
|
||||
static void winraw_grab_mouse(void *d, bool grab)
|
||||
static void winraw_grab_mouse(void *d, bool state)
|
||||
{
|
||||
winraw_input_t *wr = (winraw_input_t*)d;
|
||||
|
||||
if (grab == wr->mouse_grab)
|
||||
if (state == wr->mouse_grab)
|
||||
return;
|
||||
|
||||
if (!winraw_set_mouse_input(wr->window, grab))
|
||||
if (!winraw_set_mouse_input(wr->window, state))
|
||||
return;
|
||||
|
||||
wr->mouse_grab = grab;
|
||||
wr->mouse_grab = state;
|
||||
|
||||
#ifndef _XBOX
|
||||
win32_clip_window(state);
|
||||
#endif
|
||||
}
|
||||
|
||||
input_driver_t input_winraw = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user