mirror of https://github.com/encounter/SDL.git
The XBox One S controller sends keys outside the standard joystick button range
This commit is contained in:
parent
6558ecdbf6
commit
aa03b9d7af
|
@ -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,",
|
"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,",
|
"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,",
|
"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,",
|
"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
|
#endif
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
|
|
|
@ -449,16 +449,16 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
|
||||||
#ifdef DEBUG_INPUT_EVENTS
|
#ifdef DEBUG_INPUT_EVENTS
|
||||||
printf("Joystick has button: 0x%x\n", i);
|
printf("Joystick has button: 0x%x\n", i);
|
||||||
#endif
|
#endif
|
||||||
joystick->hwdata->key_map[i - BTN_MISC] = joystick->nbuttons;
|
joystick->hwdata->key_map[i] = joystick->nbuttons;
|
||||||
++joystick->nbuttons;
|
++joystick->nbuttons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = BTN_MISC; i < BTN_JOYSTICK; ++i) {
|
for (i = 0; i < BTN_JOYSTICK; ++i) {
|
||||||
if (test_bit(i, keybit)) {
|
if (test_bit(i, keybit)) {
|
||||||
#ifdef DEBUG_INPUT_EVENTS
|
#ifdef DEBUG_INPUT_EVENTS
|
||||||
printf("Joystick has button: 0x%x\n", i);
|
printf("Joystick has button: 0x%x\n", i);
|
||||||
#endif
|
#endif
|
||||||
joystick->hwdata->key_map[i - BTN_MISC] = joystick->nbuttons;
|
joystick->hwdata->key_map[i] = joystick->nbuttons;
|
||||||
++joystick->nbuttons;
|
++joystick->nbuttons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -715,12 +715,9 @@ HandleInputEvents(SDL_Joystick * joystick)
|
||||||
code = events[i].code;
|
code = events[i].code;
|
||||||
switch (events[i].type) {
|
switch (events[i].type) {
|
||||||
case EV_KEY:
|
case EV_KEY:
|
||||||
if (code >= BTN_MISC) {
|
|
||||||
code -= BTN_MISC;
|
|
||||||
SDL_PrivateJoystickButton(joystick,
|
SDL_PrivateJoystickButton(joystick,
|
||||||
joystick->hwdata->key_map[code],
|
joystick->hwdata->key_map[code],
|
||||||
events[i].value);
|
events[i].value);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case EV_ABS:
|
case EV_ABS:
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ struct joystick_hwdata
|
||||||
} *balls;
|
} *balls;
|
||||||
|
|
||||||
/* Support for the Linux 2.4 unified input interface */
|
/* 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];
|
Uint8 abs_map[ABS_MAX];
|
||||||
struct axis_correct
|
struct axis_correct
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue