commit 43b0fcc64181289a008d7847245f4ec50216a034 Author: Martin Gerhardy Date: Wed Nov 25 06:39:43 2015 +0100 LIBS: add SDL_GetTouchName to expose the driver name of the device currently most of the drivers don't expose a name- but that might change diff --git a/src/libs/sdl2/include/SDL_touch.h b/src/libs/sdl2/include/SDL_touch.h index 68ff171..8aacbd2 100644 --- a/src/libs/sdl2/include/SDL_touch.h +++ b/src/libs/sdl2/include/SDL_touch.h @@ -66,6 +66,11 @@ extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); /** + * \brief Get the touch device name as reported from the driver or NULL if the index is invalid. + */ +extern DECLSPEC const char* SDLCALL SDL_GetTouchName(int index); + +/** * \brief Get the number of active fingers for a given touch device. */ extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); diff --git a/src/libs/sdl2/src/dynapi/SDL_dynapi_overrides.h b/src/libs/sdl2/src/dynapi/SDL_dynapi_overrides.h index 75f31ce..d50a10b 100644 --- a/src/libs/sdl2/src/dynapi/SDL_dynapi_overrides.h +++ b/src/libs/sdl2/src/dynapi/SDL_dynapi_overrides.h @@ -492,6 +492,7 @@ #define SDL_RemoveTimer SDL_RemoveTimer_REAL #define SDL_GetNumTouchDevices SDL_GetNumTouchDevices_REAL #define SDL_GetTouchDevice SDL_GetTouchDevice_REAL +#define SDL_GetTouchName SDL_GetTouchName_REAL #define SDL_GetNumTouchFingers SDL_GetNumTouchFingers_REAL #define SDL_GetTouchFinger SDL_GetTouchFinger_REAL #define SDL_GetVersion SDL_GetVersion_REAL @@ -597,3 +598,4 @@ #define SDL_JoystickCurrentPowerLevel SDL_JoystickCurrentPowerLevel_REAL #define SDL_GameControllerFromInstanceID SDL_GameControllerFromInstanceID_REAL #define SDL_JoystickFromInstanceID SDL_JoystickFromInstanceID_REAL +#define SDL_GetTouchName SDL_GetTouchName_REAL diff --git a/src/libs/sdl2/src/dynapi/SDL_dynapi_procs.h b/src/libs/sdl2/src/dynapi/SDL_dynapi_procs.h index 57bbba6..28e892f 100644 --- a/src/libs/sdl2/src/dynapi/SDL_dynapi_procs.h +++ b/src/libs/sdl2/src/dynapi/SDL_dynapi_procs.h @@ -631,3 +631,4 @@ SDL_DYNAPI_PROC(int,SDL_GetDisplayDPI,(int a, float *b, float *c, float *d),(a,b SDL_DYNAPI_PROC(SDL_JoystickPowerLevel,SDL_JoystickCurrentPowerLevel,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(SDL_GameController*,SDL_GameControllerFromInstanceID,(SDL_JoystickID a),(a),return) SDL_DYNAPI_PROC(SDL_Joystick*,SDL_JoystickFromInstanceID,(SDL_JoystickID a),(a),return) +SDL_DYNAPI_PROC(const char*,SDL_GetTouchName,(int a),(a),return) diff --git a/src/libs/sdl2/src/events/SDL_touch.c b/src/libs/sdl2/src/events/SDL_touch.c index 1b477ea..4956d9b 100644 --- a/src/libs/sdl2/src/events/SDL_touch.c +++ b/src/libs/sdl2/src/events/SDL_touch.c @@ -54,6 +54,16 @@ SDL_GetTouchDevice(int index) return SDL_touchDevices[index]->id; } +const char* +SDL_GetTouchName(int index) +{ + if (index < 0 || index >= SDL_num_touch) { + SDL_SetError("Unknown touch device"); + return NULL; + } + return SDL_touchDevices[index]->name; +} + static int SDL_GetTouchIndex(SDL_TouchID id) { @@ -160,6 +170,7 @@ SDL_AddTouch(SDL_TouchID touchID, const char *name) SDL_touchDevices[index]->num_fingers = 0; SDL_touchDevices[index]->max_fingers = 0; SDL_touchDevices[index]->fingers = NULL; + SDL_touchDevices[index]->name = SDL_strdup(name); /* Record this touch device for gestures */ /* We could do this on the fly in the gesture code if we wanted */ @@ -342,6 +353,7 @@ SDL_DelTouch(SDL_TouchID id) SDL_free(touch->fingers[i]); } SDL_free(touch->fingers); + SDL_free(touch->name); SDL_free(touch); SDL_num_touch--; diff --git a/src/libs/sdl2/src/events/SDL_touch_c.h b/src/libs/sdl2/src/events/SDL_touch_c.h index 3e4b8bb..22d1d28 100644 --- a/src/libs/sdl2/src/events/SDL_touch_c.h +++ b/src/libs/sdl2/src/events/SDL_touch_c.h @@ -30,6 +30,7 @@ typedef struct SDL_Touch int num_fingers; int max_fingers; SDL_Finger** fingers; + const char *name; } SDL_Touch;