src/joystick/SDL_gamecontroller.c
changeset 10495 f732781d7ddc
parent 10477 dc4bec0fc176
child 10595 9da2701eeb4a
equal deleted inserted replaced
10494:c54de4000f9f 10495:f732781d7ddc
   143     switch(event->type) {
   143     switch(event->type) {
   144     case SDL_JOYAXISMOTION:
   144     case SDL_JOYAXISMOTION:
   145         {
   145         {
   146             SDL_GameController *controllerlist;
   146             SDL_GameController *controllerlist;
   147 
   147 
   148             if (event->jaxis.axis >= k_nMaxReverseEntries) break;
   148             if (event->jaxis.axis >= k_nMaxReverseEntries)
       
   149             {
       
   150                 SDL_SetError("SDL_GameControllerEventWatcher: Axis index %d too large, ignoring motion", (int)event->jaxis.axis);
       
   151                 break;
       
   152             }
   149 
   153 
   150             controllerlist = SDL_gamecontrollers;
   154             controllerlist = SDL_gamecontrollers;
   151             while (controllerlist) {
   155             while (controllerlist) {
   152                 if (controllerlist->joystick->instance_id == event->jaxis.which) {
   156                 if (controllerlist->joystick->instance_id == event->jaxis.which) {
   153                     if (controllerlist->mapping.raxes[event->jaxis.axis] >= 0) /* simple axis to axis, send it through */ {
   157                     if (controllerlist->mapping.raxes[event->jaxis.axis] >= 0) /* simple axis to axis, send it through */ {
   174     case SDL_JOYBUTTONDOWN:
   178     case SDL_JOYBUTTONDOWN:
   175     case SDL_JOYBUTTONUP:
   179     case SDL_JOYBUTTONUP:
   176         {
   180         {
   177             SDL_GameController *controllerlist;
   181             SDL_GameController *controllerlist;
   178 
   182 
   179             if (event->jbutton.button >= k_nMaxReverseEntries) break;
   183             if (event->jbutton.button >= k_nMaxReverseEntries)
       
   184             {
       
   185                 SDL_SetError("SDL_GameControllerEventWatcher: Button index %d too large, ignoring update", (int)event->jbutton.button);
       
   186                 break;
       
   187             }
   180 
   188 
   181             controllerlist = SDL_gamecontrollers;
   189             controllerlist = SDL_gamecontrollers;
   182             while (controllerlist) {
   190             while (controllerlist) {
   183                 if (controllerlist->joystick->instance_id == event->jbutton.which) {
   191                 if (controllerlist->joystick->instance_id == event->jbutton.which) {
   184                     if (controllerlist->mapping.rbuttons[event->jbutton.button] >= 0) { /* simple button as button */
   192                     if (controllerlist->mapping.rbuttons[event->jbutton.button] >= 0) { /* simple button as button */