src/joystick/linux/SDL_sysjoystick.c
changeset 10641 ae818421bb1f
parent 10617 346c02ff71b6
child 10737 3406a0f8b041
equal deleted inserted replaced
10640:2e0704a41e5a 10641:ae818421bb1f
   447         for (i = BTN_JOYSTICK; i < KEY_MAX; ++i) {
   447         for (i = BTN_JOYSTICK; i < KEY_MAX; ++i) {
   448             if (test_bit(i, keybit)) {
   448             if (test_bit(i, keybit)) {
   449 #ifdef DEBUG_INPUT_EVENTS
   449 #ifdef DEBUG_INPUT_EVENTS
   450                 printf("Joystick has button: 0x%x\n", i);
   450                 printf("Joystick has button: 0x%x\n", i);
   451 #endif
   451 #endif
   452                 joystick->hwdata->key_map[i - BTN_MISC] = joystick->nbuttons;
   452                 joystick->hwdata->key_map[i] = joystick->nbuttons;
   453                 ++joystick->nbuttons;
   453                 ++joystick->nbuttons;
   454             }
   454             }
   455         }
   455         }
   456         for (i = BTN_MISC; i < BTN_JOYSTICK; ++i) {
   456         for (i = 0; i < BTN_JOYSTICK; ++i) {
   457             if (test_bit(i, keybit)) {
   457             if (test_bit(i, keybit)) {
   458 #ifdef DEBUG_INPUT_EVENTS
   458 #ifdef DEBUG_INPUT_EVENTS
   459                 printf("Joystick has button: 0x%x\n", i);
   459                 printf("Joystick has button: 0x%x\n", i);
   460 #endif
   460 #endif
   461                 joystick->hwdata->key_map[i - BTN_MISC] = joystick->nbuttons;
   461                 joystick->hwdata->key_map[i] = joystick->nbuttons;
   462                 ++joystick->nbuttons;
   462                 ++joystick->nbuttons;
   463             }
   463             }
   464         }
   464         }
   465         for (i = 0; i < ABS_MAX; ++i) {
   465         for (i = 0; i < ABS_MAX; ++i) {
   466             /* Skip hats */
   466             /* Skip hats */
   713         len /= sizeof(events[0]);
   713         len /= sizeof(events[0]);
   714         for (i = 0; i < len; ++i) {
   714         for (i = 0; i < len; ++i) {
   715             code = events[i].code;
   715             code = events[i].code;
   716             switch (events[i].type) {
   716             switch (events[i].type) {
   717             case EV_KEY:
   717             case EV_KEY:
   718                 if (code >= BTN_MISC) {
   718                 SDL_PrivateJoystickButton(joystick,
   719                     code -= BTN_MISC;
   719                                           joystick->hwdata->key_map[code],
   720                     SDL_PrivateJoystickButton(joystick,
   720                                           events[i].value);
   721                                               joystick->hwdata->key_map[code],
       
   722                                               events[i].value);
       
   723                 }
       
   724                 break;
   721                 break;
   725             case EV_ABS:
   722             case EV_ABS:
   726                 switch (code) {
   723                 switch (code) {
   727                 case ABS_HAT0X:
   724                 case ABS_HAT0X:
   728                 case ABS_HAT0Y:
   725                 case ABS_HAT0Y: