mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +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;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
case WM_SETFOCUS:
|
||||||
|
win32_clip_window(input_mouse_grabbed());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hwnd, message, wparam, lparam);
|
return DefWindowProc(hwnd, message, wparam, lparam);
|
||||||
@ -1124,6 +1127,9 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
|
|||||||
taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
case WM_SETFOCUS:
|
||||||
|
win32_clip_window(input_mouse_grabbed());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hwnd, message, wparam, lparam);
|
return DefWindowProc(hwnd, message, wparam, lparam);
|
||||||
@ -1531,6 +1537,30 @@ void win32_check_window(void *data,
|
|||||||
#endif
|
#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)
|
bool win32_suppress_screensaver(void *data, bool enable)
|
||||||
{
|
{
|
||||||
#if !defined(_XBOX)
|
#if !defined(_XBOX)
|
||||||
|
@ -98,6 +98,8 @@ HWND win32_get_window(void);
|
|||||||
|
|
||||||
bool win32_has_focus(void *data);
|
bool win32_has_focus(void *data);
|
||||||
|
|
||||||
|
void win32_clip_window(bool grab);
|
||||||
|
|
||||||
void win32_check_window(void *data,
|
void win32_check_window(void *data,
|
||||||
bool *quit,
|
bool *quit,
|
||||||
bool *resize, unsigned *width, unsigned *height);
|
bool *resize, unsigned *width, unsigned *height);
|
||||||
|
@ -1007,6 +1007,10 @@ static void dinput_grab_mouse(void *data, bool state)
|
|||||||
(DISCL_EXCLUSIVE | DISCL_FOREGROUND) :
|
(DISCL_EXCLUSIVE | DISCL_FOREGROUND) :
|
||||||
(DISCL_NONEXCLUSIVE | DISCL_FOREGROUND));
|
(DISCL_NONEXCLUSIVE | DISCL_FOREGROUND));
|
||||||
IDirectInputDevice8_Acquire(di->mouse);
|
IDirectInputDevice8_Acquire(di->mouse);
|
||||||
|
|
||||||
|
#ifndef _XBOX
|
||||||
|
win32_clip_window(state);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t dinput_get_capabilities(void *data)
|
static uint64_t dinput_get_capabilities(void *data)
|
||||||
|
@ -25,6 +25,10 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _XBOX
|
||||||
|
#include "../../gfx/common/win32_common.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../input_keymaps.h"
|
#include "../input_keymaps.h"
|
||||||
|
|
||||||
#include "../../configuration.h"
|
#include "../../configuration.h"
|
||||||
@ -874,17 +878,21 @@ static uint64_t winraw_get_capabilities(void *u)
|
|||||||
(1 << RETRO_DEVICE_LIGHTGUN);
|
(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;
|
winraw_input_t *wr = (winraw_input_t*)d;
|
||||||
|
|
||||||
if (grab == wr->mouse_grab)
|
if (state == wr->mouse_grab)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!winraw_set_mouse_input(wr->window, grab))
|
if (!winraw_set_mouse_input(wr->window, state))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wr->mouse_grab = grab;
|
wr->mouse_grab = state;
|
||||||
|
|
||||||
|
#ifndef _XBOX
|
||||||
|
win32_clip_window(state);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
input_driver_t input_winraw = {
|
input_driver_t input_winraw = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user