Updated touch API
authorSam Lantinga <slouken@libsdl.org>
Sun, 03 Mar 2013 01:01:33 -0800
changeset 6951 7833f01322b3
parent 6950 1ddb72193079
child 6952 d2e309e7f77c
Updated touch API * Normalized touch coordinates as floats in the 0...1 range * Removed unused touchpad concepts from the API * Added API functions to get active touch devices and current finger state
include/SDL_events.h
include/SDL_touch.h
src/events/SDL_gesture.c
src/events/SDL_gesture_c.h
src/events/SDL_touch.c
src/events/SDL_touch_c.h
src/video/android/SDL_androidtouch.c
src/video/cocoa/SDL_cocoawindow.m
src/video/uikit/SDL_uikitview.m
src/video/windows/SDL_windowsevents.c
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11touch.c
src/video/x11/SDL_x11touch.h
src/video/x11/SDL_x11xinput2.c
test/testgesture.c
--- a/include/SDL_events.h	Sat Mar 02 20:44:16 2013 -0800
+++ b/include/SDL_events.h	Sun Mar 03 01:01:33 2013 -0800
@@ -105,8 +105,6 @@
     SDL_FINGERDOWN      = 0x700,
     SDL_FINGERUP,
     SDL_FINGERMOTION,
-    SDL_TOUCHBUTTONDOWN,
-    SDL_TOUCHBUTTONUP,    
 
     /* Gesture events */
     SDL_DOLLARGESTURE   = 0x800,
@@ -367,75 +365,50 @@
 
 
 /**
- *  \brief Touch finger motion/finger event structure (event.tfinger.*)
+ *  \brief Touch finger event structure (event.tfinger.*)
  */
 typedef struct SDL_TouchFingerEvent
 {
     Uint32 type;        /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */
     Uint32 timestamp;
-    Uint32 windowID;    /**< The window with mouse focus, if any */
     SDL_TouchID touchId; /**< The touch device id */
     SDL_FingerID fingerId;
-    Uint8 state;        /**< The current button state */
-    Uint8 padding1;
-    Uint8 padding2;
-    Uint8 padding3;
-    Uint16 x;
-    Uint16 y;
-    Sint16 dx;
-    Sint16 dy;
-    Uint16 pressure;
+    float x;            /**< Normalized in the range 0...1 */
+    float y;            /**< Normalized in the range 0...1 */
+    float dx;           /**< Normalized in the range 0...1 */
+    float dy;           /**< Normalized in the range 0...1 */
+    float pressure;     /**< Normalized in the range 0...1 */
 } SDL_TouchFingerEvent;
 
 
 /**
- *  \brief Touch finger motion/finger event structure (event.tbutton.*)
- */
-typedef struct SDL_TouchButtonEvent
-{
-    Uint32 type;        /**< ::SDL_TOUCHBUTTONUP OR SDL_TOUCHBUTTONDOWN */
-    Uint32 timestamp;
-    Uint32 windowID;    /**< The window with mouse focus, if any */
-    SDL_TouchID touchId;        /**< The touch device index */
-    Uint8 state;        /**< The current button state */
-    Uint8 button;        /**< The button changing state */
-    Uint8 padding1;
-    Uint8 padding2;
-} SDL_TouchButtonEvent;
-
-
-/**
  *  \brief Multiple Finger Gesture Event (event.mgesture.*)
  */
 typedef struct SDL_MultiGestureEvent
 {
     Uint32 type;        /**< ::SDL_MULTIGESTURE */
     Uint32 timestamp;
-    Uint32 windowID;    /**< The window with mouse focus, if any */
-    SDL_TouchID 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? */
+    float x;
     float y;  
     Uint16 numFingers;
     Uint16 padding;
 } SDL_MultiGestureEvent;
 
+
 /* (event.dgesture.*) */
 typedef struct SDL_DollarGestureEvent
 {
     Uint32 type;        /**< ::SDL_DOLLARGESTURE */
     Uint32 timestamp;
-    Uint32 windowID;    /**< The window with mouse focus, if any */
-    SDL_TouchID touchId;        /**< The touch device index */
+    SDL_TouchID touchId; /**< The touch device id */
     SDL_GestureID gestureId;
     Uint32 numFingers;
     float error;
-  /*
-    //TODO: Enable to give location?
-    float x;  //currently 0...1. Change to screen coords?
-    float y;  
-  */
+    float x;            /**< Normalized center of gesture */
+    float y;            /**< Normalized center of gesture */
 } SDL_DollarGestureEvent;
 
 
@@ -518,9 +491,8 @@
     SDL_UserEvent user;             /**< Custom event data */
     SDL_SysWMEvent syswm;           /**< System dependent window event data */
     SDL_TouchFingerEvent tfinger;   /**< Touch finger event data */
-    SDL_TouchButtonEvent tbutton;   /**< Touch button event data */
-    SDL_MultiGestureEvent mgesture; /**< Multi Finger Gesture data */
-    SDL_DollarGestureEvent dgesture; /**< Multi Finger Gesture data */
+    SDL_MultiGestureEvent mgesture; /**< Gesture event data */
+    SDL_DollarGestureEvent dgesture; /**< Gesture event data */
     SDL_DropEvent drop;             /**< Drag and drop event data */
 
     /* This is necessary for ABI compatibility between Visual C++ and GCC
--- a/include/SDL_touch.h	Sat Mar 02 20:44:16 2013 -0800
+++ b/include/SDL_touch.h	Sun Mar 03 01:01:33 2013 -0800
@@ -46,46 +46,11 @@
 typedef struct SDL_Finger
 {
     SDL_FingerID id;
-    Uint16 x;
-    Uint16 y;
-    Uint16 pressure;
-    Uint16 xdelta;
-    Uint16 ydelta;
-    Uint16 last_x, last_y,last_pressure;  /* the last reported coordinates */
-    SDL_bool down;
+    float x;
+    float y;
+    float pressure;
 } SDL_Finger;
 
-typedef struct SDL_Touch
-{
-  /* Free the touch when it's time */
-  void (*FreeTouch) (struct SDL_Touch * touch);
-  
-  /* data common for tablets */
-  float pressure_max, pressure_min;
-  float x_max,x_min;
-  float y_max,y_min;
-  Uint16 xres,yres,pressureres;
-  float native_xres,native_yres,native_pressureres;
-  float tilt_x;                 /* for future use */
-  float tilt_y;                 /* for future use */
-  float rotation;               /* for future use */
-  
-  /* Data common to all touch */
-  SDL_TouchID id;
-  SDL_Window *focus;
-  
-  char *name;
-  Uint8 buttonstate;
-  SDL_bool relative_mode;
-  SDL_bool flush_motion;
-
-  int num_fingers;
-  int max_fingers;
-  SDL_Finger** fingers;
-    
-  void *driverdata;
-} SDL_Touch;
-
 /* Used as the device ID for mouse events simulated with touch input */
 #define SDL_TOUCH_MOUSEID ((Uint32)-1)
 
@@ -93,14 +58,24 @@
 /* Function prototypes */
 
 /**
- *  \brief Get the touch object with the given id.
+ *  \brief Get the number of registered touch devices.
  */
-extern DECLSPEC SDL_Touch* SDLCALL SDL_GetTouch(SDL_TouchID id);
+extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices();
 
 /**
- *  \brief Get the finger object of the given touch, with the given id.
+ *  \brief Get the touch ID with the given index, or 0 if the index is invalid.
+ */
+extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index);
+
+/**
+ *  \brief Get the number of active fingers for a given touch device.
  */
-extern DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, SDL_FingerID id);
+extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID);
+
+/**
+ *  \brief Get the finger object of the given touch, with the given index.
+ */
+extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index);
 
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
--- a/src/events/SDL_gesture.c	Sat Mar 02 20:44:16 2013 -0800
+++ b/src/events/SDL_gesture.c	Sun Mar 03 01:01:33 2013 -0800
@@ -64,7 +64,6 @@
 
 typedef struct {
     SDL_TouchID id;
-    SDL_FloatPoint res;
     SDL_FloatPoint centroid;
     SDL_DollarPath dollarPath;
     Uint16 numDownFingers;
@@ -410,7 +409,7 @@
     return bestDiff;
 }
 
-int SDL_GestureAddTouch(SDL_Touch* touch)
+int SDL_GestureAddTouch(SDL_TouchID touchId)
 {
     SDL_GestureTouch *gestureTouch = (SDL_GestureTouch *)SDL_realloc(SDL_gestureTouch,
                                                                      (SDL_numGestureTouches + 1) *
@@ -423,12 +422,8 @@
 
     SDL_gestureTouch = gestureTouch;
 
-    SDL_gestureTouch[SDL_numGestureTouches].res.x = touch->xres;
-    SDL_gestureTouch[SDL_numGestureTouches].res.y = touch->yres;
     SDL_gestureTouch[SDL_numGestureTouches].numDownFingers = 0;
-
-    SDL_gestureTouch[SDL_numGestureTouches].res.x = touch->xres;
-    SDL_gestureTouch[SDL_numGestureTouches].id = touch->id;
+    SDL_gestureTouch[SDL_numGestureTouches].id = touchId;
 
     SDL_gestureTouch[SDL_numGestureTouches].numDollarTemplates = 0;
 
@@ -468,11 +463,8 @@
     SDL_Event event;
     event.dgesture.type = SDL_DOLLARGESTURE;
     event.dgesture.touchId = touch->id;
-    /*
-    //TODO: Add this to give location of gesture?
     event.mgesture.x = touch->centroid.x;
     event.mgesture.y = touch->centroid.y;
-    */
     event.dgesture.gestureId = gestureId;
     event.dgesture.error = error;
     //A finger came up to trigger this event.
@@ -513,14 +505,8 @@
         //Shouldn't be possible
         if (inTouch == NULL) return;
 
-        //printf("@ (%i,%i) with res: (%i,%i)\n",(int)event->tfinger.x,
-        //           (int)event->tfinger.y,
-        //   (int)inTouch->res.x,(int)inTouch->res.y);
-
-
-        x = ((float)event->tfinger.x)/(float)inTouch->res.x;
-        y = ((float)event->tfinger.y)/(float)inTouch->res.y;
-
+        x = event->tfinger.x;
+        y = event->tfinger.y;
 
         //Finger Up
         if (event->type == SDL_FINGERUP) {
@@ -569,9 +555,8 @@
             }
         }
         else if (event->type == SDL_FINGERMOTION) {
-            float dx = ((float)event->tfinger.dx)/(float)inTouch->res.x;
-            float dy = ((float)event->tfinger.dy)/(float)inTouch->res.y;
-            //printf("dx,dy: (%f,%f)\n",dx,dy);
+            float dx = event->tfinger.dx;
+            float dy = event->tfinger.dy;
 #ifdef ENABLE_DOLLAR
             SDL_DollarPath* path = &inTouch->dollarPath;
             if (path->numPoints < MAXPATHSIZE) {
--- a/src/events/SDL_gesture_c.h	Sat Mar 02 20:44:16 2013 -0800
+++ b/src/events/SDL_gesture_c.h	Sun Mar 03 01:01:33 2013 -0800
@@ -23,12 +23,12 @@
 #ifndef _SDL_gesture_c_h
 #define _SDL_gesture_c_h
 
+extern int SDL_GestureAddTouch(SDL_TouchID touchId);
+
 extern void SDL_GestureProcessEvent(SDL_Event* event);
 
 extern int SDL_RecordGesture(SDL_TouchID touchId);
 
-extern int SDL_GestureAddTouch(SDL_Touch* touch);
-
 #endif /* _SDL_gesture_c_h */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/events/SDL_touch.c	Sat Mar 02 20:44:16 2013 -0800
+++ b/src/events/SDL_touch.c	Sun Mar 03 01:01:33 2013 -0800
@@ -22,72 +22,46 @@
 
 /* General touch handling code for SDL */
 
+#include "SDL_assert.h"
 #include "SDL_events.h"
 #include "SDL_events_c.h"
-#include "../video/SDL_sysvideo.h"
-
-#include <stdio.h>
 
 
 static int SDL_num_touch = 0;
-static SDL_Touch **SDL_touchPads = NULL;
+static SDL_Touch **SDL_touchDevices = NULL;
 
 
 /* Public functions */
 int
 SDL_TouchInit(void)
 {
-  return (0);
+    return (0);
+}
+
+int
+SDL_GetNumTouchDevices()
+{
+    return SDL_num_touch;
 }
 
-SDL_Touch *
-SDL_GetTouch(SDL_TouchID id)
-{
-    int index = SDL_GetTouchIndexId(id);
-    if (index < 0 || index >= SDL_num_touch) {
-        return NULL;
-    }
-    return SDL_touchPads[index];
-}
-
-SDL_Touch *
-SDL_GetTouchIndex(int index)
+SDL_TouchID
+SDL_GetTouchDevice(int index)
 {
     if (index < 0 || index >= SDL_num_touch) {
-        return NULL;
+        SDL_SetError("Unknown touch device");
+        return 0;
     }
-    return SDL_touchPads[index];
+    return SDL_touchDevices[index]->id;
 }
 
 static int
-SDL_GetFingerIndexId(SDL_Touch* touch,SDL_FingerID fingerid)
-{
-    int i;
-    for(i = 0;i < touch->num_fingers;i++)
-        if(touch->fingers[i]->id == fingerid)
-            return i;
-    return -1;
-}
-
-
-SDL_Finger *
-SDL_GetFinger(SDL_Touch* touch,SDL_FingerID id)
-{
-    int index = SDL_GetFingerIndexId(touch,id);
-    if(index < 0 || index >= touch->num_fingers)
-        return NULL;
-    return touch->fingers[index];
-}
-
-
-int
-SDL_GetTouchIndexId(SDL_TouchID id)
+SDL_GetTouchIndex(SDL_TouchID id)
 {
     int index;
     SDL_Touch *touch;
 
     for (index = 0; index < SDL_num_touch; ++index) {
-        touch = SDL_touchPads[index];
+        touch = SDL_touchDevices[index];
         if (touch->id == id) {
             return index;
         }
@@ -95,78 +69,284 @@
     return -1;
 }
 
-int
-SDL_AddTouch(const SDL_Touch * touch, char *name)
+SDL_Touch *
+SDL_GetTouch(SDL_TouchID id)
 {
-    SDL_Touch **touchPads;
+    int index = SDL_GetTouchIndex(id);
+    if (index < 0 || index >= SDL_num_touch) {
+        SDL_SetError("Unknown touch device");
+        return NULL;
+    }
+    return SDL_touchDevices[index];
+}
+
+static int
+SDL_GetFingerIndex(const SDL_Touch * touch, SDL_FingerID fingerid)
+{
     int index;
-    size_t length;
+    for (index = 0; index < touch->num_fingers; ++index) {
+        if (touch->fingers[index]->id == fingerid) {
+            return index;
+        }
+    }
+    return -1;
+}
+
+SDL_Finger *
+SDL_GetFinger(const SDL_Touch * touch, SDL_FingerID id)
+{
+    int index = SDL_GetFingerIndex(touch, id);
+    if (index < 0 || index >= touch->num_fingers) {
+        return NULL;
+    }
+    return touch->fingers[index];
+}
 
-    if (SDL_GetTouchIndexId(touch->id) != -1) {
-        SDL_SetError("Touch ID already in use");
+int
+SDL_GetNumTouchFingers(SDL_TouchID touchID)
+{
+    SDL_Touch *touch = SDL_GetTouch(touchID);
+    if (touch) {
+        return touch->num_fingers;
+    }
+    return 0;
+}
+
+SDL_Finger *
+SDL_GetTouchFinger(SDL_TouchID touchID, int index)
+{
+    SDL_Touch *touch = SDL_GetTouch(touchID);
+    if (!touch) {
+        return NULL;
+    }
+    if (index < 0 || index >= touch->num_fingers) {
+        SDL_SetError("Unknown touch finger");
+        return NULL;
+    }
+    return touch->fingers[index];
+}
+
+int
+SDL_AddTouch(SDL_TouchID touchID, const char *name)
+{
+    SDL_Touch **touchDevices;
+    int index;
+
+    index = SDL_GetTouchIndex(touchID);
+    if (index >= 0) {
+        return index;
     }
 
     /* Add the touch to the list of touch */
-    touchPads = (SDL_Touch **) SDL_realloc(SDL_touchPads,
-                                      (SDL_num_touch + 1) * sizeof(*touch));
-    if (!touchPads) {
+    touchDevices = (SDL_Touch **) SDL_realloc(SDL_touchDevices,
+                                      (SDL_num_touch + 1) * sizeof(*touchDevices));
+    if (!touchDevices) {
+        SDL_OutOfMemory();
+        return -1;
+    }
+
+    SDL_touchDevices = touchDevices;
+    index = SDL_num_touch++;
+
+    SDL_touchDevices[index] = (SDL_Touch *) SDL_malloc(sizeof(*SDL_touchDevices[index]));
+    if (!SDL_touchDevices[index]) {
         SDL_OutOfMemory();
         return -1;
     }
 
-    SDL_touchPads = touchPads;
-    index = SDL_num_touch++;
+    /* we're setting the touch properties */
+    SDL_touchDevices[index]->id = touchID;
+    SDL_touchDevices[index]->num_fingers = 0;
+    SDL_touchDevices[index]->max_fingers = 0;
+    SDL_touchDevices[index]->fingers = NULL;
+
+    /* Record this touch device for gestures */
+    /* We could do this on the fly in the gesture code if we wanted */
+    SDL_GestureAddTouch(touchID);
+
+    return index;
+}
+
+static int 
+SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float pressure)
+{
+    SDL_Finger *finger;
+
+    if (touch->num_fingers == touch->max_fingers) {
+        SDL_Finger **new_fingers;
+        new_fingers = (SDL_Finger **)SDL_realloc(touch->fingers, (touch->max_fingers+1)*sizeof(*touch->fingers));
+        if (!new_fingers) {
+            SDL_OutOfMemory();
+            return -1;
+        }
+        touch->fingers = new_fingers;
+        touch->fingers[touch->max_fingers] = (SDL_Finger *)SDL_malloc(sizeof(*finger));
+        if (!touch->fingers[touch->max_fingers]) {
+            SDL_OutOfMemory();
+            return -1;
+        }
+        touch->max_fingers++;
+    }
 
-    SDL_touchPads[index] = (SDL_Touch *) SDL_malloc(sizeof(*SDL_touchPads[index]));
-    if (!SDL_touchPads[index]) {
-        SDL_OutOfMemory();
+    finger = touch->fingers[touch->num_fingers++];
+    finger->id = fingerid;
+    finger->x = x;
+    finger->y = y;
+    finger->pressure = pressure;
+    return 0;
+}
+
+static int
+SDL_DelFinger(SDL_Touch* touch, SDL_FingerID fingerid)
+{
+    SDL_Finger *temp;
+
+    int index = SDL_GetFingerIndex(touch, fingerid);
+    if (index < 0) {
+        return -1;
+    }
+
+    touch->num_fingers--;
+    temp = touch->fingers[index];
+    touch->fingers[index] = touch->fingers[touch->num_fingers];
+    touch->fingers[touch->num_fingers] = temp;
+    return 0;
+}
+
+int
+SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid,
+              SDL_bool down, float x, float y, float pressure)
+{
+    int posted;
+    SDL_Finger *finger;
+
+    SDL_Touch* touch = SDL_GetTouch(id);
+    if (!touch) {
         return -1;
     }
-    SDL_memcpy(SDL_touchPads[index], touch, sizeof(*touch));
+
+    finger = SDL_GetFinger(touch, fingerid);
+    if (down) {
+        if (finger) {
+            /* This finger is already down */
+            return 0;
+        }
+
+        if (SDL_AddFinger(touch, fingerid, x, y, pressure) < 0) {
+            return 0;
+        }
 
-    /* we're setting the touch properties */
-    length = SDL_strlen(name);
-    SDL_touchPads[index]->focus = 0;
-    SDL_touchPads[index]->name = SDL_malloc((length + 2) * sizeof(char));
-    SDL_strlcpy(SDL_touchPads[index]->name, name, length + 1);   
+        posted = 0;
+        if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) {
+            SDL_Event event;
+            event.tfinger.type = SDL_FINGERDOWN;
+            event.tfinger.touchId = id;
+            event.tfinger.fingerId = fingerid;
+            event.tfinger.x = x;
+            event.tfinger.y = y;
+            event.tfinger.dx = 0;
+            event.tfinger.dy = 0;
+            event.tfinger.pressure = pressure;
+            posted = (SDL_PushEvent(&event) > 0);
+        }
+    } else {
+        if (!finger) {
+            /* This finger is already up */
+            return 0;
+        }
+
+        posted = 0;
+        if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
+            SDL_Event event;
+            event.tfinger.type = SDL_FINGERUP;
+            event.tfinger.touchId =  id;
+            event.tfinger.fingerId = fingerid;
+            /* I don't trust the coordinates passed on fingerUp */
+            event.tfinger.x = finger->x; 
+            event.tfinger.y = finger->y;
+            event.tfinger.dx = 0;
+            event.tfinger.dy = 0;
+            event.tfinger.pressure = pressure;
+            posted = (SDL_PushEvent(&event) > 0);
+        }
+
+        SDL_DelFinger(touch, fingerid);
+    }
+    return posted;
+}
 
-    SDL_touchPads[index]->num_fingers = 0;
-    SDL_touchPads[index]->max_fingers = 1;
-    SDL_touchPads[index]->fingers = (SDL_Finger **) SDL_malloc(sizeof(SDL_Finger*));
-    SDL_touchPads[index]->fingers[0] = NULL;
-    SDL_touchPads[index]->buttonstate = 0;
-    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));
-    SDL_touchPads[index]->pressureres = (1<<(16-1));
-    //Do I want this here? Probably
-    SDL_GestureAddTouch(SDL_touchPads[index]);
+int
+SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
+                    float x, float y, float pressure)
+{
+    SDL_Touch *touch;
+    SDL_Finger *finger;
+    int posted;
+    float xrel, yrel, prel;
+
+    touch = SDL_GetTouch(id);
+    if (!touch) {
+        return -1;
+    }
+
+    finger = SDL_GetFinger(touch,fingerid);
+    if (!finger) {
+        return SDL_SendTouch(id, fingerid, SDL_TRUE, x, y, pressure);        
+    }
+
+    xrel = x - finger->x;
+    yrel = y - finger->y;
+    prel = pressure - finger->pressure;
 
-    return index;
+    /* Drop events that don't change state */
+    if (!xrel && !yrel && !prel) {
+#if 0
+        printf("Touch event didn't change state - dropped!\n");
+#endif
+        return 0;
+    }
+
+    /* Update internal touch coordinates */
+    finger->x = x;
+    finger->y = y;
+    finger->pressure = pressure;
+        
+    /* Post the event, if desired */
+    posted = 0;
+    if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
+        SDL_Event event;
+        event.tfinger.type = SDL_FINGERMOTION;
+        event.tfinger.touchId = id;
+        event.tfinger.fingerId = fingerid;
+        event.tfinger.x = x;
+        event.tfinger.y = y;
+        event.tfinger.dx = xrel;
+        event.tfinger.dy = yrel;            
+        event.tfinger.pressure = pressure;
+        posted = (SDL_PushEvent(&event) > 0);
+    }
+    return posted;
 }
 
 void
 SDL_DelTouch(SDL_TouchID id)
 {
-    int index = SDL_GetTouchIndexId(id);
+    int i;
+    int index = SDL_GetTouchIndex(id);
     SDL_Touch *touch = SDL_GetTouch(id);
 
     if (!touch) {
         return;
     }
 
-    
-    SDL_free(touch->name);
- 
-    if (touch->FreeTouch) {
-        touch->FreeTouch(touch);
+    for (i = 0; i < touch->max_fingers; ++i) {
+        SDL_free(touch->fingers[i]);
     }
+    SDL_free(touch->fingers);
     SDL_free(touch);
 
     SDL_num_touch--;
-    SDL_touchPads[index] = SDL_touchPads[SDL_num_touch];
+    SDL_touchDevices[index] = SDL_touchDevices[SDL_num_touch];
 }
 
 void
@@ -174,400 +354,15 @@
 {
     int i;
 
-    for (i = SDL_num_touch-1; i > 0 ; --i) {
-        SDL_DelTouch(i);
-    }
-    SDL_num_touch = 0;
-
-    if (SDL_touchPads) {
-        SDL_free(SDL_touchPads);
-        SDL_touchPads = NULL;
+    for (i = SDL_num_touch; i--; ) {
+        SDL_DelTouch(SDL_touchDevices[i]->id);
     }
-}
-
-int
-SDL_GetNumTouch(void)
-{
-    return SDL_num_touch;
-}
-
-SDL_Window *
-SDL_GetTouchFocusWindow(SDL_TouchID id)
-{
-    SDL_Touch *touch = SDL_GetTouch(id);
-
-    if (!touch) {
-        return 0;
-    }
-    return touch->focus;
-}
-
-void
-SDL_SetTouchFocus(SDL_TouchID id, SDL_Window * window)
-{
-    int index = SDL_GetTouchIndexId(id);
-    SDL_Touch *touch = SDL_GetTouch(id);
-    int i;
-    SDL_bool focus;
+    SDL_assert(SDL_num_touch == 0);
 
-    if (!touch || (touch->focus == window)) {
-        return;
-    }
-
-    /* See if the current window has lost focus */
-    if (touch->focus) {
-        focus = SDL_FALSE;
-        for (i = 0; i < SDL_num_touch; ++i) {
-            SDL_Touch *check;
-            if (i != index) {
-                check = SDL_touchPads[i];
-                if (check && check->focus == touch->focus) {
-                    focus = SDL_TRUE;
-                    break;
-                }
-            }
-        }
-        if (!focus) {
-            SDL_SendWindowEvent(touch->focus, SDL_WINDOWEVENT_LEAVE, 0, 0);
-        }
-    }
-
-    touch->focus = window;
-
-    if (touch->focus) {
-        focus = SDL_FALSE;
-        for (i = 0; i < SDL_num_touch; ++i) {
-            SDL_Touch *check;
-            if (i != index) {
-                check = SDL_touchPads[i];
-                if (check && check->focus == touch->focus) {
-                    focus = SDL_TRUE;
-                    break;
-                }
-            }
-        }
-        if (!focus) {
-            SDL_SendWindowEvent(touch->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
-        }
+    if (SDL_touchDevices) {
+        SDL_free(SDL_touchDevices);
+        SDL_touchDevices = NULL;
     }
 }
 
-int 
-SDL_AddFinger(SDL_Touch* touch,SDL_Finger *finger)
-{
-    int index;
-    SDL_Finger **fingers;
-    //printf("Adding Finger...\n");
-    if (SDL_GetFingerIndexId(touch,finger->id) != -1) {
-        SDL_SetError("Finger ID already in use");
-        }
-
-    /* Add the touch to the list of touch */
-    if(touch->num_fingers  >= touch->max_fingers){
-                //printf("Making room for it!\n");
-                fingers = (SDL_Finger **) SDL_realloc(touch->fingers,
-                                                     (touch->num_fingers + 1) * sizeof(SDL_Finger *));
-                if (!fingers) {
-                        SDL_OutOfMemory();
-                        return -1;
-                } else {
-                        touch->max_fingers = touch->num_fingers+1;
-                        touch->fingers = fingers;
-                }
-        }
-
-    index = touch->num_fingers;
-    //printf("Max_Fingers: %i Index: %i\n",touch->max_fingers,index);
-
-    touch->fingers[index] = (SDL_Finger *) SDL_malloc(sizeof(SDL_Finger));
-    if (!touch->fingers[index]) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-    *(touch->fingers[index]) = *finger;
-    touch->num_fingers++;
-
-    return index;
-}
-
-int
-SDL_DelFinger(SDL_Touch* touch,SDL_FingerID fingerid)
-{
-    int index = SDL_GetFingerIndexId(touch,fingerid);
-    SDL_Finger* finger = SDL_GetFinger(touch,fingerid);
-
-    if (!finger) {
-        return -1;
-    }
- 
-
-    SDL_free(finger);
-    touch->num_fingers--;
-    touch->fingers[index] = touch->fingers[touch->num_fingers];
-    return 0;
-}
-
-
-int
-SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down, 
-                   float xin, float yin, float pressurein)
-{
-    int posted;
-        Uint16 x;
-        Uint16 y;
-        Uint16 pressure;
-        SDL_Finger *finger;
-
-    SDL_Touch* touch = SDL_GetTouch(id);
-
-    if(!touch) {
-      return SDL_TouchNotFoundError(id);
-    }
-
-    
-    //scale to Integer coordinates
-    x = (Uint16)((xin+touch->x_min)*(touch->xres)/(touch->native_xres));
-    y = (Uint16)((yin+touch->y_min)*(touch->yres)/(touch->native_yres));
-    pressure = (Uint16)((pressurein+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
-    
-    finger = SDL_GetFinger(touch,fingerid);
-    if(down) {
-        if(finger == NULL) {
-            SDL_Finger nf;
-            nf.id = fingerid;
-            nf.x = x;
-            nf.y = y;
-            nf.pressure = pressure;
-            nf.xdelta = 0;
-            nf.ydelta = 0;
-            nf.last_x = x;
-            nf.last_y = y;
-            nf.last_pressure = pressure;
-            nf.down = SDL_FALSE;
-            if(SDL_AddFinger(touch,&nf) < 0) return 0;
-            finger = SDL_GetFinger(touch,fingerid);
-        }
-        else if(finger->down) return 0;
-        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;
-            event.tfinger.type = SDL_FINGERDOWN;
-            event.tfinger.touchId = id;
-            event.tfinger.x = x;
-            event.tfinger.y = y;
-            event.tfinger.dx = 0;
-            event.tfinger.dy = 0;
-            event.tfinger.pressure = pressure;
-            event.tfinger.state = touch->buttonstate;
-            event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
-            event.tfinger.fingerId = fingerid;
-            posted = (SDL_PushEvent(&event) > 0);
-        }
-        if(posted) finger->down = SDL_TRUE;
-        return posted;
-    }
-    else {
-        if(finger == NULL) {
-            SDL_SetError("Finger not found.");
-            return 0;
-        }      
-        posted = 0;
-        if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
-            SDL_Event event;
-            event.tfinger.type = SDL_FINGERUP;
-            event.tfinger.touchId =  id;
-            event.tfinger.state = touch->buttonstate;
-            event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
-            event.tfinger.fingerId = fingerid;
-            //I don't trust the coordinates passed on fingerUp
-            event.tfinger.x = finger->x; 
-            event.tfinger.y = finger->y;
-            event.tfinger.dx = 0;
-            event.tfinger.dy = 0;
-            event.tfinger.pressure = pressure;
-
-            if(SDL_DelFinger(touch,fingerid) < 0) return 0;
-            posted = (SDL_PushEvent(&event) > 0);
-        }        
-        return posted;
-    }
-}
-
-int
-SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative, 
-                    float xin, float yin, float pressurein)
-{
-    SDL_Touch *touch;
-    SDL_Finger *finger;
-    int posted;
-    Sint16 xrel, yrel;
-    Uint16 x;
-    Uint16 y;
-    Uint16 pressure;
-    
-    touch = SDL_GetTouch(id);
-    if (!touch) {
-      return SDL_TouchNotFoundError(id);
-    }
-
-    //scale to Integer coordinates
-    x = (Uint16)((xin+touch->x_min)*(touch->xres)/(touch->native_xres));
-    y = (Uint16)((yin+touch->y_min)*(touch->yres)/(touch->native_yres));
-    pressure = (Uint16)((pressurein+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
-    if(touch->flush_motion) {
-        return 0;
-    }
-    
-    finger = SDL_GetFinger(touch,fingerid);
-    if(finger == NULL || !finger->down) {
-        return SDL_SendFingerDown(id,fingerid,SDL_TRUE,xin,yin,pressurein);        
-    } else {
-        /* the relative motion is calculated regarding the last position */
-        if (relative) {
-            xrel = x;
-            yrel = y;
-            x = (finger->last_x + x);
-            y = (finger->last_y + y);
-        } else {
-            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;
-            //printf("xrel,yrel (%i,%i)\n",(int)xrel,(int)yrel);
-        }
-        
-        /* Drop events that don't change state */
-        if (!xrel && !yrel) {
-#if 0
-            printf("Touch event didn't change state - dropped!\n");
-#endif
-            return 0;
-        }
-        
-        /* Update internal touch coordinates */
-        
-        finger->x = x;
-        finger->y = y;
-        
-        /*Should scale to window? Normalize? Maintain Aspect?*/
-        //SDL_GetWindowSize(touch->focus, &x_max, &y_max);
-        
-        /* make sure that the pointers find themselves inside the windows */
-        /* only check if touch->xmax is set ! */
-        /*
-          if (x_max && touch->x > x_max) {
-          touch->x = x_max;
-          } else if (touch->x < 0) {
-          touch->x = 0;
-          }
-          
-          if (y_max && touch->y > y_max) {
-          touch->y = y_max;
-          } else if (touch->y < 0) {
-          touch->y = 0;
-          }
-        */
-        finger->xdelta = xrel;
-        finger->ydelta = yrel;
-        finger->pressure = pressure;
-        
-        
-        
-        /* Post the event, if desired */
-        posted = 0;
-        if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
-            SDL_Event event;
-            event.tfinger.type = SDL_FINGERMOTION;
-            event.tfinger.touchId = id;
-            event.tfinger.fingerId = fingerid;
-            event.tfinger.x = x;
-            event.tfinger.y = y;
-            event.tfinger.dx = xrel;
-            event.tfinger.dy = yrel;            
-                
-            event.tfinger.pressure = pressure;
-            event.tfinger.state = touch->buttonstate;
-            event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
-            posted = (SDL_PushEvent(&event) > 0);
-        }
-        finger->last_x = finger->x;
-        finger->last_y = finger->y;
-        finger->last_pressure = finger->pressure;
-        return posted;
-    }
-}
-
-int
-SDL_SendTouchButton(SDL_TouchID id, Uint8 state, Uint8 button)
-{
-    SDL_Touch *touch;
-    int posted;
-    Uint32 type;
-
-    
-    touch = SDL_GetTouch(id);
-    if (!touch) {
-      return SDL_TouchNotFoundError(id);
-    }
-
-    /* Figure out which event to perform */
-    switch (state) {
-    case SDL_PRESSED:
-        if (touch->buttonstate & SDL_BUTTON(button)) {
-            /* Ignore this event, no state change */
-            return 0;
-        }
-        type = SDL_TOUCHBUTTONDOWN;
-        touch->buttonstate |= SDL_BUTTON(button);
-        break;
-    case SDL_RELEASED:
-        if (!(touch->buttonstate & SDL_BUTTON(button))) {
-            /* Ignore this event, no state change */
-            return 0;
-        }
-        type = SDL_TOUCHBUTTONUP;
-        touch->buttonstate &= ~SDL_BUTTON(button);
-        break;
-    default:
-        /* Invalid state -- bail */
-        return 0;
-    }
-
-    /* Post the event, if desired */
-    posted = 0;
-    if (SDL_GetEventState(type) == SDL_ENABLE) {
-        SDL_Event event;
-        event.type = type;
-        event.tbutton.touchId = touch->id;
-        event.tbutton.state = state;
-        event.tbutton.button = button;
-        event.tbutton.windowID = touch->focus ? touch->focus->id : 0;
-        posted = (SDL_PushEvent(&event) > 0);
-    }
-    return posted;
-}
-
-char *
-SDL_GetTouchName(SDL_TouchID id)
-{
-    SDL_Touch *touch = SDL_GetTouch(id);
-    if (!touch) {
-        return NULL;
-    }
-    return touch->name;
-}
-
-int SDL_TouchNotFoundError(SDL_TouchID id) {
-  //int i;
-  SDL_SetError("ERROR: Cannot send touch on non-existent device with id: %li make sure SDL_AddTouch has been called\n",id);
-#if 0
-  printf("ERROR: There are %i touches installed with Id's:\n",SDL_num_touch);
-  for(i=0;i < SDL_num_touch;i++) {
-    printf("ERROR: %li\n",SDL_touchPads[i]->id);
-  }
-#endif
-  return 0;
-}
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/events/SDL_touch_c.h	Sat Mar 02 20:44:16 2013 -0800
+++ b/src/events/SDL_touch_c.h	Sun Mar 03 01:01:33 2013 -0800
@@ -24,55 +24,38 @@
 #ifndef _SDL_touch_c_h
 #define _SDL_touch_c_h
 
+typedef struct SDL_Touch
+{
+    SDL_TouchID id;
+    int num_fingers;
+    int max_fingers;
+    SDL_Finger** fingers;
+} SDL_Touch;
 
 
 /* Initialize the touch subsystem */
 extern int SDL_TouchInit(void);
 
-/*Get the touch at an index */
-extern SDL_Touch *SDL_GetTouchIndex(int index);
-
-/* Get the touch with id = id */
+/* Add a touch, returning the index of the touch, or -1 if there was an error. */
+extern int SDL_AddTouch(SDL_TouchID id, const char *name);
+                     
+/* Get the touch with a given 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,SDL_FingerID id);
-
-
-/* Add a touch, possibly reattaching at a particular index (or -1),
-   returning the index of the touch, or -1 if there was an error. */
-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(SDL_TouchID id);
-
-/* Set the touch focus window */
-extern void SDL_SetTouchFocus(SDL_TouchID id, SDL_Window * window);
+/* Send a touch down/up event for a touch */
+extern int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, 
+			             SDL_bool down, float x, float y, float pressure);
 
 /* Send a touch motion event for a touch */
 extern int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
-			       int relative, float x, float y, float z);
+			                   float x, float y, float pressure);
 
