mirror of
https://github.com/encounter/SDL.git
synced 2025-12-09 13:37:56 +00:00
cocoa: Another attempt at mouse vs touch support.
This time, we make anything we think is a MacBook trackpad report its touches as SDL_MOUSE_TOUCHID, even though they're not _actually_ synthesized events, and let all mouse input--even if the OS synthesized it from a multitouch trackpad on our behalf--look like physical input. This is backwards from reality, but produces the results most apps will expect. Note that if you have a real touch device that doesn't appear to be the trackpad, it'll produce real touch events with unique device ids, so it's not a total loss here, but also note that the way we decide if it was the trackpad is an imperfect heuristic; it happens to work out right now, but it's not impossible that a real touchscreen could come to the Mac at some point and (incorrectly?) call it a "mouse" input, etc. But for now, good enough. Fixes Bugzilla #4690.
This commit is contained in:
@@ -383,13 +383,11 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ
|
||||
mouse->has_position = SDL_TRUE;
|
||||
}
|
||||
|
||||
#ifndef __MACOSX__ /* all your trackpad input would lack relative motion when not dragging in this case. */
|
||||
/* Ignore relative motion positioning the first touch */
|
||||
if (mouseID == SDL_TOUCH_MOUSEID && !mouse->buttonstate) {
|
||||
xrel = 0;
|
||||
yrel = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Update internal mouse coordinates */
|
||||
if (!mouse->relative_mode) {
|
||||
|
||||
@@ -33,11 +33,7 @@ static SDL_Touch **SDL_touchDevices = NULL;
|
||||
|
||||
/* for mapping touch events to mice */
|
||||
|
||||
#ifndef __MACOSX__ /* don't generate mouse events from touch on macOS, the OS handles that. */
|
||||
#define SYNTHESIZE_TOUCH_TO_MOUSE 1
|
||||
#else
|
||||
#define SYNTHESIZE_TOUCH_TO_MOUSE 0
|
||||
#endif
|
||||
|
||||
#if SYNTHESIZE_TOUCH_TO_MOUSE
|
||||
static SDL_bool finger_touching = SDL_FALSE;
|
||||
|
||||
Reference in New Issue
Block a user