mirror of https://github.com/encounter/SDL.git
Fixed detecting the wired XBox 360 controller on Linux
Also added some more debug output to detect issues
This commit is contained in:
parent
c78476dadc
commit
4ab350d4f2
|
@ -743,6 +743,7 @@ SDL_GameControllerAddMapping( const char *mappingString )
|
||||||
|
|
||||||
pchGUID = SDL_PrivateGetControllerGUIDFromMappingString( mappingString );
|
pchGUID = SDL_PrivateGetControllerGUIDFromMappingString( mappingString );
|
||||||
if (!pchGUID) {
|
if (!pchGUID) {
|
||||||
|
SDL_SetError("Couldn't parse GUID from %s", mappingString);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef SDL_JOYSTICK_DINPUT
|
#ifdef SDL_JOYSTICK_DINPUT
|
||||||
|
@ -753,17 +754,21 @@ SDL_GameControllerAddMapping( const char *mappingString )
|
||||||
jGUID = SDL_JoystickGetGUIDFromString(pchGUID);
|
jGUID = SDL_JoystickGetGUIDFromString(pchGUID);
|
||||||
SDL_free(pchGUID);
|
SDL_free(pchGUID);
|
||||||
|
|
||||||
pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
|
|
||||||
|
|
||||||
pchName = SDL_PrivateGetControllerNameFromMappingString( mappingString );
|
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 );
|
pchMapping = SDL_PrivateGetControllerMappingFromMappingString( mappingString );
|
||||||
if (!pchMapping) {
|
if (!pchMapping) {
|
||||||
|
SDL_SetError("Couldn't parse %s", mappingString);
|
||||||
SDL_free( pchName );
|
SDL_free( pchName );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
|
||||||
|
|
||||||
if (pControllerMapping) {
|
if (pControllerMapping) {
|
||||||
/* Update existing mapping */
|
/* Update existing mapping */
|
||||||
SDL_free( pControllerMapping->name );
|
SDL_free( pControllerMapping->name );
|
||||||
|
|
|
@ -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. */
|
"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,",
|
"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,",
|
"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,",
|
"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,",
|
"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,",
|
"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,",
|
||||||
|
|
|
@ -509,10 +509,11 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
|
||||||
if (test_bit(i, absbit)) {
|
if (test_bit(i, absbit)) {
|
||||||
struct input_absinfo absinfo;
|
struct input_absinfo absinfo;
|
||||||
|
|
||||||
if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0)
|
if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
#ifdef DEBUG_INPUT_EVENTS
|
#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",
|
printf("Values = { %d, %d, %d, %d, %d }\n",
|
||||||
absinfo.value, absinfo.minimum, absinfo.maximum,
|
absinfo.value, absinfo.minimum, absinfo.maximum,
|
||||||
absinfo.fuzz, absinfo.flat);
|
absinfo.fuzz, absinfo.flat);
|
||||||
|
@ -539,9 +540,17 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
|
||||||
}
|
}
|
||||||
for (i = ABS_HAT0X; i <= ABS_HAT3Y; i += 2) {
|
for (i = ABS_HAT0X; i <= ABS_HAT3Y; i += 2) {
|
||||||
if (test_bit(i, absbit) || test_bit(i + 1, absbit)) {
|
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
|
#ifdef DEBUG_INPUT_EVENTS
|
||||||
printf("Joystick has hat %d\n", (i - ABS_HAT0X) / 2);
|
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;
|
++joystick->nhats;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ def write_controllers():
|
||||||
global controller_guids
|
global controller_guids
|
||||||
for entry in sorted(controllers, key=lambda entry: entry[2]):
|
for entry in sorted(controllers, key=lambda entry: entry[2]):
|
||||||
line = "".join(entry) + "\n"
|
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):
|
if (entry[1] in controller_guids):
|
||||||
print "Warning: entry '%s' is duplicate of entry '%s'" % (entry[2], controller_guids[entry[1]][2])
|
print "Warning: entry '%s' is duplicate of entry '%s'" % (entry[2], controller_guids[entry[1]][2])
|
||||||
controller_guids[entry[1]] = entry
|
controller_guids[entry[1]] = entry
|
||||||
|
|
Loading…
Reference in New Issue