-/* Send a touch down/up event for a touch */
-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(SDL_TouchID id, Uint8 state, Uint8 button);
+/* Remove a touch */
+extern void SDL_DelTouch(SDL_TouchID id);
 
 /* Shutdown the touch subsystem */
 extern void SDL_TouchQuit(void);
 
-/* Get the index of a touch device */
-extern int SDL_GetTouchIndexId(SDL_TouchID id);
-
-/* Print a debug message for a nonexistent touch */
-extern int SDL_TouchNotFoundError(SDL_TouchID id);
-
 #endif /* _SDL_touch_c_h */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/android/SDL_androidtouch.c	Sat Mar 02 20:44:16 2013 -0800
+++ b/src/video/android/SDL_androidtouch.c	Sun Mar 03 01:01:33 2013 -0800
@@ -64,19 +64,7 @@
 
     touchDeviceId = (SDL_TouchID)touch_device_id_in;
     if (!SDL_GetTouch(touchDeviceId)) {
-        SDL_Touch touch;
-        memset( &touch, 0, sizeof(touch) );
-        touch.id = touchDeviceId;
-        touch.x_min = 0.0f;
-        touch.x_max = 1.0f;
-        touch.native_xres = touch.x_max - touch.x_min;
-        touch.y_min = 0.0f;
-        touch.y_max = 1.0f;
-        touch.native_yres = touch.y_max - touch.y_min;
-        touch.pressure_min = 0.0f;
-        touch.pressure_max = 1.0f;
-        touch.native_pressureres = touch.pressure_max - touch.pressure_min;
-        if (SDL_AddTouch(&touch, "") < 0) {
+        if (SDL_AddTouch(touchDeviceId, "") < 0) {
              SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
         }
     }
@@ -96,7 +84,7 @@
 
                 leftFingerDown = fingerId;
             }
