mirror of https://github.com/libsdl-org/SDL.git
mouse: Clean up virtual touch devices as appropriate.
This commit is contained in:
parent
dabc93a631
commit
ebb24eedc8
|
|
@ -169,7 +169,15 @@ static void SDLCALL SDL_MouseTouchEventsChanged(void *userdata, const char *name
|
|||
mouse->mouse_touch_events = SDL_GetStringBoolean(hint, default_value);
|
||||
|
||||
if (mouse->mouse_touch_events) {
|
||||
SDL_AddTouch(SDL_MOUSE_TOUCHID, SDL_TOUCH_DEVICE_DIRECT, "mouse_input");
|
||||
if (!mouse->added_mouse_touch_device) {
|
||||
SDL_AddTouch(SDL_MOUSE_TOUCHID, SDL_TOUCH_DEVICE_DIRECT, "mouse_input");
|
||||
mouse->added_mouse_touch_device = true;
|
||||
}
|
||||
} else {
|
||||
if (mouse->added_mouse_touch_device) {
|
||||
SDL_DelTouch(SDL_MOUSE_TOUCHID);
|
||||
mouse->added_mouse_touch_device = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -187,7 +195,15 @@ static void SDLCALL SDL_PenTouchEventsChanged(void *userdata, const char *name,
|
|||
mouse->pen_touch_events = SDL_GetStringBoolean(hint, true);
|
||||
|
||||
if (mouse->pen_touch_events) {
|
||||
SDL_AddTouch(SDL_PEN_TOUCHID, SDL_TOUCH_DEVICE_DIRECT, "pen_input");
|
||||
if (!mouse->added_pen_touch_device) {
|
||||
SDL_AddTouch(SDL_PEN_TOUCHID, SDL_TOUCH_DEVICE_DIRECT, "pen_input");
|
||||
mouse->added_pen_touch_device = true;
|
||||
}
|
||||
} else {
|
||||
if (mouse->added_pen_touch_device) {
|
||||
SDL_DelTouch(SDL_PEN_TOUCHID);
|
||||
mouse->added_pen_touch_device = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1010,6 +1026,14 @@ void SDL_QuitMouse(void)
|
|||
SDL_Cursor *cursor, *next;
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
if (mouse->added_mouse_touch_device) {
|
||||
SDL_DelTouch(SDL_MOUSE_TOUCHID);
|
||||
}
|
||||
|
||||
if (mouse->added_pen_touch_device) {
|
||||
SDL_DelTouch(SDL_PEN_TOUCHID);
|
||||
}
|
||||
|
||||
if (mouse->CaptureMouse) {
|
||||
SDL_CaptureMouse(false);
|
||||
SDL_UpdateMouseCapture(true);
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ typedef struct
|
|||
bool pen_mouse_events;
|
||||
bool pen_touch_events;
|
||||
bool was_touch_mouse_events; // Was a touch-mouse event pending?
|
||||
bool added_mouse_touch_device; // did we SDL_AddTouch() a virtual touch device for the mouse?
|
||||
bool added_pen_touch_device; // did we SDL_AddTouch() a virtual touch device for pens?
|
||||
#ifdef SDL_PLATFORM_VITA
|
||||
Uint8 vita_touch_mouse_device;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue