README.gesture
changeset 6987 7084af936d82
parent 4693 2ede56a19f2f
equal deleted inserted replaced
6986:bc887debed9b 6987:7084af936d82
    14 
    14 
    15 Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event.
    15 Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event.
    16 A SDL_DOLLARRECORD event is a dgesture with the following fields:
    16 A SDL_DOLLARRECORD event is a dgesture with the following fields:
    17 
    17 
    18 event.dgesture.touchId   - the Id of the touch used to record the gesture.
    18 event.dgesture.touchId   - the Id of the touch used to record the gesture.
    19 event.dgesture.gestureId - the unique id of the recoreded gesture.
    19 event.dgesture.gestureId - the unique id of the recorded gesture.
    20 
    20 
    21 
    21 
    22 Performing:
    22 Performing:
    23 -----------
    23 -----------
    24 As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields:
    24 As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields:
    26 event.dgesture.touchId    - the Id of the touch which performed the gesture.
    26 event.dgesture.touchId    - the Id of the touch which performed the gesture.
    27 event.dgesture.gestureId  - the unique id of the closest gesture to the performed stroke.
    27 event.dgesture.gestureId  - the unique id of the closest gesture to the performed stroke.
    28 event.dgesture.error      - the difference between the gesture template and the actual performed gesture. Lower error is a better match.
    28 event.dgesture.error      - the difference between the gesture template and the actual performed gesture. Lower error is a better match.
    29 event.dgesture.numFingers - the number of fingers used to draw the stroke.
    29 event.dgesture.numFingers - the number of fingers used to draw the stroke.
    30 
    30 
    31 Most programs will want to define an appropriate error threshold and check to be sure taht the error of a gesture is not abnormally high (an indicator that no gesture was performed). 
    31 Most programs will want to define an appropriate error threshold and check to be sure that the error of a gesture is not abnormally high (an indicator that no gesture was performed).
    32 
    32 
    33 
    33 
    34 
    34 
    35 Saving:
    35 Saving:
    36 -------
    36 -------
    37 To save a template, call SDL_SaveDollarTemplate(gestureId, src) where gestureId is the id of the gesture you want to save, and src is an SDL_RWops pointer to the file where the gesture will be stored.
    37 To save a template, call SDL_SaveDollarTemplate(gestureId, src) where gestureId is the id of the gesture you want to save, and src is an SDL_RWops pointer to the file where the gesture will be stored.
    38 
    38 
    39 To save all currently loaded templates, call SDL_SaveAllDollarTemplates(src) where source is an SDL_RWops pointer to the file where the gesture will be stored.
    39 To save all currently loaded templates, call SDL_SaveAllDollarTemplates(src) where source is an SDL_RWops pointer to the file where the gesture will be stored.
    40 
    40 
    41 Both functions return the number of gestures sucessfully saved.
    41 Both functions return the number of gestures successfully saved.
    42 
    42 
    43 
    43 
    44 Loading:
    44 Loading:
    45 --------
    45 --------
    46 To load templates from a file, call SDL_LoadDollarTemplates(touchId,src) where touchId is the id of the touch to load to (or -1 to load to all touch devices), and src is an SDL_RWops pointer to a gesture save file. 
    46 To load templates from a file, call SDL_LoadDollarTemplates(touchId,src) where touchId is the id of the touch to load to (or -1 to load to all touch devices), and src is an SDL_RWops pointer to a gesture save file. 
    47 
    47 
    48 SDL_LoadDollarTemplates returns the number of templates sucessfully loaded. 
    48 SDL_LoadDollarTemplates returns the number of templates successfully loaded.
    49 
    49 
    50 
    50 
    51 
    51 
    52 ===========================================================================
    52 ===========================================================================
    53 Multi Gestures
    53 Multi Gestures
    54 ===========================================================================
    54 ===========================================================================
    55 SDL provides simple support for pinch/rotate/swipe gestures. 
    55 SDL provides simple support for pinch/rotate/swipe gestures. 
    56 Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields:
    56 Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields:
    57 
    57 
    58 event.mgesture.touchId - the Id of the touch on which the gesture was performed.
    58 event.mgesture.touchId - the Id of the touch on which the gesture was performed.
    59 event.mgesture.x       - the normalized x cooridinate of the gesture. (0..1)
    59 event.mgesture.x       - the normalized x coordinate of the gesture. (0..1)
    60 event.mgesture.y       - the normalized y cooridinate of the gesture. (0..1)
    60 event.mgesture.y       - the normalized y coordinate of the gesture. (0..1)
    61 event.mgesture.dTheta  - the amount that the fingers rotated during this motion.
    61 event.mgesture.dTheta  - the amount that the fingers rotated during this motion.
    62 event.mgesture.dDist   - the amount that the fingers pinched during this motion.
    62 event.mgesture.dDist   - the amount that the fingers pinched during this motion.
    63 event.mgesture.numFingers - the number of fingers used in the gesture.
    63 event.mgesture.numFingers - the number of fingers used in the gesture.
    64 
    64 
    65 
    65