-            SDL_SendFingerDown(touchDeviceId, fingerId, SDL_TRUE, x, y, p);
+            SDL_SendTouch(touchDeviceId, fingerId, SDL_TRUE, x, y, p);
             break;
         case ACTION_MOVE:
             if (!leftFingerDown) {
@@ -105,7 +93,7 @@
                 /* send moved event */
                 SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
             }
-            SDL_SendTouchMotion(touchDeviceId, fingerId, SDL_FALSE, x, y, p);
+            SDL_SendTouchMotion(touchDeviceId, fingerId, x, y, p);
             break;
         case ACTION_UP:
         case ACTION_POINTER_1_UP:
@@ -114,7 +102,7 @@
                 SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
                 leftFingerDown = 0;
             }
-            SDL_SendFingerDown(touchDeviceId, fingerId, SDL_FALSE, x, y, p);
+            SDL_SendTouch(touchDeviceId, fingerId, SDL_FALSE, x, y, p);
             break;
         default:
             break;
--- a/src/video/cocoa/SDL_cocoawindow.m	Sat Mar 02 20:44:16 2013 -0800
+++ b/src/video/cocoa/SDL_cocoawindow.m	Sun Mar 03 01:01:33 2013 -0800
@@ -408,27 +408,14 @@
     enumerator = [touches objectEnumerator];
     touch = (NSTouch*)[enumerator nextObject];
     while (touch) {
-        const SDL_TouchID touchId = (SDL_TouchID) ((size_t) [touch device]);
+        const SDL_TouchID touchId = (SDL_TouchID)[touch device];
         if (!SDL_GetTouch(touchId)) {
-            SDL_Touch touch;
-
-            touch.id = touchId;
-            touch.x_min = 0;
-            touch.x_max = 1;
-            touch.native_xres = touch.x_max - touch.x_min;
-            touch.y_min = 0;
-            touch.y_max = 1;
-            touch.native_yres = touch.y_max - touch.y_min;
-            touch.pressure_min = 0;
-            touch.pressure_max = 1;
-            touch.native_pressureres = touch.pressure_max - touch.pressure_min;
-            
-            if (SDL_AddTouch(&touch, "") < 0) {
+            if (SDL_AddTouch(touchId, "") < 0) {
                 return;
             }
         } 
 
-        const SDL_FingerID fingerId = (SDL_FingerID) ((size_t) [touch identity]);
+        const SDL_FingerID fingerId = (SDL_FingerID)[touch identity];
         float x = [touch normalizedPosition].x;
         float y = [touch normalizedPosition].y;
         /* Make the origin the upper left instead of the lower left */
@@ -436,17 +423,17 @@
 
         switch (type) {
         case COCOA_TOUCH_DOWN:
-            SDL_SendFingerDown(touchId, fingerId, SDL_TRUE, x, y, 1);
+            SDL_SendTouch(touchId, fingerId, SDL_TRUE, x, y, 1.0f);
             break;
         case COCOA_TOUCH_UP:
         case COCOA_TOUCH_CANCELLED:
-            SDL_SendFingerDown(touchId, fingerId, SDL_FALSE, x, y, 1);
+            SDL_SendTouch(touchId, fingerId, SDL_FALSE, x, y, 1.0f);
             break;
         case COCOA_TOUCH_MOVE:
-            SDL_SendTouchMotion(touchId, fingerId, SDL_FALSE, x, y, 1);
+            SDL_SendTouchMotion(touchId, fingerId, x, y, 1.0f);
             break;
         }
-        
+
         touch = (NSTouch*)[enumerator nextObject];
     }
 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 */
--- a/src/video/uikit/SDL_uikitview.m	Sat Mar 02 20:44:16 2013 -0800
+++ b/src/video/uikit/SDL_uikitview.m	Sun Mar 03 01:01:33 2013 -0800
@@ -52,23 +52,8 @@
 
     self.multipleTouchEnabled = YES;
 
-    SDL_Touch touch;
-    touch.id = 0; //TODO: Should be -1?
-
-    //touch.driverdata = SDL_malloc(sizeof(EventTouchData));
-    //EventTouchData* data = (EventTouchData*)(touch.driverdata);
-
-    touch.x_min = 0;
-    touch.x_max = 1;
-    touch.native_xres = touch.x_max - touch.x_min;
-    touch.y_min = 0;
-    touch.y_max = 1;
-    touch.native_yres = touch.y_max - touch.y_min;
-    touch.pressure_min = 0;
-    touch.pressure_max = 1;
-    touch.native_pressureres = touch.pressure_max - touch.pressure_min;
-
-    touchId = SDL_AddTouch(&touch, "IPHONE SCREEN");
+    touchId = 1;
+    SDL_AddTouch(touchId, "");
 
     return self;
 
@@ -117,17 +102,15 @@
         // FIXME: TODO: Using touch as the fingerId is potentially dangerous
         // It is also much more efficient than storing the UITouch pointer
         // and comparing it to the incoming event.
-        SDL_SendFingerDown(touchId, (SDL_FingerID)touch,
-                           SDL_TRUE, locationInView.x, locationInView.y,
-                           1);
+        SDL_SendTouch(touchId, (SDL_FingerID)touch,
+                      SDL_TRUE, locationInView.x, locationInView.y, 1.0f);
 #else
         int i;
         for(i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
             if (finger[i] == NULL) {
                 finger[i] = touch;
-                SDL_SendFingerDown(touchId, i,
-                                   SDL_TRUE, locationInView.x, locationInView.y,
-                                   1);
+                SDL_SendTouch(touchId, i,
+                              SDL_TRUE, locationInView.x, locationInView.y, 1.0f);
                 break;
             }
         }
@@ -150,16 +133,14 @@
 
         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
-        SDL_SendFingerDown(touchId, (long)touch,
-                           SDL_FALSE, locationInView.x, locationInView.y,
-                           1);
+        SDL_SendTouch(touchId, (long)touch,
+                      SDL_FALSE, locationInView.x, locationInView.y, 1.0f);
 #else
         int i;
         for (i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
             if (finger[i] == touch) {
-                SDL_SendFingerDown(touchId, i,
-                                   SDL_FALSE, locationInView.x, locationInView.y,
-                                   1);
+                SDL_SendTouch(touchId, i,
+                              SDL_FALSE, locationInView.x, locationInView.y, 1.0f);
                 finger[i] = NULL;
                 break;
             }
@@ -195,15 +176,13 @@
         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
         SDL_SendTouchMotion(touchId, (long)touch,
-                            SDL_FALSE, locationInView.x, locationInView.y,
-                            1);
+                            locationInView.x, locationInView.y, 1.0f);
 #else
         int i;
         for (i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
             if (finger[i] == touch) {
                 SDL_SendTouchMotion(touchId, i,
-                                    SDL_FALSE, locationInView.x, locationInView.y,
-                                    1);
+                                    locationInView.x, locationInView.y, 1.0f);
                 break;
             }
         }
