README.touch
changeset 4689 f9ab8df6d45a
child 4690 baf8195aeb92
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/README.touch	Sun Aug 15 00:36:28 2010 -0400
     1.3 @@ -0,0 +1,77 @@
     1.4 +===========================================================================
     1.5 +Events
     1.6 +===========================================================================
     1.7 +SDL_FINGERDOWN:
     1.8 +Sent when a finger (or stylus) is placed on a touch device.
     1.9 +Fields:
    1.10 +event.tfinger.touchId  - the Id of the touch device.
    1.11 +event.tfinger.fingerId - the Id of the finger which just went down.
    1.12 +event.tfinger.x        - the x coordinate of the touch (0..touch.xres)
    1.13 +event.tfinger.y        - the y coordinate of the touch (0..touch.yres)
    1.14 +event.tfinger.pressure - the pressure of the touch (0..touch.pressureres)
    1.15 +
    1.16 +SDL_FINGERMOTION:
    1.17 +Sent when a finger (or stylus) is moved on the touch device.
    1.18 +Fields:
    1.19 +Same as FINGERDOWN but with additional:
    1.20 +event.tfginer.dx       - chagne in x coordinate during this motion event.
    1.21 +event.tfginer.dy       - chagne in y coordinate during this motion event.
    1.22 +
    1.23 +SDL_FINGERMOTION:
    1.24 +Sent when a finger (or stylus) is lifted from the touch device.
    1.25 +Fields:
    1.26 +Same as FINGERDOWN.
    1.27 +
    1.28 +
    1.29 +===========================================================================
    1.30 +Functions
    1.31 +===========================================================================
    1.32 +SDL provides the ability to access the underlying Touch and Finger structures.
    1.33 +These structures should _never_ be modified.
    1.34 +
    1.35 +The following functions are included from SDL_Touch.h
    1.36 +
    1.37 +To get a SDL_Touch device call SDL_GetTouch(touchId). 
    1.38 +This returns an SDL_Touch*. 
    1.39 +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.40 +
    1.41 +An SDL_Touch has the following fields:
    1.42 +>pressure_max, pressure_min, x_max, x_min, y_max, y_min
    1.43 +	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.44 +On Mac/iPhone systems _max will always be 0, and _min will always be 1. 
    1.45 +
    1.46 +>xres,yres,pressures:
    1.47 +	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.48 +
    1.49 +>native_xres,native_yres,native_pressureres:
    1.50 +	The native resolution of the touch device AS REPORTED BY THE OPERATING SYSTEM.
    1.51 +On Mac/iPhone systems these will always be 1.
    1.52 +
    1.53 +>num_fingers:
    1.54 +	The number of fingers currently down on the device.
    1.55 +
    1.56 +>fingers:
    1.57 +	An array of pointers to the fingers which are on the device.
    1.58 +
    1.59 +
    1.60 +The most common reason to get a touch device is to normalize inputs. This would look something like:
    1.61 +
    1.62 +      SDL_Touch* inTouch = SDL_GetTouch(event.tfinger.touchId);
    1.63 +      if(inTouch == NULL) continue;
    1.64 +
    1.65 +      float x = ((float)event.tfinger.x)/inTouch->xres;
    1.66 +      float y = ((float)event.tfinger.y)/inTouch->yres;      
    1.67 +
    1.68 +
    1.69 +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.70 +This returns an SDL_Finger*, or null if the finger does not exist, or has been removed.
    1.71 +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 seen. 
    1.72 +As a result, be very careful to check for null return values.
    1.73 +
    1.74 +An SDL_Finger has the following fields:
    1.75 +>x,y,pressure:
    1.76 +	The current coordinates of the touch.
    1.77 +>xdelta,ydelta: 
    1.78 +	The change in position resulting from the last finger motion.
    1.79 +>last_x, last_y, last_pressure:
    1.80 +	 The previous coordinates of the touch.
    1.81 \ No newline at end of file