mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-03-12 04:01:17 +01:00
SDL_Mouse/Touch: discard synthetic events when hints are not set.
Those are generated/flagged by platform layer.
This commit is contained in:
parent
d550867aef
commit
6625203514
@ -338,6 +338,13 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* SDL_HINT_TOUCH_MOUSE_EVENTS: if not set, discard synthetic mouse events coming from platform layer */
|
||||||
|
if (mouse->touch_mouse_events == 0) {
|
||||||
|
if (mouseID == SDL_TOUCH_MOUSEID) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mouseID != SDL_TOUCH_MOUSEID && mouse->relative_mode_warp) {
|
if (mouseID != SDL_TOUCH_MOUSEID && 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);
|
||||||
@ -499,6 +506,13 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* SDL_HINT_TOUCH_MOUSE_EVENTS: if not set, discard synthetic mouse events coming from platform layer */
|
||||||
|
if (mouse->touch_mouse_events == 0) {
|
||||||
|
if (mouseID == SDL_TOUCH_MOUSEID) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Figure out which event to perform */
|
/* Figure out which event to perform */
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case SDL_PRESSED:
|
case SDL_PRESSED:
|
||||||
|
@ -244,16 +244,18 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid,
|
|||||||
{
|
{
|
||||||
int posted;
|
int posted;
|
||||||
SDL_Finger *finger;
|
SDL_Finger *finger;
|
||||||
|
SDL_Mouse *mouse;
|
||||||
|
|
||||||
SDL_Touch* touch = SDL_GetTouch(id);
|
SDL_Touch* touch = SDL_GetTouch(id);
|
||||||
if (!touch) {
|
if (!touch) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mouse = SDL_GetMouse();
|
||||||
|
|
||||||
#if SYNTHESIZE_TOUCH_TO_MOUSE
|
#if SYNTHESIZE_TOUCH_TO_MOUSE
|
||||||
/* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */
|
/* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */
|
||||||
{
|
{
|
||||||
SDL_Mouse *mouse = SDL_GetMouse();
|
|
||||||
if (mouse->touch_mouse_events) {
|
if (mouse->touch_mouse_events) {
|
||||||
/* FIXME: maybe we should only restrict to a few SDL_TouchDeviceType */
|
/* FIXME: maybe we should only restrict to a few SDL_TouchDeviceType */
|
||||||
if (id != SDL_MOUSE_TOUCHID) {
|
if (id != SDL_MOUSE_TOUCHID) {
|
||||||
@ -301,6 +303,13 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* SDL_HINT_MOUSE_TOUCH_EVENTS: if not set, discard synthetic touch events coming from platform layer */
|
||||||
|
if (mouse->mouse_touch_events == 0) {
|
||||||
|
if (id == SDL_MOUSE_TOUCHID) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
finger = SDL_GetFinger(touch, fingerid);
|
finger = SDL_GetFinger(touch, fingerid);
|
||||||
if (down) {
|
if (down) {
|
||||||
if (finger) {
|
if (finger) {
|
||||||
@ -357,6 +366,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
|
|||||||
{
|
{
|
||||||
SDL_Touch *touch;
|
SDL_Touch *touch;
|
||||||
SDL_Finger *finger;
|
SDL_Finger *finger;
|
||||||
|
SDL_Mouse *mouse;
|
||||||
int posted;
|
int posted;
|
||||||
float xrel, yrel, prel;
|
float xrel, yrel, prel;
|
||||||
|
|
||||||
@ -365,10 +375,11 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mouse = SDL_GetMouse();
|
||||||
|
|
||||||
#if SYNTHESIZE_TOUCH_TO_MOUSE
|
#if SYNTHESIZE_TOUCH_TO_MOUSE
|
||||||
/* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */
|
/* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */
|
||||||
{
|
{
|
||||||
SDL_Mouse *mouse = SDL_GetMouse();
|
|
||||||
if (mouse->touch_mouse_events) {
|
if (mouse->touch_mouse_events) {
|
||||||
if (id != SDL_MOUSE_TOUCHID) {
|
if (id != SDL_MOUSE_TOUCHID) {
|
||||||
SDL_Window *window = SDL_GetMouseFocus();
|
SDL_Window *window = SDL_GetMouseFocus();
|
||||||
@ -388,6 +399,13 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* SDL_HINT_MOUSE_TOUCH_EVENTS: if not set, discard synthetic touch events coming from platform layer */
|
||||||
|
if (mouse->mouse_touch_events == 0) {
|
||||||
|
if (id == SDL_MOUSE_TOUCHID) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
finger = SDL_GetFinger(touch,fingerid);
|
finger = SDL_GetFinger(touch,fingerid);
|
||||||
if (!finger) {
|
if (!finger) {
|
||||||
return SDL_SendTouch(id, fingerid, SDL_TRUE, x, y, pressure);
|
return SDL_SendTouch(id, fingerid, SDL_TRUE, x, y, pressure);
|
||||||
|
Loading…
Reference in New Issue
Block a user