Fixed the GameCube HIDAPI controller mapping
Fixes https://github.com/libsdl-org/SDL/issues/8617 Closes https://github.com/libsdl-org/SDL/pull/8623 Closes https://github.com/libsdl-org/SDL/pull/7930main
parent
dd984dcd9f
commit
571e9796b9
|
@ -705,7 +705,7 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_JoystickGUID guid
|
||||||
(product == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER1 ||
|
(product == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER1 ||
|
||||||
product == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER2))) {
|
product == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER2))) {
|
||||||
/* GameCube driver has 12 buttons and 6 axes */
|
/* GameCube driver has 12 buttons and 6 axes */
|
||||||
SDL_strlcat(mapping_string, "a:b0,b:b1,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3,start:b8,x:b2,y:b3,", sizeof(mapping_string));
|
SDL_strlcat(mapping_string, "a:b0,b:b1,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1~,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3~,start:b8,x:b2,y:b3,", sizeof(mapping_string));
|
||||||
} else if (vendor == USB_VENDOR_NINTENDO &&
|
} else if (vendor == USB_VENDOR_NINTENDO &&
|
||||||
(guid.data[15] == k_eSwitchDeviceInfoControllerType_HVCLeft ||
|
(guid.data[15] == k_eSwitchDeviceInfoControllerType_HVCLeft ||
|
||||||
guid.data[15] == k_eSwitchDeviceInfoControllerType_HVCRight ||
|
guid.data[15] == k_eSwitchDeviceInfoControllerType_HVCRight ||
|
||||||
|
|
|
@ -263,8 +263,8 @@ static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device
|
||||||
joystick, \
|
joystick, \
|
||||||
axis, axis_value);
|
axis, axis_value);
|
||||||
READ_AXIS(3, SDL_GAMEPAD_AXIS_LEFTX, 0)
|
READ_AXIS(3, SDL_GAMEPAD_AXIS_LEFTX, 0)
|
||||||
READ_AXIS(4, SDL_GAMEPAD_AXIS_LEFTY, 0)
|
READ_AXIS(4, SDL_GAMEPAD_AXIS_LEFTY, 1)
|
||||||
READ_AXIS(6, SDL_GAMEPAD_AXIS_RIGHTX, 1)
|
READ_AXIS(6, SDL_GAMEPAD_AXIS_RIGHTX, 0)
|
||||||
READ_AXIS(5, SDL_GAMEPAD_AXIS_RIGHTY, 1)
|
READ_AXIS(5, SDL_GAMEPAD_AXIS_RIGHTY, 1)
|
||||||
READ_AXIS(7, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, 0)
|
READ_AXIS(7, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, 0)
|
||||||
READ_AXIS(8, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, 0)
|
READ_AXIS(8, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, 0)
|
||||||
|
@ -317,9 +317,9 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device
|
||||||
button, \
|
button, \
|
||||||
(curSlot[off] & flag) ? SDL_PRESSED : SDL_RELEASED);
|
(curSlot[off] & flag) ? SDL_PRESSED : SDL_RELEASED);
|
||||||
READ_BUTTON(1, 0x01, 0) /* A */
|
READ_BUTTON(1, 0x01, 0) /* A */
|
||||||
READ_BUTTON(1, 0x04, 1) /* B */
|
READ_BUTTON(1, 0x02, 1) /* B */
|
||||||
|
READ_BUTTON(1, 0x04, 2) /* X */
|
||||||
READ_BUTTON(1, 0x08, 3) /* Y */
|
READ_BUTTON(1, 0x08, 3) /* Y */
|
||||||
READ_BUTTON(1, 0x02, 2) /* X */
|
|
||||||
READ_BUTTON(1, 0x10, 4) /* DPAD_LEFT */
|
READ_BUTTON(1, 0x10, 4) /* DPAD_LEFT */
|
||||||
READ_BUTTON(1, 0x20, 5) /* DPAD_RIGHT */
|
READ_BUTTON(1, 0x20, 5) /* DPAD_RIGHT */
|
||||||
READ_BUTTON(1, 0x40, 6) /* DPAD_DOWN */
|
READ_BUTTON(1, 0x40, 6) /* DPAD_DOWN */
|
||||||
|
@ -363,7 +363,7 @@ static SDL_bool HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||||
/* Read input packet */
|
/* Read input packet */
|
||||||
while ((size = SDL_hid_read_timeout(device->dev, packet, sizeof(packet), 0)) > 0) {
|
while ((size = SDL_hid_read_timeout(device->dev, packet, sizeof(packet), 0)) > 0) {
|
||||||
#ifdef DEBUG_GAMECUBE_PROTOCOL
|
#ifdef DEBUG_GAMECUBE_PROTOCOL
|
||||||
// HIDAPI_DumpPacket("Nintendo GameCube packet: size = %d", packet, size);
|
HIDAPI_DumpPacket("Nintendo GameCube packet: size = %d", packet, size);
|
||||||
#endif
|
#endif
|
||||||
if (ctx->pc_mode) {
|
if (ctx->pc_mode) {
|
||||||
HIDAPI_DriverGameCube_HandleJoystickPacket(device, ctx, packet, size);
|
HIDAPI_DriverGameCube_HandleJoystickPacket(device, ctx, packet, size);
|
||||||
|
|
Loading…
Reference in New Issue