mirror of https://github.com/encounter/SDL.git
Vita: add hint to select which touchpad generates mouse events
This commit is contained in:
parent
1db47d468a
commit
96be9cddcc
|
@ -1354,6 +1354,18 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define SDL_HINT_TOUCH_MOUSE_EVENTS "SDL_TOUCH_MOUSE_EVENTS"
|
#define SDL_HINT_TOUCH_MOUSE_EVENTS "SDL_TOUCH_MOUSE_EVENTS"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief A variable controlling which touchpad should generate synthetic mouse events
|
||||||
|
*
|
||||||
|
* This variable can be set to the following values:
|
||||||
|
* "0" - Only front touchpad should generate mouse events. Default
|
||||||
|
* "1" - Only back touchpad should generate mouse events.
|
||||||
|
* "2" - Both touchpads should generate mouse events.
|
||||||
|
*
|
||||||
|
* By default SDL will generate mouse events for all touch devices
|
||||||
|
*/
|
||||||
|
#define SDL_HINT_VITA_TOUCH_MOUSE_DEVICE "SDL_HINT_VITA_TOUCH_MOUSE_DEVICE"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A variable controlling whether the Android / tvOS remotes
|
* \brief A variable controlling whether the Android / tvOS remotes
|
||||||
* should be listed as joystick devices, instead of sending keyboard events.
|
* should be listed as joystick devices, instead of sending keyboard events.
|
||||||
|
|
|
@ -109,6 +109,28 @@ SDL_TouchMouseEventsChanged(void *userdata, const char *name, const char *oldVal
|
||||||
mouse->touch_mouse_events = SDL_GetStringBoolean(hint, SDL_TRUE);
|
mouse->touch_mouse_events = SDL_GetStringBoolean(hint, SDL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__vita__)
|
||||||
|
static void SDLCALL
|
||||||
|
SDL_VitaTouchMouseDeviceChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||||
|
{
|
||||||
|
SDL_Mouse *mouse = (SDL_Mouse *)userdata;
|
||||||
|
if (hint) {
|
||||||
|
switch(*hint) {
|
||||||
|
default:
|
||||||
|
case '0':
|
||||||
|
mouse->vita_touch_mouse_device = 0;
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
mouse->vita_touch_mouse_device = 1;
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
mouse->vita_touch_mouse_device = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void SDLCALL
|
static void SDLCALL
|
||||||
SDL_MouseTouchEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
SDL_MouseTouchEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||||
{
|
{
|
||||||
|
@ -166,6 +188,11 @@ SDL_MouseInit(void)
|
||||||
SDL_AddHintCallback(SDL_HINT_TOUCH_MOUSE_EVENTS,
|
SDL_AddHintCallback(SDL_HINT_TOUCH_MOUSE_EVENTS,
|
||||||
SDL_TouchMouseEventsChanged, mouse);
|
SDL_TouchMouseEventsChanged, mouse);
|
||||||
|
|
||||||
|
#if defined(__vita__)
|
||||||
|
SDL_AddHintCallback(SDL_HINT_VITA_TOUCH_MOUSE_DEVICE,
|
||||||
|
SDL_VitaTouchMouseDeviceChanged, mouse);
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_AddHintCallback(SDL_HINT_MOUSE_TOUCH_EVENTS,
|
SDL_AddHintCallback(SDL_HINT_MOUSE_TOUCH_EVENTS,
|
||||||
SDL_MouseTouchEventsChanged, mouse);
|
SDL_MouseTouchEventsChanged, mouse);
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,9 @@ typedef struct
|
||||||
SDL_bool touch_mouse_events;
|
SDL_bool touch_mouse_events;
|
||||||
SDL_bool mouse_touch_events;
|
SDL_bool mouse_touch_events;
|
||||||
SDL_bool was_touch_mouse_events; /* Was a touch-mouse event pending? */
|
SDL_bool was_touch_mouse_events; /* Was a touch-mouse event pending? */
|
||||||
|
#if defined(__vita__)
|
||||||
|
Uint8 vita_touch_mouse_device;
|
||||||
|
#endif
|
||||||
SDL_bool auto_capture;
|
SDL_bool auto_capture;
|
||||||
|
|
||||||
/* Data for input source state */
|
/* Data for input source state */
|
||||||
|
|
|
@ -265,8 +265,13 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window,
|
||||||
|
|
||||||
#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_HINT_VITA_TOUCH_MOUSE_DEVICE: controlling which touchpad should generate synthetic mouse events, PSVita-only */
|
||||||
{
|
{
|
||||||
|
#if defined(__vita__)
|
||||||
|
if (mouse->touch_mouse_events && ((mouse->vita_touch_mouse_device == id) || (mouse->vita_touch_mouse_device == 2)) ) {
|
||||||
|
#else
|
||||||
if (mouse->touch_mouse_events) {
|
if (mouse->touch_mouse_events) {
|
||||||
|
#endif
|
||||||
/* 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) {
|
||||||
if (window) {
|
if (window) {
|
||||||
|
|
Loading…
Reference in New Issue