README.touch
changeset 6987 7084af936d82
parent 4693 2ede56a19f2f
child 7127 5011ddf43295
     1.1 --- a/README.touch	Sat Mar 09 10:35:12 2013 -0800
     1.2 +++ b/README.touch	Sun Mar 10 09:03:38 2013 -0700
     1.3 @@ -5,7 +5,7 @@
     1.4  The linux touch system is currently based off event streams, and proc/bus/devices. The active user must be given permissions to read /dev/input/TOUCHDEVICE, where TOUCHDEVICE is the event stream for your device. Currently only Wacom tablets are supported. If you have an unsupported tablet contact me at jim.tla+sdl_touch@gmail.com and I will help you get support for it.
     1.5  
     1.6  Mac: 
     1.7 -The Mac and Iphone API's are pretty. If your touch device supports them then you'll be fine. If it doesn't, then there isn't much we can do.
     1.8 +The Mac and iPhone APIs are pretty. If your touch device supports them then you'll be fine. If it doesn't, then there isn't much we can do.
     1.9  
    1.10  iPhone: 
    1.11  Works out of box.
    1.12 @@ -21,18 +21,18 @@
    1.13  Fields:
    1.14  event.tfinger.touchId  - the Id of the touch device.
    1.15  event.tfinger.fingerId - the Id of the finger which just went down.
    1.16 -event.tfinger.x        - the x coordinate of the touch (0..touch.xres)
    1.17 -event.tfinger.y        - the y coordinate of the touch (0..touch.yres)
    1.18 -event.tfinger.pressure - the pressure of the touch (0..touch.pressureres)
    1.19 +event.tfinger.x        - the x coordinate of the touch (0..1)
    1.20 +event.tfinger.y        - the y coordinate of the touch (0..1)
    1.21 +event.tfinger.pressure - the pressure of the touch (0..1)
    1.22  
    1.23  SDL_FINGERMOTION:
    1.24  Sent when a finger (or stylus) is moved on the touch device.
    1.25  Fields:
    1.26  Same as FINGERDOWN but with additional:
    1.27 -event.tfginer.dx       - change in x coordinate during this motion event.
    1.28 -event.tfginer.dy       - change in y coordinate during this motion event.
    1.29 +event.tfinger.dx       - change in x coordinate during this motion event.
    1.30 +event.tfinger.dy       - change in y coordinate during this motion event.
    1.31  
    1.32 -SDL_FINGERMOTION:
    1.33 +SDL_FINGERUP:
    1.34  Sent when a finger (or stylus) is lifted from the touch device.
    1.35  Fields:
    1.36  Same as FINGERDOWN.
    1.37 @@ -41,56 +41,38 @@
    1.38  ===========================================================================
    1.39  Functions
    1.40  ===========================================================================
    1.41 -SDL provides the ability to access the underlying Touch and Finger structures.
    1.42 +SDL provides the ability to access the underlying Finger structures.
    1.43  These structures should _never_ be modified.
    1.44  
    1.45 -The following functions are included from SDL_Touch.h
    1.46 -
    1.47 -To get a SDL_Touch device call SDL_GetTouch(touchId). 
    1.48 -This returns an SDL_Touch*. 
    1.49 -IMPORTANT: If the touch has been removed, or there is no touch with the given ID, SDL_GetTouch will return null. Be sure to check for this!
    1.50 +The following functions are included from SDL_touch.h
    1.51  
    1.52 -An SDL_Touch has the following fields:
    1.53 ->xres,yres,pressures:
    1.54 -	The resolution at which x,y, and pressure values are reported. Currently these will always be equal to 2^15, but this may not always be the case. 
    1.55 +To get a SDL_TouchID call SDL_GetTouchDevice(index).
    1.56 +This returns a SDL_TouchID.
    1.57 +IMPORTANT: If the touch has been removed, or there is no touch with the given ID, SDL_GetTouchID will return 0. Be sure to check for this!
    1.58  
    1.59 ->pressure_max, pressure_min, x_max, x_min, y_max, y_min
    1.60 -	Which give, respectively, the maximum and minumum values that the touch digitizer can return for pressure, x coordiniate, and y coordinate AS REPORTED BY THE OPERATING SYSTEM.
    1.61 -On Mac/iPhone systems _max will always be 0, and _min will always be 1. 
    1.62 +The number of touch devices can be queried with SDL_GetNumTouchDevices().
    1.63  
    1.64 ->native_xres,native_yres,native_pressureres:
    1.65 -	The native resolution of the touch device AS REPORTED BY THE OPERATING SYSTEM.
    1.66 -On Mac/iPhone systems these will always be 1.
    1.67 +A SDL_Touch may be used to get pointers to SDL_Finger.
    1.68  
    1.69 ->num_fingers:
    1.70 -	The number of fingers currently down on the device.
    1.71 +SDL_GetNumTouchFingers(touchID) may be used to get the number of fingers currently down on the device.
    1.72  
    1.73 ->fingers:
    1.74 -	An array of pointers to the fingers which are on the device.
    1.75 -
    1.76 -
    1.77 -The most common reason to access a touch device is to normalize inputs. This would be accomplished by code like the following:
    1.78 +The most common reason to access SDL_Finger is to query the fingers outside the event. In most cases accessing the fingers is using the event. This would be accomplished by code like the following:
    1.79  
    1.80 -      SDL_Touch* inTouch = SDL_GetTouch(event.tfinger.touchId);
    1.81 -      if(inTouch == NULL) continue; //The touch has been removed
    1.82 -
    1.83 -      float x = ((float)event.tfinger.x)/inTouch->xres;
    1.84 -      float y = ((float)event.tfinger.y)/inTouch->yres;
    1.85 +      float x = event.tfinger.x;
    1.86 +      float y = event.tfinger.y;
    1.87  
    1.88  
    1.89  
    1.90 -To get an SDL_Finger, call SDL_GetFinger(touch,fingerId), where touch is a pointer to an SDL_Touch device, and fingerId is the id of the requested finger.
    1.91 -This returns an SDL_Finger*, or null if the finger does not exist, or has been removed.
    1.92 -An SDL_Finger is guaranteed to be persistent for the duration of a touch, but it will be de-allocated as soon as the finger is removed. This occurs when the SDL_FINGERUP event is _added_ to the event queue, and thus _before_ the FINGERUP event is polled. 
    1.93 -As a result, be very careful to check for null return values.
    1.94 +To get a SDL_Finger, call SDL_GetTouchFinger(touchID,index), where touchID is a SDL_TouchID, and index is the requested finger.
    1.95 +This returns a SDL_Finger*, or NULL if the finger does not exist, or has been removed.
    1.96 +A SDL_Finger is guaranteed to be persistent for the duration of a touch, but it will be de-allocated as soon as the finger is removed. This occurs when the SDL_FINGERUP event is _added_ to the event queue, and thus _before_ the FINGERUP event is polled.
    1.97 +As a result, be very careful to check for NULL return values.
    1.98  
    1.99 -An SDL_Finger has the following fields:
   1.100 +A SDL_Finger has the following fields:
   1.101  >x,y,pressure:
   1.102  	The current coordinates of the touch.
   1.103 ->xdelta,ydelta: 
   1.104 -	The change in position resulting from the last finger motion.
   1.105 ->last_x, last_y, last_pressure:
   1.106 -	 The previous coordinates of the touch.
   1.107 +>pressure:
   1.108 +	The pressure of the touch.
   1.109  
   1.110  ===========================================================================
   1.111  Notes
   1.112 @@ -99,3 +81,4 @@
   1.113  
   1.114  Please direct questions/comments to:
   1.115     jim.tla+sdl_touch@gmail.com
   1.116 +   (original author, API was changed since)