Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Added SDL_TouchID, SDL_FingerID, SDL_GestureID types. Converted to in…
…teger cioordinates (<- not working).
  • Loading branch information
jimtla committed Jul 31, 2010
1 parent 9c24bb5 commit 7fffc6c540c8f5a601c213ee77120b683bd3bf07
@@ -288,15 +288,15 @@ typedef struct SDL_TouchFingerEvent
Uint32 type; /**< ::SDL_FINGERMOTION OR
SDL_FINGERDOWN OR SDL_FINGERUP*/
Uint32 windowID; /**< The window with mouse focus, if any */
long touchId; /**< The touch device id */
long fingerId;
SDL_TouchID touchId; /**< The touch device id */
SDL_FingerID fingerId;
Uint8 state; /**< The current button state */
Uint8 padding1;
Uint8 padding2;
Uint8 padding3;
float x;
float y;
int pressure;
Uint16 x;
Uint16 y;
Uint16 pressure;
} SDL_TouchFingerEvent;


@@ -307,7 +307,7 @@ typedef struct SDL_TouchButtonEvent
{
Uint32 type; /**< ::SDL_TOUCHBUTTONUP OR SDL_TOUCHBUTTONDOWN */
Uint32 windowID; /**< The window with mouse focus, if any */
long touchId; /**< The touch device index */
SDL_TouchID touchId; /**< The touch device index */
Uint8 state; /**< The current button state */
Uint8 button; /**< The button changing state */
Uint8 padding1;
@@ -323,7 +323,7 @@ typedef struct SDL_MultiGestureEvent
{
Uint32 type; /**< ::SDL_MULTIGESTURE */
Uint32 windowID; /**< The window with mouse focus, if any */
long touchId; /**< The touch device index */
SDL_TouchID touchId; /**< The touch device index */
float dTheta;
float dDist;
float x; //currently 0...1. Change to screen coords?
@@ -335,8 +335,8 @@ typedef struct SDL_DollarGestureEvent
{
Uint32 type; /**< ::SDL_DOLLARGESTURE */
Uint32 windowID; /**< The window with mouse focus, if any */
long touchId; /**< The touch device index */
unsigned long gestureId;
SDL_TouchID touchId; /**< The touch device index */
SDL_GestureID gestureId;
float error;
/*
//TODO: Enable to give location?
@@ -33,6 +33,9 @@
#include "SDL_error.h"
#include "SDL_video.h"

#include "SDL_touch.h"


#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
@@ -41,6 +44,7 @@ extern "C" {
/* *INDENT-ON* */
#endif

typedef Uint64 SDL_GestureID;

/* Function prototypes */

@@ -49,7 +53,7 @@ extern "C" {
*
*
*/
extern DECLSPEC int SDLCALL SDL_RecordGesture(int touchId);
extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);


/**
@@ -65,15 +69,16 @@ extern "C" {
*
*/
extern DECLSPEC int
SDLCALL SDL_SaveDollarTemplate(unsigned long gestureId,SDL_RWops *src);
SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *src);


/**
* \brief Load Dollar Gesture templates from a file
*
*
*/
extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(int touchId, SDL_RWops *src);
extern DECLSPEC
int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src);



@@ -42,15 +42,19 @@ extern "C" {
#endif


typedef Uint64 SDL_TouchID;
typedef Uint64 SDL_FingerID;


struct SDL_Finger {
long id;
float x;
float y;
float xdelta;
float ydelta;
float last_x, last_y,last_pressure; /* the last reported coordinates */
SDL_FingerID id;
Uint16 x;
Uint16 y;
Uint16 xdelta;
Uint16 ydelta;
Uint16 last_x, last_y,last_pressure; /* the last reported coordinates */
SDL_bool down;
float pressure;
Uint16 pressure;
};

typedef struct SDL_Touch SDL_Touch;
@@ -66,12 +70,13 @@ struct SDL_Touch {
float pressure_max, pressure_min;
float x_max,x_min;
float y_max,y_min;
float xres,yres,pressureres;
Uint16 xres,yres,pressureres;
float native_xres,native_yres,native_pressureres;
float tilt; /* for future use */
float rotation; /* for future use */

/* Data common to all touch */
long id;
SDL_TouchID id;
SDL_Window *focus;

char *name;
@@ -95,7 +100,7 @@ struct SDL_Touch {
*
*
*/
extern DECLSPEC SDL_Touch* SDLCALL SDL_GetTouch(long id);
extern DECLSPEC SDL_Touch* SDLCALL SDL_GetTouch(SDL_TouchID id);



@@ -104,7 +109,8 @@ struct SDL_Touch {
*
*
*/
extern DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, long id);
extern
DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, SDL_FingerID id);

/* Ends C function definitions when using C++ */
#ifdef __cplusplus
@@ -46,7 +46,7 @@ typedef struct {
typedef struct {
Point p;
float pressure;
int id;
SDL_FingerID id;
} Finger;


@@ -71,7 +71,7 @@ typedef struct {
} DollarTemplate;

typedef struct {
int id;
SDL_GestureID id;
Point res;
Point centroid;
TouchPoint gestureLast[MAXFINGERS];
@@ -87,7 +87,7 @@ GestureTouch gestureTouch[MAXTOUCHES];
int numGestureTouches = 0;
SDL_bool recordAll;

int SDL_RecordGesture(int touchId) {
int SDL_RecordGesture(SDL_TouchID touchId) {
int i;
if(touchId < 0) recordAll = SDL_TRUE;
for(i = 0;i < numGestureTouches; i++) {
@@ -143,7 +143,7 @@ int SDL_SaveAllDollarTemplates(SDL_RWops *src) {
return rtrn;
}

int SDL_SaveDollarTemplate(unsigned long gestureId, SDL_RWops *src) {
int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src) {
int i,j;
for(i = 0; i < numGestureTouches; i++) {
GestureTouch* touch = &gestureTouch[i];
@@ -185,7 +185,7 @@ static int SDL_AddDollarGesture(GestureTouch* inTouch,Point* path) {
return -1;
}

int SDL_LoadDollarTemplates(int touchId, SDL_RWops *src) {
int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) {
if(src == NULL) return 0;
int i,loaded = 0;
GestureTouch *touch = NULL;
@@ -394,7 +394,7 @@ int SDL_GestureAddTouch(SDL_Touch* touch) {
return 0;
}

GestureTouch * SDL_GetGestureTouch(int id) {
GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) {
int i;
for(i = 0;i < numGestureTouches; i++) {
//printf("%i ?= %i\n",gestureTouch[i].id,id);
@@ -414,7 +414,8 @@ int SDL_SendGestureMulti(GestureTouch* touch,float dTheta,float dDist) {
return SDL_PushEvent(&event) > 0;
}

int SDL_SendGestureDollar(GestureTouch* touch,int gestureId,float error) {
int SDL_SendGestureDollar(GestureTouch* touch,
SDL_GestureID gestureId,float error) {
SDL_Event event;
event.dgesture.type = SDL_DOLLARGESTURE;
event.dgesture.touchId = touch->id;
@@ -429,7 +430,7 @@ int SDL_SendGestureDollar(GestureTouch* touch,int gestureId,float error) {
}


int SDL_SendDollarRecord(GestureTouch* touch,int gestureId) {
int SDL_SendDollarRecord(GestureTouch* touch,SDL_GestureID gestureId) {
SDL_Event event;
event.dgesture.type = SDL_DOLLARRECORD;
event.dgesture.touchId = touch->id;
@@ -489,7 +490,7 @@ void SDL_GestureProcessEvent(SDL_Event* event)
&bestTempl,inTouch);
if(bestTempl >= 0){
//Send Event
int gestureId = inTouch->dollarTemplate[bestTempl].hash;
unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash;
SDL_SendGestureDollar(inTouch,gestureId,error);
printf("Dollar error: %f\n",error);
}
@@ -26,7 +26,7 @@

extern void SDL_GestureProcessEvent(SDL_Event* event);

extern int SDL_RecordGesture(int touchId);
extern int SDL_RecordGesture(SDL_TouchID touchId);

extern int SDL_GestureAddTouch(SDL_Touch* touch);

0 comments on commit 7fffc6c

Please sign in to comment.