--- a/src/video/windows/SDL_windowsevents.c	Sat Mar 02 20:44:16 2013 -0800
+++ b/src/video/windows/SDL_windowsevents.c	Sun Mar 03 01:01:33 2013 -0800
@@ -691,23 +691,9 @@
 				for (i = 0; i < num_inputs; ++i) {
 					PTOUCHINPUT input = &inputs[i];
 
-					const SDL_TouchID touchId = (SDL_TouchID)
-												((size_t)input->hSource);
+					const SDL_TouchID touchId = (SDL_TouchID)input->hSource;
 					if (!SDL_GetTouch(touchId)) {
-						SDL_Touch touch;
-
-						touch.id = touchId;
-						touch.x_min = 0;
-						touch.x_max = 1;
-						touch.native_xres = touch.x_max - touch.x_min;
-						touch.y_min = 0;
-						touch.y_max = 1;
-						touch.native_yres = touch.y_max - touch.y_min;
-						touch.pressure_min = 0;
-						touch.pressure_max = 1;
-						touch.native_pressureres = touch.pressure_max - touch.pressure_min;
-
-						if (SDL_AddTouch(&touch, "") < 0) {
+						if (SDL_AddTouch(touchId, "") < 0) {
 							continue;
 						}
 					}
@@ -717,13 +703,13 @@
 					y = (float)(input->y - rect.top)/(rect.bottom - rect.top);
 
 					if (input->dwFlags & TOUCHEVENTF_DOWN) {
-						SDL_SendFingerDown(touchId, input->dwID, SDL_TRUE, x, y, 1);
+						SDL_SendTouch(touchId, input->dwID, SDL_TRUE, x, y, 1.0f);
 					}
 					if (input->dwFlags & TOUCHEVENTF_MOVE) {
-						SDL_SendTouchMotion(touchId, input->dwID, SDL_FALSE, x, y, 1);
+						SDL_SendTouchMotion(touchId, input->dwID, x, y, 1.0f);
 					}
 					if (input->dwFlags & TOUCHEVENTF_UP) {
-						SDL_SendFingerDown(touchId, input->dwID, SDL_FALSE, x, y, 1);
+						SDL_SendTouch(touchId, input->dwID, SDL_FALSE, x, y, 1.0f);
 					}
 				}
 			}
