zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_gesture.c File Reference
#include "SDL_config.h"
#include "SDL_events.h"
#include "SDL_events_c.h"
#include "SDL_gesture_c.h"
#include <memory.h>
#include <string.h>
#include <stdio.h>
#include <math.h>

Go to the source code of this file.

Macros

#define DOLLARNPOINTS   64
 
#define DOLLARSIZE   256
 
#define ENABLE_DOLLAR
 
#define MAXPATHSIZE   1024
 
#define PHI   0.618033989
 

Functions

static float bestDollarDifference (SDL_FloatPoint *points, SDL_FloatPoint *templ)
 
static float dollarDifference (SDL_FloatPoint *points, SDL_FloatPoint *templ, float ang)
 
static int dollarNormalize (const SDL_DollarPath *path, SDL_FloatPoint *points)
 
static float dollarRecognize (const SDL_DollarPath *path, int *bestTempl, SDL_GestureTouch *touch)
 
static int SaveTemplate (SDL_DollarTemplate *templ, SDL_RWops *src)
 
static int SDL_AddDollarGesture (SDL_GestureTouch *inTouch, SDL_FloatPoint *path)
 
static int SDL_AddDollarGesture_one (SDL_GestureTouch *inTouch, SDL_FloatPoint *path)
 
int SDL_GestureAddTouch (SDL_TouchID touchId)
 
void SDL_GestureProcessEvent (SDL_Event *event)
 
static SDL_GestureTouch * SDL_GetGestureTouch (SDL_TouchID id)
 
static unsigned long SDL_HashDollar (SDL_FloatPoint *points)
 
int SDL_LoadDollarTemplates (SDL_TouchID touchId, SDL_RWops *src)
 Load Dollar Gesture templates from a file. More...
 
int SDL_RecordGesture (SDL_TouchID touchId)
 Begin Recording a gesture on the specified touch, or all touches (-1) More...
 
int SDL_SaveAllDollarTemplates (SDL_RWops *src)
 Save all currently loaded Dollar Gesture templates. More...
 
int SDL_SaveDollarTemplate (SDL_GestureID gestureId, SDL_RWops *src)
 Save a currently loaded Dollar Gesture template. More...
 
static int SDL_SendDollarRecord (SDL_GestureTouch *touch, SDL_GestureID gestureId)
 
static int SDL_SendGestureDollar (SDL_GestureTouch *touch, SDL_GestureID gestureId, float error)
 
int SDL_SendGestureMulti (SDL_GestureTouch *touch, float dTheta, float dDist)
 

Variables

SDL_bool recordAll
 
SDL_GestureTouch * SDL_gestureTouch
 
int SDL_numGestureTouches = 0
 

Macro Definition Documentation

#define DOLLARSIZE   256

Definition at line 43 of file SDL_gesture.c.

Referenced by dollarNormalize().

#define ENABLE_DOLLAR

Definition at line 45 of file SDL_gesture.c.

#define MAXPATHSIZE   1024

Definition at line 40 of file SDL_gesture.c.

Referenced by SDL_GestureProcessEvent().

#define PHI   0.618033989

Definition at line 47 of file SDL_gesture.c.

Referenced by bestDollarDifference().

Function Documentation

static float bestDollarDifference ( SDL_FloatPoint *  points,
SDL_FloatPoint *  templ 
)
static

Definition at line 262 of file SDL_gesture.c.

References dollarDifference(), M_PI, PHI, SDL_fabs(), and SDL_min.

Referenced by dollarRecognize().

static float dollarDifference ( SDL_FloatPoint *  points,
SDL_FloatPoint *  templ,
float  ang 
)
static

Definition at line 246 of file SDL_gesture.c.

References DOLLARNPOINTS, i, SDL_cos(), SDL_sin(), and SDL_sqrt().

Referenced by bestDollarDifference().

static int dollarNormalize ( const SDL_DollarPath *  path,
SDL_FloatPoint *  points 
)
static

Definition at line 301 of file SDL_gesture.c.

References d, DOLLARNPOINTS, DOLLARSIZE, i, SDL_atan2(), SDL_cos(), SDL_sin(), and SDL_sqrt().

Referenced by dollarRecognize(), and SDL_GestureProcessEvent().

static float dollarRecognize ( const SDL_DollarPath *  path,
int bestTempl,
SDL_GestureTouch *  touch 
)
static

