Skip to content

Commit e4b763f

Browse files
endriftslouken
authored andcommitted
switch2: Enable grip buttons on charging grip
1 parent b152c9f commit e4b763f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/joystick/hidapi/SDL_hidapi_switch2.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ static bool HIDAPI_DriverSwitch2_InitUSB(SDL_HIDAPI_Device *device)
385385
(Uint8[]) { // Unknown purpose
386386
0x11, 0x91, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0,
387387
},
388+
(Uint8[]) { // Unknown purpose
389+
0x11, 0x91, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0,
390+
},
388391
(Uint8[]) { // Set rumble data?
389392
0x0a, 0x91, 0x00, 0x08, 0x00, 0x14, 0x00, 0x00,
390393
0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@@ -397,9 +400,18 @@ static bool HIDAPI_DriverSwitch2_InitUSB(SDL_HIDAPI_Device *device)
397400
(Uint8[]) { // Unknown purpose
398401
0x10, 0x91, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0,
399402
},
403+
(Uint8[]) { // Unknown purpose
404+
0x01, 0x91, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0,
405+
},
400406
(Uint8[]) { // Enable rumble
401407
0x01, 0x91, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0,
402408
},
409+
(Uint8[]) { // Unknown purpose
410+
0x8, 0x91, 0x0, 0x1, 0x0, 0x4, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0,
411+
},
412+
(Uint8[]) { // Enable grip buttons on charging grip
413+
0x8, 0x91, 0x0, 0x2, 0x0, 0x4, 0x0, 0x0, 0x01, 0x0, 0x0, 0x0,
414+
},
403415
(Uint8[]) { // Set report format
404416
0x03, 0x91, 0x00, 0x0a, 0x00, 0x04, 0x00, 0x00,
405417
0x05, 0x00, 0x00, 0x00
@@ -717,6 +729,10 @@ static void HandleCombinedControllerStateL(Uint64 timestamp, SDL_Joystick *joyst
717729
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, ((data[7] & 0x40) != 0));
718730
}
719731

732+
if (data[8] != ctx->last_state[8]) {
733+
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_SWITCH2_JOYCON_LEFT_PADDLE1, ((data[8] & 0x02) != 0));
734+
}
735+
720736
Sint16 axis = (data[7] & 0x80) ? 32767 : -32768;
721737
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
722738

@@ -795,6 +811,10 @@ static void HandleCombinedControllerStateR(Uint64 timestamp, SDL_Joystick *joyst
795811
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_SWITCH2_JOYCON_C, ((data[6] & 0x40) != 0));
796812
}
797813

814+
if (data[8] != ctx->last_state[8]) {
815+
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_SWITCH2_JOYCON_RIGHT_PADDLE1, ((data[8] & 0x01) != 0));
816+
}
817+
798818
Sint16 axis = (data[5] & 0x80) ? 32767 : -32768;
799819
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
800820

0 commit comments

Comments
 (0)