--- a/src/video/x11/SDL_x11events.c	Sat Mar 02 20:44:16 2013 -0800
+++ b/src/video/x11/SDL_x11events.c	Sun Mar 03 01:01:33 2013 -0800
@@ -41,12 +41,6 @@
 
 #include <stdio.h>
 
-#ifdef SDL_INPUT_LINUXEV
-/* Touch Input/event* includes */
-#include <linux/input.h>
-#include <fcntl.h>
-#endif
-
 /*#define DEBUG_XEVENTS*/
 
 /* Check to see if this is a repeated key.
@@ -703,90 +697,6 @@
 
     /* FIXME: Only need to do this when there are pending focus changes */
     X11_HandleFocusChanges(_this);
-
-    /*Dont process evtouch events if XInput2 multitouch is supported*/
-    if(X11_Xinput2IsMultitouchSupported()) {
-        return;
-    }
-
-#ifdef SDL_INPUT_LINUXEV
-    /* Process Touch events*/
-    int i = 0,rd;
-    struct input_event ev[64];
-    int size = sizeof (struct input_event);
-
-/* !!! FIXME: clean the tabstops out of here. */
-    for(i = 0;i < SDL_GetNumTouch();++i) {
-	SDL_Touch* touch = SDL_GetTouchIndex(i);
-	if(!touch) printf("Touch %i/%i DNE\n",i,SDL_GetNumTouch());
-	EventTouchData* data;
-	data = (EventTouchData*)(touch->driverdata);
-	if(data == NULL) {
-	  printf("No driver data\n");
-	  continue;
-	}
-	if(data->eventStream <= 0) 
-	    printf("Error: Couldn't open stream\n");
-	rd = read(data->eventStream, ev, size * 64);
-	if(rd >= size) {
-	    for (i = 0; i < rd / sizeof(struct input_event); i++) {
-		switch (ev[i].type) {
-		case EV_ABS:
-		    switch (ev[i].code) {
-			case ABS_X:
-			    data->x = ev[i].value;
-			    break;
-			case ABS_Y:
-			    data->y = ev[i].value;
-			    break;
-			case ABS_PRESSURE:
-			    data->pressure = ev[i].value;
-			    if(data->pressure < 0) data->pressure = 0;
-			    break;
-			case ABS_MISC:
-			    if(ev[i].value == 0)
-			        data->up = SDL_TRUE;			    
-			    break;
-			}
-		    break;
-		case EV_MSC:
-			if(ev[i].code == MSC_SERIAL)
-				data->finger = ev[i].value;
-			break;
-		case EV_KEY:
-			if(ev[i].code == BTN_TOUCH)
-			    if(ev[i].value == 0)
-			        data->up = SDL_TRUE;
-			break;
-		case EV_SYN:
-		  if(!data->down) {
-		      data->down = SDL_TRUE;
-		      SDL_SendFingerDown(touch->id,data->finger,
-		    		  data->down, data->x, data->y,
-		    		  data->pressure);
-		  }
-		  else if(!data->up)
-		    SDL_SendTouchMotion(touch->id,data->finger, 
-					SDL_FALSE, data->x,data->y,
-					data->pressure);
-		  else
-		  {
-		      data->down = SDL_FALSE;
-			  SDL_SendFingerDown(touch->id,data->finger,
-					  data->down, data->x,data->y,
-					  data->pressure);
-			  data->x = -1;
-			  data->y = -1;
-			  data->pressure = -1;
-			  data->finger = 0;
-			  data->up = SDL_FALSE;
-		  }
-		  break;		
-		}
-	    }
-	}
-    }
-#endif
 }
 
 
