Fixed detecting the wired XBox 360 controller on Linux

Also added some more debug output to detect issues
Sam Lantinga 2013-12-06 09:13:31 -08:00
parent c78476dadc
commit 4ab350d4f2
4 changed files with 23 additions and 7 deletions

View File

@ -743,6 +743,7 @@ SDL_GameControllerAddMapping( const char *mappingString )
pchGUID = SDL_PrivateGetControllerGUIDFromMappingString( mappingString );
if (!pchGUID) {
SDL_SetError("Couldn't parse GUID from %s", mappingString);
return -1;
}
#ifdef SDL_JOYSTICK_DINPUT
@ -753,17 +754,21 @@ SDL_GameControllerAddMapping( const char *mappingString )
jGUID = SDL_JoystickGetGUIDFromString(pchGUID);
SDL_free(pchGUID);
pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
pchName = SDL_PrivateGetControllerNameFromMappingString( mappingString );
if (!pchName) return -1;
if (!pchName) {
SDL_SetError("Couldn't parse name from %s", mappingString);
return -1;
}
pchMapping = SDL_PrivateGetControllerMappingFromMappingString( mappingString );
if (!pchMapping) {
SDL_SetError("Couldn't parse %s", mappingString);
SDL_free( pchName );
return -1;
}
pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
if (pControllerMapping) {
/* Update existing mapping */
SDL_free( pControllerMapping->name );

View File

@ -57,7 +57,7 @@ static const char *s_ControllerMappings [] =
"030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
"030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),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,",
"030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
"03000000de280000ff11000001000000,Valve Streaming Gamepad,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,"
"03000000de280000ff11000001000000,Valve Streaming Gamepad,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,",
"030000005e0400008e02000014010000,X360 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,",
"030000005e0400008e02000010010000,X360 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,",
"030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,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,",

View File

@ -509,10 +509,11 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
if (test_bit(i, absbit)) {
struct input_absinfo absinfo;
if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0)
if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0) {
continue;
}
#ifdef DEBUG_INPUT_EVENTS
printf("Joystick has absolute axis: %x\n", i);
printf("Joystick has absolute axis: 0x%.2x\n", i);
printf("Values = { %d, %d, %d, %d, %d }\n",
absinfo.value, absinfo.minimum, absinfo.maximum,
absinfo.fuzz, absinfo.flat);
@ -539,9 +540,17 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
}
for (i = ABS_HAT0X; i <= ABS_HAT3Y; i += 2) {
if (test_bit(i, absbit) || test_bit(i + 1, absbit)) {
struct input_absinfo absinfo;
if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0) {
continue;
}
#ifdef DEBUG_INPUT_EVENTS
printf("Joystick has hat %d\n", (i - ABS_HAT0X) / 2);
#endif
printf("Values = { %d, %d, %d, %d, %d }\n",
absinfo.value, absinfo.minimum, absinfo.maximum,
absinfo.fuzz, absinfo.flat);
#endif /* DEBUG_INPUT_EVENTS */
++joystick->nhats;
}
}

View File

@ -29,6 +29,8 @@ def write_controllers():
global controller_guids
for entry in sorted(controllers, key=lambda entry: entry[2]):
line = "".join(entry) + "\n"
if not line.endswith(",\n") and not line.endswith("*/\n"):
print "Warning: '%s' is missing a comma at the end of the line" % (line)
if (entry[1] in controller_guids):
print "Warning: entry '%s' is duplicate of entry '%s'" % (entry[2], controller_guids[entry[1]][2])
controller_guids[entry[1]] = entry