Skip to content

Commit

Permalink
The XBox One S controller sends keys outside the standard joystick bu…
Browse files Browse the repository at this point in the history
…tton range
  • Loading branch information
slouken committed Nov 23, 2016
1 parent 6558ecd commit aa03b9d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/joystick/SDL_gamecontrollerdb.h
Expand Up @@ -104,7 +104,6 @@ static const char *s_ControllerMappings [] =
"03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"050000005e040000e002000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"050000005e040000fd02000003090000,Xbox One Wireless Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,",
"030000005e040000d102000001010000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
#endif
#if defined(__ANDROID__)
Expand Down
15 changes: 6 additions & 9 deletions src/joystick/linux/SDL_sysjoystick.c
Expand Up @@ -449,16 +449,16 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
#ifdef DEBUG_INPUT_EVENTS
printf("Joystick has button: 0x%x\n", i);
#endif
joystick->hwdata->key_map[i - BTN_MISC] = joystick->nbuttons;
joystick->hwdata->key_map[i] = joystick->nbuttons;
++joystick->nbuttons;
}
}
for (i = BTN_MISC; i < BTN_JOYSTICK; ++i) {
for (i = 0; i < BTN_JOYSTICK; ++i) {
if (test_bit(i, keybit)) {
#ifdef DEBUG_INPUT_EVENTS
printf("Joystick has button: 0x%x\n", i);
#endif
joystick->hwdata->key_map[i - BTN_MISC] = joystick->nbuttons;
joystick->hwdata->key_map[i] = joystick->nbuttons;
++joystick->nbuttons;
}
}
Expand Down Expand Up @@ -715,12 +715,9 @@ HandleInputEvents(SDL_Joystick * joystick)
code = events[i].code;
switch (events[i].type) {
case EV_KEY:
if (code >= BTN_MISC) {
code -= BTN_MISC;
SDL_PrivateJoystickButton(joystick,
joystick->hwdata->key_map[code],
events[i].value);
}
SDL_PrivateJoystickButton(joystick,
joystick->hwdata->key_map[code],
events[i].value);
break;
case EV_ABS:
switch (code) {
Expand Down
2 changes: 1 addition & 1 deletion src/joystick/linux/SDL_sysjoystick_c.h
Expand Up @@ -43,7 +43,7 @@ struct joystick_hwdata
} *balls;

/* Support for the Linux 2.4 unified input interface */
Uint8 key_map[KEY_MAX - BTN_MISC];
Uint8 key_map[KEY_MAX];
Uint8 abs_map[ABS_MAX];
struct axis_correct
{
Expand Down

0 comments on commit aa03b9d

Please sign in to comment.