The XBox One S controller sends keys outside the standard joystick button range

This commit is contained in:
Sam Lantinga 2016-11-22 22:14:28 -08:00
parent 6558ecdbf6
commit aa03b9d7af
3 changed files with 7 additions and 11 deletions

View File

@ -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__)

View File

@ -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;
}
}
@ -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) {

View File

@ -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
{