Merge pull request #12710 from R-YaTian/master

libnx: Fix split joycons mode
This commit is contained in:
Autechre 2021-07-29 07:22:42 +02:00 committed by GitHub
commit 4714af546b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -312,12 +312,60 @@ static void switch_joypad_poll(void)
{
HidAnalogStickState stick_left_state = padGetStickPos(&pad_states[i], 0);
HidAnalogStickState stick_right_state = padGetStickPos(&pad_states[i], 1);
button_state[i] = padGetButtons(&pad_states[i]);
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT]
[RETRO_DEVICE_ID_ANALOG_X] = stick_left_state.x;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT]
[RETRO_DEVICE_ID_ANALOG_Y] = -stick_left_state.y;
unsigned input_split_joycon = settings->uints.input_split_joycon[i];
int pad_button = padGetButtons(&pad_states[i]);
if (input_split_joycon && !handheld) {
if (hidGetNpadDeviceType((HidNpadIdType)i) & HidDeviceTypeBits_JoyLeft) {
if (pad_button & HidNpadButton_Left)
button_state[i] = (uint16_t)HidNpadButton_B;
else if (pad_button & HidNpadButton_Up)
button_state[i] = (uint16_t)HidNpadButton_Y;
else if (pad_button & HidNpadButton_Right)
button_state[i] = (uint16_t)HidNpadButton_X;
else if (pad_button & HidNpadButton_Down)
button_state[i] = (uint16_t)HidNpadButton_A;
else if (pad_button & HidNpadButton_LeftSL)
button_state[i] = (uint16_t)HidNpadButton_L;
else if (pad_button & HidNpadButton_LeftSR)
button_state[i] = (uint16_t)HidNpadButton_R;
else
button_state[i] = pad_button;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT]
[RETRO_DEVICE_ID_ANALOG_X] = -stick_left_state.y;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT]
[RETRO_DEVICE_ID_ANALOG_Y] = -stick_left_state.x;
}
else if (hidGetNpadDeviceType((HidNpadIdType)i) & HidDeviceTypeBits_JoyRight) {
if (pad_button & HidNpadButton_A)
button_state[i] = (uint16_t)HidNpadButton_B;
else if (pad_button & HidNpadButton_B)
button_state[i] = (uint16_t)HidNpadButton_Y;
else if (pad_button & HidNpadButton_X)
button_state[i] = (uint16_t)HidNpadButton_A;
else if (pad_button & HidNpadButton_Y)
button_state[i] = (uint16_t)HidNpadButton_X;
else if (pad_button & HidNpadButton_RightSL)
button_state[i] = (uint16_t)HidNpadButton_L;
else if (pad_button & HidNpadButton_RightSR)
button_state[i] = (uint16_t)HidNpadButton_R;
else if (pad_button & HidNpadButton_StickR)
button_state[i] = (uint16_t)HidNpadButton_StickL;
else
button_state[i] = pad_button;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT]
[RETRO_DEVICE_ID_ANALOG_X] = stick_right_state.y;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT]
[RETRO_DEVICE_ID_ANALOG_Y] = stick_right_state.x;
}
}
else
{
button_state[i] = pad_button;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT]
[RETRO_DEVICE_ID_ANALOG_X] = stick_left_state.x;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT]
[RETRO_DEVICE_ID_ANALOG_Y] = -stick_left_state.y;
}
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT]
[RETRO_DEVICE_ID_ANALOG_X] = stick_right_state.x;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT]