src/joystick/SDL_joystick.c
changeset 6145 964d13f789e2
parent 6138 4c64952a58fb
child 6690 9548c8a58103
equal deleted inserted replaced
6140:67268d47c17b 6145:964d13f789e2
   424 
   424 
   425 int
   425 int
   426 SDL_PrivateJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
   426 SDL_PrivateJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
   427 {
   427 {
   428     int posted;
   428     int posted;
       
   429 
       
   430     /* Make sure we're not getting garbage events */
       
   431     if (axis >= joystick->naxes) {
       
   432         return 0;
       
   433     }
   429 
   434 
   430     /* Update internal joystick state */
   435     /* Update internal joystick state */
   431     joystick->axes[axis] = value;
   436     joystick->axes[axis] = value;
   432 
   437 
   433     /* Post the event, if desired */
   438     /* Post the event, if desired */
   452 int
   457 int
   453 SDL_PrivateJoystickHat(SDL_Joystick * joystick, Uint8 hat, Uint8 value)
   458 SDL_PrivateJoystickHat(SDL_Joystick * joystick, Uint8 hat, Uint8 value)
   454 {
   459 {
   455     int posted;
   460     int posted;
   456 
   461 
       
   462     /* Make sure we're not getting garbage events */
       
   463     if (hat >= joystick->nhats) {
       
   464         return 0;
       
   465     }
       
   466 
   457     /* Update internal joystick state */
   467     /* Update internal joystick state */
   458     joystick->hats[hat] = value;
   468     joystick->hats[hat] = value;
   459 
   469 
   460     /* Post the event, if desired */
   470     /* Post the event, if desired */
   461     posted = 0;
   471     posted = 0;
   479 int
   489 int
   480 SDL_PrivateJoystickBall(SDL_Joystick * joystick, Uint8 ball,
   490 SDL_PrivateJoystickBall(SDL_Joystick * joystick, Uint8 ball,
   481                         Sint16 xrel, Sint16 yrel)
   491                         Sint16 xrel, Sint16 yrel)
   482 {
   492 {
   483     int posted;
   493     int posted;
       
   494 
       
   495     /* Make sure we're not getting garbage events */
       
   496     if (ball >= joystick->nballs) {
       
   497         return 0;
       
   498     }
   484 
   499 
   485     /* Update internal mouse state */
   500     /* Update internal mouse state */
   486     joystick->balls[ball].dx += xrel;
   501     joystick->balls[ball].dx += xrel;
   487     joystick->balls[ball].dy += yrel;
   502     joystick->balls[ball].dy += yrel;
   488 
   503 
   524         /* Invalid state -- bail */
   539         /* Invalid state -- bail */
   525         return (0);
   540         return (0);
   526     }
   541     }
   527 #endif /* !SDL_EVENTS_DISABLED */
   542 #endif /* !SDL_EVENTS_DISABLED */
   528 
   543 
       
   544     /* Make sure we're not getting garbage events */
       
   545     if (button >= joystick->nbuttons) {
       
   546         return 0;
       
   547     }
       
   548 
   529     /* Update internal joystick state */
   549     /* Update internal joystick state */
   530     joystick->buttons[button] = state;
   550     joystick->buttons[button] = state;
   531 
   551 
   532     /* Post the event, if desired */
   552     /* Post the event, if desired */
   533     posted = 0;
   553     posted = 0;