Skip to content

Commit

Permalink
Changed parameter name for gesture template save functions from "src"…
Browse files Browse the repository at this point in the history
… to "dst".
  • Loading branch information
philippwiesemann committed Nov 2, 2013
1 parent 95bbf5f commit cd37485
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README-gesture.txt
Expand Up @@ -34,9 +34,9 @@ Most programs will want to define an appropriate error threshold and check to be

Saving:
-------
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.
To save a template, call SDL_SaveDollarTemplate(gestureId, dst) where gestureId is the id of the gesture you want to save, and dst is an SDL_RWops pointer to the file where the gesture will be stored.

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.
To save all currently loaded templates, call SDL_SaveAllDollarTemplates(dst) where dst is an SDL_RWops pointer to the file where the gesture will be stored.

Both functions return the number of gestures successfully saved.

Expand Down
4 changes: 2 additions & 2 deletions include/SDL_gesture.h
Expand Up @@ -58,14 +58,14 @@ extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);
*
*
*/
extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *src);
extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst);

/**
* \brief Save a currently loaded Dollar Gesture template
*
*
*/
extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *src);
extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst);


/**
Expand Down
17 changes: 8 additions & 9 deletions src/events/SDL_gesture.c
Expand Up @@ -116,42 +116,41 @@ static unsigned long SDL_HashDollar(SDL_FloatPoint* points)
}


static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops * src)
static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst)
{
if (src == NULL) return 0;

if (dst == NULL) return 0;

/* No Longer storing the Hash, rehash on load */
/* if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0; */
/* if (SDL_RWops.write(dst, &(templ->hash), sizeof(templ->hash), 1) != 1) return 0; */

if (SDL_RWwrite(src,templ->path,
if (SDL_RWwrite(dst, templ->path,
sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS)
return 0;

return 1;
}


int SDL_SaveAllDollarTemplates(SDL_RWops *src)
int SDL_SaveAllDollarTemplates(SDL_RWops *dst)
{
int i,j,rtrn = 0;
for (i = 0; i < SDL_numGestureTouches; i++) {
SDL_GestureTouch* touch = &SDL_gestureTouch[i];
for (j = 0; j < touch->numDollarTemplates; j++) {
rtrn += SaveTemplate(&touch->dollarTemplate[i],src);
rtrn += SaveTemplate(&touch->dollarTemplate[i], dst);
}
}
return rtrn;
}

int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src)
int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *dst)
{
int i,j;
for (i = 0; i < SDL_numGestureTouches; i++) {
SDL_GestureTouch* touch = &SDL_gestureTouch[i];
for (j = 0; j < touch->numDollarTemplates; j++) {
if (touch->dollarTemplate[i].hash == gestureId) {
return SaveTemplate(&touch->dollarTemplate[i],src);
return SaveTemplate(&touch->dollarTemplate[i], dst);
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions test/testgesture.c
Expand Up @@ -205,7 +205,7 @@ int main(int argc, char* argv[])
SDL_Surface *screen;
SDL_Event event;
SDL_bool quitting = SDL_FALSE;
SDL_RWops *src;
SDL_RWops *stream;

/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
Expand Down Expand Up @@ -241,14 +241,14 @@ int main(int argc, char* argv[])
SDL_RecordGesture(-1);
break;
case SDLK_s:
src = SDL_RWFromFile("gestureSave","w");
SDL_Log("Wrote %i templates",SDL_SaveAllDollarTemplates(src));
SDL_RWclose(src);
stream = SDL_RWFromFile("gestureSave", "w");
SDL_Log("Wrote %i templates", SDL_SaveAllDollarTemplates(stream));
SDL_RWclose(stream);
break;
case SDLK_l:
src = SDL_RWFromFile("gestureSave","r");
SDL_Log("Loaded: %i",SDL_LoadDollarTemplates(-1,src));
SDL_RWclose(src);
stream = SDL_RWFromFile("gestureSave", "r");
SDL_Log("Loaded: %i", SDL_LoadDollarTemplates(-1, stream));
SDL_RWclose(stream);
break;
case SDLK_ESCAPE:
quitting = SDL_TRUE;
Expand Down

0 comments on commit cd37485

Please sign in to comment.