From 7fffc6c540c8f5a601c213ee77120b683bd3bf07 Mon Sep 17 00:00:00 2001 From: jimtla Date: Sat, 31 Jul 2010 20:02:54 +0400 Subject: [PATCH] Added SDL_TouchID, SDL_FingerID, SDL_GestureID types. Converted to integer cioordinates (<- not working). --- include/SDL_events.h | 18 +++--- include/SDL_gesture.h | 11 +++- include/SDL_touch.h | 28 +++++---- src/events/SDL_gesture.c | 19 +++--- src/events/SDL_gesture_c.h | 2 +- src/events/SDL_touch.c | 62 ++++++++++++------- src/events/SDL_touch_c.h | 20 +++--- src/video/cocoa/SDL_cocoawindow.m | 6 +- src/video/uikit/SDL_uikitview.m | 6 +- src/video/x11/SDL_eventtouch.c | 11 +--- .../touchTestIPhone2/touchTestIPhone/main.c | 14 ++--- 11 files changed, 108 insertions(+), 89 deletions(-) diff --git a/include/SDL_events.h b/include/SDL_events.h index 928c64cb3..032bed438 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -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? diff --git a/include/SDL_gesture.h b/include/SDL_gesture.h index 497b86e1f..1c366eaae 100644 --- a/include/SDL_gesture.h +++ b/include/SDL_gesture.h @@ -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,7 +69,7 @@ extern "C" { * */ extern DECLSPEC int - SDLCALL SDL_SaveDollarTemplate(unsigned long gestureId,SDL_RWops *src); + SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *src); /** @@ -73,7 +77,8 @@ extern "C" { * * */ - extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(int touchId, SDL_RWops *src); + extern DECLSPEC + int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); diff --git a/include/SDL_touch.h b/include/SDL_touch.h index bcae77817..2c7ce4056 100644 --- a/include/SDL_touch.h +++ b/include/SDL_touch.h @@ -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 diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index f1989e41b..c73d6f11a 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -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); } diff --git a/src/events/SDL_gesture_c.h b/src/events/SDL_gesture_c.h index feec21744..f1f67a3e4 100644 --- a/src/events/SDL_gesture_c.h +++ b/src/events/SDL_gesture_c.h @@ -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); diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c index 6c07badb0..5fb336d73 100644 --- a/src/events/SDL_touch.c +++ b/src/events/SDL_touch.c @@ -42,7 +42,7 @@ SDL_TouchInit(void) } SDL_Touch * -SDL_GetTouch(long id) +SDL_GetTouch(SDL_TouchID id) { int index = SDL_GetTouchIndexId(id); if (index < 0 || index >= SDL_num_touch) { @@ -61,7 +61,7 @@ SDL_GetTouchIndex(int index) } int -SDL_GetFingerIndexId(SDL_Touch* touch,long fingerid) +SDL_GetFingerIndexId(SDL_Touch* touch,SDL_FingerID fingerid) { int i; for(i = 0;i < touch->num_fingers;i++) @@ -72,7 +72,7 @@ SDL_GetFingerIndexId(SDL_Touch* touch,long fingerid) SDL_Finger * -SDL_GetFinger(SDL_Touch* touch,long id) +SDL_GetFinger(SDL_Touch* touch,SDL_FingerID id) { int index = SDL_GetFingerIndexId(touch,id); if(index < 0 || index >= touch->num_fingers) @@ -82,7 +82,7 @@ SDL_GetFinger(SDL_Touch* touch,long id) int -SDL_GetTouchIndexId(long id) +SDL_GetTouchIndexId(SDL_TouchID id) { int index; SDL_Touch *touch; @@ -139,6 +139,8 @@ SDL_AddTouch(const SDL_Touch * touch, char *name) SDL_touchPads[index]->relative_mode = SDL_FALSE; SDL_touchPads[index]->flush_motion = SDL_FALSE; + SDL_touchPads[index]->xres = (1<<(16-1)); + SDL_touchPads[index]->yres = (1<<(16-1)); //Do I want this here? Probably SDL_GestureAddTouch(SDL_touchPads[index]); @@ -146,7 +148,7 @@ SDL_AddTouch(const SDL_Touch * touch, char *name) } void -SDL_DelTouch(long id) +SDL_DelTouch(SDL_TouchID id) { int index = SDL_GetTouchIndexId(id); SDL_Touch *touch = SDL_GetTouch(id); @@ -189,7 +191,7 @@ SDL_GetNumTouch(void) return SDL_num_touch; } SDL_Window * -SDL_GetTouchFocusWindow(long id) +SDL_GetTouchFocusWindow(SDL_TouchID id) { SDL_Touch *touch = SDL_GetTouch(id); @@ -200,7 +202,7 @@ SDL_GetTouchFocusWindow(long id) } void -SDL_SetTouchFocus(long id, SDL_Window * window) +SDL_SetTouchFocus(SDL_TouchID id, SDL_Window * window) { int index = SDL_GetTouchIndexId(id); SDL_Touch *touch = SDL_GetTouch(id); @@ -250,12 +252,12 @@ SDL_SetTouchFocus(long id, SDL_Window * window) } int -SDL_AddFinger(SDL_Touch* touch,SDL_Finger finger) +SDL_AddFinger(SDL_Touch* touch,SDL_Finger *finger) { int index; SDL_Finger **fingers; //printf("Adding Finger...\n"); - if (SDL_GetFingerIndexId(touch,finger.id) != -1) { + if (SDL_GetFingerIndexId(touch,finger->id) != -1) { SDL_SetError("Finger ID already in use"); } @@ -282,14 +284,14 @@ SDL_AddFinger(SDL_Touch* touch,SDL_Finger finger) SDL_OutOfMemory(); return -1; } - *(touch->fingers[index]) = finger; + *(touch->fingers[index]) = *finger; touch->num_fingers++; return index; } int -SDL_DelFinger(SDL_Touch* touch,long fingerid) +SDL_DelFinger(SDL_Touch* touch,SDL_FingerID fingerid) { int index = SDL_GetFingerIndexId(touch,fingerid); SDL_Finger* finger = SDL_GetFinger(touch,fingerid); @@ -307,7 +309,8 @@ SDL_DelFinger(SDL_Touch* touch,long fingerid) int -SDL_SendFingerDown(long id, long fingerid, SDL_bool down, float x, float y, float pressure) +SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down, + float xin, float yin, float pressurein) { int posted; SDL_Touch* touch = SDL_GetTouch(id); @@ -315,11 +318,15 @@ SDL_SendFingerDown(long id, long fingerid, SDL_bool down, float x, float y, floa if(!touch) { return SDL_TouchNotFoundError(id); } - + //scale to Integer coordinates + Uint16 x = (xin+touch->x_min)*(touch->xres)/(touch->native_xres); + Uint16 y = (yin+touch->y_min)*(touch->yres)/(touch->native_yres); + Uint16 pressure = (yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres); if(down) { SDL_Finger *finger = SDL_GetFinger(touch,fingerid); + SDL_Finger nf; if(finger == NULL) { - SDL_Finger nf; + nf.id = fingerid; nf.x = x; nf.y = y; @@ -330,11 +337,11 @@ SDL_SendFingerDown(long id, long fingerid, SDL_bool down, float x, float y, floa nf.last_y = y; nf.last_pressure = pressure; nf.down = SDL_FALSE; - SDL_AddFinger(touch,nf); + SDL_AddFinger(touch,&nf); finger = &nf; } else if(finger->down) return 0; - if(x < 0 || y < 0) return 0; //should defer if only a partial input + if(xin < touch->x_min || yin < touch->y_min) return 0; //should defer if only a partial input posted = 0; if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) { SDL_Event event; @@ -367,8 +374,8 @@ SDL_SendFingerDown(long id, long fingerid, SDL_bool down, float x, float y, floa } int -SDL_SendTouchMotion(long id, long fingerid, int relative, - float x, float y, float pressure) +SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative, + float xin, float yin, float pressurein) { int index = SDL_GetTouchIndexId(id); SDL_Touch *touch = SDL_GetTouch(id); @@ -381,6 +388,12 @@ SDL_SendTouchMotion(long id, long fingerid, int relative, if (!touch) { return SDL_TouchNotFoundError(id); } + + //scale to Integer coordinates + Uint16 x = (xin+touch->x_min)*(touch->xres)/(touch->native_xres); + Uint16 y = (yin+touch->y_min)*(touch->yres)/(touch->native_yres); + Uint16 pressure = (yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres); + printf("(%f,%f) --> (%i,%i)",xin,yin,x,y); if(touch->flush_motion) { return 0; } @@ -395,9 +408,9 @@ SDL_SendTouchMotion(long id, long fingerid, int relative, x = (finger->last_x + x); y = (finger->last_y + y); } else { - if(x < 0) x = finger->last_x; /*If movement is only in one axis,*/ - if(y < 0) y = finger->last_y; /*The other is marked as -1*/ - if(pressure < 0) pressure = finger->last_pressure; + if(xin < touch->x_min) x = finger->last_x; /*If movement is only in one axis,*/ + if(yin < touch->y_min) y = finger->last_y; /*The other is marked as -1*/ + if(pressurein < touch->pressure_min) pressure = finger->last_pressure; xrel = x - finger->last_x; yrel = y - finger->last_y; } @@ -448,6 +461,7 @@ SDL_SendTouchMotion(long id, long fingerid, int relative, event.tfinger.fingerId = fingerid; event.tfinger.x = x; event.tfinger.y = y; + event.tfinger.pressure = pressure; event.tfinger.state = touch->buttonstate; event.tfinger.windowID = touch->focus ? touch->focus->id : 0; @@ -460,7 +474,7 @@ SDL_SendTouchMotion(long id, long fingerid, int relative, } } int -SDL_SendTouchButton(long id, Uint8 state, Uint8 button) +SDL_SendTouchButton(SDL_TouchID id, Uint8 state, Uint8 button) { SDL_Touch *touch = SDL_GetTouch(id); int posted; @@ -509,7 +523,7 @@ SDL_SendTouchButton(long id, Uint8 state, Uint8 button) } char * -SDL_GetTouchName(long id) +SDL_GetTouchName(SDL_TouchID id) { SDL_Touch *touch = SDL_GetTouch(id); if (!touch) { @@ -518,7 +532,7 @@ SDL_GetTouchName(long id) return touch->name; } -int SDL_TouchNotFoundError(long id) { +int SDL_TouchNotFoundError(SDL_TouchID id) { printf("ERROR: Cannot send touch on non-existent device with id: %li make sure SDL_AddTouch has been called\n",id); printf("ERROR: There are %i touches installed with Id's:\n",SDL_num_touch); int i; diff --git a/src/events/SDL_touch_c.h b/src/events/SDL_touch_c.h index db07bbe84..cc97def78 100644 --- a/src/events/SDL_touch_c.h +++ b/src/events/SDL_touch_c.h @@ -34,13 +34,13 @@ extern int SDL_TouchInit(void); extern SDL_Touch *SDL_GetTouchIndex(int index); /* Get the touch with id = id */ -extern SDL_Touch *SDL_GetTouch(long id); +extern SDL_Touch *SDL_GetTouch(SDL_TouchID id); /*Get the finger at an index */ extern SDL_Finger *SDL_GetFingerIndex(SDL_Touch *touch, int index); /* Get the finger with id = id */ -extern SDL_Finger *SDL_GetFinger(SDL_Touch *touch,long id); +extern SDL_Finger *SDL_GetFinger(SDL_Touch *touch,SDL_FingerID id); /* Add a touch, possibly reattaching at a particular index (or -1), @@ -49,30 +49,30 @@ extern int SDL_AddTouch(const SDL_Touch * touch, char *name); /* Remove a touch at an index, clearing the slot for later */ -extern void SDL_DelTouch(long id); +extern void SDL_DelTouch(SDL_TouchID id); /* Set the touch focus window */ -extern void SDL_SetTouchFocus(long id, SDL_Window * window); +extern void SDL_SetTouchFocus(SDL_TouchID id, SDL_Window * window); /* Send a touch motion event for a touch */ -extern int SDL_SendTouchMotion(long id, long fingerid, +extern int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative, float x, float y, float z); /* Send a touch down/up event for a touch */ -extern int SDL_SendFingerDown(long id, long fingerid, SDL_bool down, - float x, float y, float pressure); +extern int SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid, + SDL_bool down, float x, float y, float pressure); /* Send a touch button event for a touch */ -extern int SDL_SendTouchButton(long id, Uint8 state, Uint8 button); +extern int SDL_SendTouchButton(SDL_TouchID id, Uint8 state, Uint8 button); /* Shutdown the touch subsystem */ extern void SDL_TouchQuit(void); /* Get the index of a touch device */ -extern int SDL_GetTouchIndexId(long id); +extern int SDL_GetTouchIndexId(SDL_TouchID id); /* Print a debug message for a nonexistent touch */ -extern int SDL_TouchNotFoundError(long id); +extern int SDL_TouchNotFoundError(SDL_TouchID id); #endif /* _SDL_touch_c_h */ diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 109bbc9fe..aa93e712e 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -304,13 +304,13 @@ - (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event touch.id = touchId; touch.x_min = 0; touch.x_max = 1; - touch.xres = touch.x_max - touch.x_min; + touch.native_xres = touch.x_max - touch.x_min; touch.y_min = 0; touch.y_max = 1; - touch.yres = touch.y_max - touch.y_min; + touch.native_yres = touch.y_max - touch.y_min; touch.pressure_min = 0; touch.pressure_max = 1; - touch.pressureres = touch.pressure_max - touch.pressure_min; + touch.native_pressureres = touch.pressure_max - touch.pressure_min; if (SDL_AddTouch(&touch, "") < 0) { continue; diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index 2ace2fd00..74045359b 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -58,13 +58,13 @@ - (id)initWithFrame:(CGRect)frame { touch.x_min = 0; touch.x_max = frame.size.width; - touch.xres = touch.x_max - touch.x_min; + touch.native_xres = touch.x_max - touch.x_min; touch.y_min = 0; touch.y_max = frame.size.height; - touch.yres = touch.y_max - touch.y_min; + touch.native_yres = touch.y_max - touch.y_min; touch.pressure_min = 0; touch.pressure_max = 1; - touch.pressureres = touch.pressure_max - touch.pressure_min; + touch.native_pressureres = touch.pressure_max - touch.pressure_min; touchId = SDL_AddTouch(&touch, "IPHONE SCREEN"); diff --git a/src/video/x11/SDL_eventtouch.c b/src/video/x11/SDL_eventtouch.c index a12152a7c..ce2edc8a7 100644 --- a/src/video/x11/SDL_eventtouch.c +++ b/src/video/x11/SDL_eventtouch.c @@ -56,9 +56,6 @@ X11_InitTouch(_THIS) touch.pressure_max = 0; touch.pressure_min = 0; touch.id = event; - - - touch.driverdata = SDL_malloc(sizeof(EventTouchData)); @@ -76,19 +73,17 @@ X11_InitTouch(_THIS) ioctl(data->eventStream,EVIOCGABS(0),abs); touch.x_min = abs[1]; touch.x_max = abs[2]; - touch.xres = touch.x_max - touch.x_min; + touch.native_xres = touch.x_max - touch.x_min; ioctl(data->eventStream,EVIOCGABS(ABS_Y),abs); touch.y_min = abs[1]; touch.y_max = abs[2]; - touch.yres = touch.y_max - touch.y_min; + touch.native_yres = touch.y_max - touch.y_min; ioctl(data->eventStream,EVIOCGABS(ABS_PRESSURE),abs); touch.pressure_min = abs[1]; touch.pressure_max = abs[2]; - touch.pressureres = touch.pressure_max - touch.pressure_min; - + touch.native_pressureres = touch.pressure_max - touch.pressure_min; SDL_AddTouch(&touch, tstr); - } vendor = -1; product = -1; diff --git a/touchTest/Iphone Test/touchTestIPhone2/touchTestIPhone/main.c b/touchTest/Iphone Test/touchTestIPhone2/touchTestIPhone/main.c index ff1b60c5c..0025076ff 100644 --- a/touchTest/Iphone Test/touchTestIPhone2/touchTestIPhone/main.c +++ b/touchTest/Iphone Test/touchTestIPhone2/touchTestIPhone/main.c @@ -335,7 +335,7 @@ int main(int argc, char* argv[]) case SDL_MOUSEMOTION: mousx = event.motion.x; mousy = event.motion.y; - break; + break; case SDL_MOUSEBUTTONDOWN: bstatus |= (1<<(event.button.button-1)); break; @@ -344,7 +344,7 @@ int main(int argc, char* argv[]) break; case SDL_FINGERMOTION: ; - printf("Finger: %li,x: %f, y: %f\n",event.tfinger.fingerId, + printf("Finger: %li,x: %i, y: %i\n",event.tfinger.fingerId, event.tfinger.x,event.tfinger.y); SDL_Touch* inTouch = SDL_GetTouch(event.tfinger.touchId); //SDL_Finger* inFinger = SDL_GetFinger(inTouch,event.tfinger.fingerId); @@ -353,10 +353,8 @@ int main(int argc, char* argv[]) break; if(i == MAXFINGERS) break; if(inTouch > 0) { - finger[i].p.x = ((float)event.tfinger.x)/ - inTouch->xres; - finger[i].p.y = ((float)event.tfinger.y)/ - inTouch->yres; + finger[i].p.x = ((float)event.tfinger.x)/inTouch->xres; + finger[i].p.y = ((float)event.tfinger.y)/inTouch->yres; finger[i].pressure = ((float)event.tfinger.pressure)/inTouch->pressureres; @@ -372,7 +370,7 @@ int main(int argc, char* argv[]) break; case SDL_FINGERDOWN: - printf("Finger: %li down - x: %f, y: %f\n",event.tfinger.fingerId, + printf("Finger: %li down - x: %i, y: %i\n",event.tfinger.fingerId, event.tfinger.x,event.tfinger.y); for(i = 0;i