Definition at line 393 of file SDL_gesture.c.

References bestDollarDifference(), dollarNormalize(), DOLLARNPOINTS, i, and SDL_memset().

Referenced by SDL_GestureProcessEvent().

static int SaveTemplate ( SDL_DollarTemplate *  templ,
SDL_RWops src 
)
static

Definition at line 119 of file SDL_gesture.c.

References DOLLARNPOINTS, NULL, and SDL_RWwrite.

Referenced by SDL_SaveAllDollarTemplates(), and SDL_SaveDollarTemplate().

static int SDL_AddDollarGesture ( SDL_GestureTouch *  inTouch,
SDL_FloatPoint *  path 
)
static
static int SDL_AddDollarGesture_one ( SDL_GestureTouch *  inTouch,
SDL_FloatPoint *  path 
)
static

Definition at line 163 of file SDL_gesture.c.

References DOLLARNPOINTS, SDL_HashDollar(), SDL_memcpy(), SDL_OutOfMemory, and SDL_realloc().

Referenced by SDL_AddDollarGesture().

int SDL_GestureAddTouch ( SDL_TouchID  touchId)

Definition at line 412 of file SDL_gesture.c.

References SDL_FALSE, SDL_gestureTouch, SDL_numGestureTouches, SDL_OutOfMemory, and SDL_realloc().

Referenced by SDL_AddTouch().

static SDL_GestureTouch* SDL_GetGestureTouch ( SDL_TouchID  id)
static

Definition at line 435 of file SDL_gesture.c.

References i, NULL, SDL_gestureTouch, and SDL_numGestureTouches.

Referenced by SDL_GestureProcessEvent().

static unsigned long SDL_HashDollar ( SDL_FloatPoint *  points)
static

Definition at line 107 of file SDL_gesture.c.

References DOLLARNPOINTS, and i.

Referenced by SDL_AddDollarGesture_one().

int SDL_LoadDollarTemplates ( SDL_TouchID  touchId,
SDL_RWops src 
)

Load Dollar Gesture templates from a file.

Definition at line 207 of file SDL_gesture.c.

References DOLLARNPOINTS, i, NULL, SDL_AddDollarGesture(), SDL_gestureTouch, SDL_numGestureTouches, and SDL_RWread.

int SDL_RecordGesture ( SDL_TouchID  touchId)

Begin Recording a gesture on the specified touch, or all touches (-1)

Definition at line 93 of file SDL_gesture.c.

References i, recordAll, SDL_gestureTouch, SDL_numGestureTouches, and SDL_TRUE.

int SDL_SaveAllDollarTemplates ( SDL_RWops src)

Save all currently loaded Dollar Gesture templates.

Definition at line 135 of file SDL_gesture.c.

References i, j, SaveTemplate(), SDL_gestureTouch, and SDL_numGestureTouches.

int SDL_SaveDollarTemplate ( SDL_GestureID  gestureId,
SDL_RWops src 
)

Save a currently loaded Dollar Gesture template.

Definition at line 147 of file SDL_gesture.c.

References i, j, SaveTemplate(), SDL_gestureTouch, SDL_numGestureTouches, and SDL_SetError().

static int SDL_SendDollarRecord ( SDL_GestureTouch *  touch,
SDL_GestureID  gestureId 
)
static

Definition at line 475 of file SDL_gesture.c.

References SDL_DOLLARRECORD, and SDL_PushEvent().

Referenced by SDL_GestureProcessEvent().

static int SDL_SendGestureDollar ( SDL_GestureTouch *  touch,
SDL_GestureID  gestureId,
float  error 
)
static

Definition at line 459 of file SDL_gesture.c.

References error, SDL_DOLLARGESTURE, and SDL_PushEvent().

Referenced by SDL_GestureProcessEvent().

int SDL_SendGestureMulti ( SDL_GestureTouch *  touch,
float  dTheta,
float  dDist 
)

Definition at line 446 of file SDL_gesture.c.

References SDL_MULTIGESTURE, and SDL_PushEvent().

Referenced by SDL_GestureProcessEvent().

Variable Documentation

SDL_bool recordAll

Definition at line 79 of file SDL_gesture.c.

Referenced by SDL_GestureProcessEvent(), and SDL_RecordGesture().