--- a/src/video/x11/SDL_x11touch.c	Sat Mar 02 20:44:16 2013 -0800
+++ b/src/video/x11/SDL_x11touch.c	Sun Mar 03 01:01:33 2013 -0800
@@ -28,97 +28,12 @@
 #include "../../events/SDL_touch_c.h"
 
 
-#ifdef SDL_INPUT_LINUXEV
-#include <linux/input.h>
-#include <fcntl.h>
-#endif
-
 void
 X11_InitTouch(_THIS)
 {
-    /*Initilized Xinput2 multitouch 
-    * and return in order to not initialize
-    * evtouch also*/
-    if(X11_Xinput2IsMultitouchSupported()) {
+    if (X11_Xinput2IsMultitouchSupported()) {
         X11_InitXinput2Multitouch(_this);
-        return;
     }
-#ifdef SDL_INPUT_LINUXEV
-    FILE *fd;
-    fd = fopen("/proc/bus/input/devices","r");
-    if (!fd) return;
-
-    int i = 0;
-    int tsfd;
-    char line[256];
-    char tstr[256];
-    int vendor = -1,product = -1,event = -1;
-    while(!feof(fd)) {
-        if(fgets(line,256,fd) <=0) continue;
-        if(line[0] == '\n') {
-            if(vendor == 1386 || vendor==1) {
-                sprintf(tstr,"/dev/input/event%i",event);
-
-                tsfd = open( tstr, O_RDONLY | O_NONBLOCK );
-                if ( tsfd == -1 )
-                    continue;   /* Maybe not enough permissions ? */
-
-                SDL_Touch touch;
-                touch.pressure_max = 0;
-                touch.pressure_min = 0;
-                touch.id = event; 
-
-                touch.driverdata = SDL_malloc(sizeof(EventTouchData));
-                EventTouchData* data = (EventTouchData*)(touch.driverdata);
-
-                data->x = -1;
-                data->y = -1;
-                data->pressure = -1;
-                data->finger = 0;
-                data->up = SDL_FALSE;
-                data->down = SDL_FALSE;
-
-                data->eventStream = tsfd;
-                ioctl (data->eventStream, EVIOCGNAME (sizeof (tstr)), tstr);
-
-                int abs[5];
-                ioctl(data->eventStream,EVIOCGABS(0),abs);	
-                touch.x_min = abs[1];
-                touch.x_max = abs[2];
-                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.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.native_pressureres = touch.pressure_max - touch.pressure_min;
-
-                SDL_AddTouch(&touch, tstr);
-            }
-            vendor = -1;
-            product = -1;
-            event = -1;      
-        }
-        else if(line[0] == 'I') {
-            i = 1;
-            while(line[i]) {
-                sscanf(&line[i],"Vendor=%x",&vendor);
-                sscanf(&line[i],"Product=%x",&product);
-                i++;
-            }
-        }
-        else if(line[0] == 'H') {
-            i = 1;
-            while(line[i]) {
-                sscanf(&line[i],"event%d",&event);
-                i++;
-            }
-        }
-    }
-    fclose(fd);
-#endif
 }
 
 void
--- a/src/video/x11/SDL_x11touch.h	Sat Mar 02 20:44:16 2013 -0800
+++ b/src/video/x11/SDL_x11touch.h	Sun Mar 03 01:01:33 2013 -0800
@@ -23,16 +23,6 @@
 #ifndef _SDL_x11touch_h
 #define _SDL_x11touch_h
 
-#ifdef SDL_INPUT_LINUXEV
-typedef struct EventTouchData
-{
-    int x,y,pressure,finger; /* Temporary Variables until sync */
-    int eventStream;
-    SDL_bool up;
-    SDL_bool down;
-} EventTouchData;
-#endif
-
 extern void X11_InitTouch(_THIS);
 extern void X11_QuitTouch(_THIS);
 
--- a/src/video/x11/SDL_x11xinput2.c	Sat Mar 02 20:44:16 2013 -0800
+++ b/src/video/x11/SDL_x11xinput2.c	Sun Mar 03 01:01:33 2013 -0800
@@ -121,8 +121,6 @@
 #endif
 }
 
