src/events/SDL_gesture.c
changeset 7900 cc2289c332eb
parent 7899 e94abe9c40ca
child 8093 b43765095a6f
equal deleted inserted replaced
7899:e94abe9c40ca 7900:cc2289c332eb
   114     }
   114     }
   115     return hash;
   115     return hash;
   116 }
   116 }
   117 
   117 
   118 
   118 
   119 static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops * src)
   119 static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst)
   120 {
   120 {
   121     if (src == NULL) return 0;
   121     if (dst == NULL) return 0;
   122 
       
   123 
   122 
   124     /* No Longer storing the Hash, rehash on load */
   123     /* No Longer storing the Hash, rehash on load */
   125     /* if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0; */
   124     /* if (SDL_RWops.write(dst, &(templ->hash), sizeof(templ->hash), 1) != 1) return 0; */
   126 
   125 
   127     if (SDL_RWwrite(src,templ->path,
   126     if (SDL_RWwrite(dst, templ->path,
   128                     sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS)
   127                     sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS)
   129         return 0;
   128         return 0;
   130 
   129 
   131     return 1;
   130     return 1;
   132 }
   131 }
   133 
   132 
   134 
   133 
   135 int SDL_SaveAllDollarTemplates(SDL_RWops *src)
   134 int SDL_SaveAllDollarTemplates(SDL_RWops *dst)
   136 {
   135 {
   137     int i,j,rtrn = 0;
   136     int i,j,rtrn = 0;
   138     for (i = 0; i < SDL_numGestureTouches; i++) {
   137     for (i = 0; i < SDL_numGestureTouches; i++) {
   139         SDL_GestureTouch* touch = &SDL_gestureTouch[i];
   138         SDL_GestureTouch* touch = &SDL_gestureTouch[i];
   140         for (j = 0; j < touch->numDollarTemplates; j++) {
   139         for (j = 0; j < touch->numDollarTemplates; j++) {
   141             rtrn += SaveTemplate(&touch->dollarTemplate[i],src);
   140             rtrn += SaveTemplate(&touch->dollarTemplate[i], dst);
   142         }
   141         }
   143     }
   142     }
   144     return rtrn;
   143     return rtrn;
   145 }
   144 }
   146 
   145 
   147 int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src)
   146 int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *dst)
   148 {
   147 {
   149     int i,j;
   148     int i,j;
   150     for (i = 0; i < SDL_numGestureTouches; i++) {
   149     for (i = 0; i < SDL_numGestureTouches; i++) {
   151         SDL_GestureTouch* touch = &SDL_gestureTouch[i];
   150         SDL_GestureTouch* touch = &SDL_gestureTouch[i];
   152         for (j = 0; j < touch->numDollarTemplates; j++) {
   151         for (j = 0; j < touch->numDollarTemplates; j++) {
   153             if (touch->dollarTemplate[i].hash == gestureId) {
   152             if (touch->dollarTemplate[i].hash == gestureId) {
   154                 return SaveTemplate(&touch->dollarTemplate[i],src);
   153                 return SaveTemplate(&touch->dollarTemplate[i], dst);
   155             }
   154             }
   156         }
   155         }
   157     }
   156     }
   158     return SDL_SetError("Unknown gestureId");
   157     return SDL_SetError("Unknown gestureId");
   159 }
   158 }