mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-01-09 12:25:27 +00:00
Added a hint SDL_HINT_TOUCH_MOUSE_EVENTS to control whether touch events generate synthetic mouse events.
This commit is contained in:
parent
86e95a607b
commit
56cab6d452
|
@ -275,6 +275,17 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH "SDL_MOUSE_FOCUS_CLICKTHROUGH"
|
#define SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH "SDL_MOUSE_FOCUS_CLICKTHROUGH"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief A variable controlling whether touch events should generate synthetic mouse events
|
||||||
|
*
|
||||||
|
* This variable can be set to the following values:
|
||||||
|
* "0" - Touch events will not generate mouse events
|
||||||
|
* "1" - Touch events will generate mouse events
|
||||||
|
*
|
||||||
|
* By default SDL will generate mouse events for touch events
|
||||||
|
*/
|
||||||
|
#define SDL_HINT_TOUCH_MOUSE_EVENTS "SDL_TOUCH_MOUSE_EVENTS"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Minimize your SDL_Window if it loses key focus when in fullscreen mode. Defaults to true.
|
* \brief Minimize your SDL_Window if it loses key focus when in fullscreen mode. Defaults to true.
|
||||||
*
|
*
|
||||||
|
|
|
@ -64,6 +64,18 @@ SDL_MouseRelativeSpeedScaleChanged(void *userdata, const char *name, const char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
SDL_TouchMouseEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||||
|
{
|
||||||
|
SDL_Mouse *mouse = (SDL_Mouse *)userdata;
|
||||||
|
|
||||||
|
if (hint && (*hint == '0' || SDL_strcasecmp(hint, "false") == 0)) {
|
||||||
|
mouse->touch_mouse_events = SDL_FALSE;
|
||||||
|
} else {
|
||||||
|
mouse->touch_mouse_events = SDL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Public functions */
|
/* Public functions */
|
||||||
int
|
int
|
||||||
SDL_MouseInit(void)
|
SDL_MouseInit(void)
|
||||||
|
@ -76,6 +88,9 @@ SDL_MouseInit(void)
|
||||||
SDL_AddHintCallback(SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE,
|
SDL_AddHintCallback(SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE,
|
||||||
SDL_MouseRelativeSpeedScaleChanged, mouse);
|
SDL_MouseRelativeSpeedScaleChanged, mouse);
|
||||||
|
|
||||||
|
SDL_AddHintCallback(SDL_HINT_TOUCH_MOUSE_EVENTS,
|
||||||
|
SDL_TouchMouseEventsChanged, mouse);
|
||||||
|
|
||||||
mouse->cursor_shown = SDL_TRUE;
|
mouse->cursor_shown = SDL_TRUE;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -252,6 +267,10 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ
|
||||||
int xrel;
|
int xrel;
|
||||||
int yrel;
|
int yrel;
|
||||||
|
|
||||||
|
if (mouseID == SDL_TOUCH_MOUSEID && !mouse->touch_mouse_events) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (mouse->relative_mode_warp) {
|
if (mouse->relative_mode_warp) {
|
||||||
int center_x = 0, center_y = 0;
|
int center_x = 0, center_y = 0;
|
||||||
SDL_GetWindowSize(window, ¢er_x, ¢er_y);
|
SDL_GetWindowSize(window, ¢er_x, ¢er_y);
|
||||||
|
@ -384,6 +403,10 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state
|
||||||
Uint32 type;
|
Uint32 type;
|
||||||
Uint32 buttonstate = mouse->buttonstate;
|
Uint32 buttonstate = mouse->buttonstate;
|
||||||
|
|
||||||
|
if (mouseID == SDL_TOUCH_MOUSEID && !mouse->touch_mouse_events) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Figure out which event to perform */
|
/* Figure out which event to perform */
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case SDL_PRESSED:
|
case SDL_PRESSED:
|
||||||
|
|
|
@ -87,6 +87,7 @@ typedef struct
|
||||||
float relative_speed_scale;
|
float relative_speed_scale;
|
||||||
float scale_accum_x;
|
float scale_accum_x;
|
||||||
float scale_accum_y;
|
float scale_accum_y;
|
||||||
|
SDL_bool touch_mouse_events;
|
||||||
|
|
||||||
/* Data for double-click tracking */
|
/* Data for double-click tracking */
|
||||||
int num_clickstates;
|
int num_clickstates;
|
||||||
|
|
Loading…
Reference in a new issue