-
-
 int 
 X11_HandleXinput2Event(SDL_VideoData *videodata,XGenericEventCookie *cookie)
 {
@@ -149,25 +147,22 @@
 #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
         case XI_TouchBegin: {
             const XIDeviceEvent *xev = (const XIDeviceEvent *) cookie->data;
-            SDL_SendFingerDown(xev->sourceid,xev->detail,
-                      SDL_TRUE, (int)xev->event_x, (int)xev->event_y,
-		    		  1.0);
+            SDL_SendTouch(xev->sourceid,xev->detail,
+                      SDL_TRUE, xev->event_x, xev->event_y, 1.0);
             return 1;
             }
             break;
         case XI_TouchEnd: {
             const XIDeviceEvent *xev = (const XIDeviceEvent *) cookie->data;
-            SDL_SendFingerDown(xev->sourceid,xev->detail,
-                      SDL_FALSE, (int)xev->event_x, (int)xev->event_y,
-		    		  1.0);
+            SDL_SendTouch(xev->sourceid,xev->detail,
+                      SDL_FALSE, xev->event_x, xev->event_y, 1.0);
             return 1;
             }
             break;
         case XI_TouchUpdate: {
             const XIDeviceEvent *xev = (const XIDeviceEvent *) cookie->data;
             SDL_SendTouchMotion(xev->sourceid,xev->detail,
-                      SDL_FALSE, (int)xev->event_x, (int)xev->event_y,
-		    		  1.0);
+                                xev->event_x, xev->event_y, 1.0);
             return 1;
             }
             break;
@@ -198,22 +193,8 @@
                 continue;
 
             touchId = t->sourceid;
-            /*Add the touch*/
             if (!SDL_GetTouch(touchId)) {
-                SDL_Touch touch;
-
-                touch.id = touchId;
-                touch.x_min = 0;
-                touch.x_max = 1;
-                touch.native_xres = touch.x_max - touch.x_min;
-                touch.y_min = 0;
-                touch.y_max = 1;
-                touch.native_yres = touch.y_max - touch.y_min;
-                touch.pressure_min = 0;
-                touch.pressure_max = 1;
-                touch.native_pressureres = touch.pressure_max - touch.pressure_min;
-
-                SDL_AddTouch(&touch,dev->name);
+                SDL_AddTouch(touchId, dev->name);
             }
         }
     }
--- a/test/testgesture.c	Sat Mar 02 20:44:16 2013 -0800
+++ b/test/testgesture.c	Sun Mar 03 01:01:33 2013 -0800
@@ -167,11 +167,8 @@
     if(event->type == SDL_FINGERMOTION || 
        event->type == SDL_FINGERDOWN ||
        event->type == SDL_FINGERUP) {
-      SDL_Touch* inTouch = SDL_GetTouch(event->tfinger.touchId);
-      if(inTouch == NULL) continue;
-
-      x = ((float)event->tfinger.x)/inTouch->xres;
-      y = ((float)event->tfinger.y)/inTouch->yres;      
+      x = event->tfinger.x;
+      y = event->tfinger.y;
       
       //draw the touch:      
       c = colors[event->tfinger.fingerId%7]; 
@@ -269,10 +266,6 @@
 	    SDL_Log("Finger: %i,x: %i, y: %i",event.tfinger.fingerId,
 	    	   event.tfinger.x,event.tfinger.y);
 #endif
-		{
-			SDL_Touch* inTouch = SDL_GetTouch(event.tfinger.touchId);
-			SDL_Finger* inFinger = SDL_GetFinger(inTouch,event.tfinger.fingerId);
-		}
 	    break;	    
 	  case SDL_FINGERDOWN:
 #if VERBOSE