Merge pull request #104726 from Meorge/bugfix/reversed-buttons-do-not-spark-joy-con
Fix Apple's incorrect mapping of Joy-Con (L) and Joy-Con (R) face buttons
This commit is contained in:
@ -46,7 +46,8 @@ struct GameController {
|
|||||||
RumbleContext *rumble_context API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) = nil;
|
RumbleContext *rumble_context API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) = nil;
|
||||||
NSInteger ff_effect_timestamp = 0;
|
NSInteger ff_effect_timestamp = 0;
|
||||||
bool force_feedback = false;
|
bool force_feedback = false;
|
||||||
bool nintendo_button_layout = false;
|
bool double_nintendo_joycon_layout = false;
|
||||||
|
bool single_nintendo_joycon_layout = false;
|
||||||
|
|
||||||
bool axis_changed[(int)JoyAxis::MAX];
|
bool axis_changed[(int)JoyAxis::MAX];
|
||||||
double axis_value[(int)JoyAxis::MAX];
|
double axis_value[(int)JoyAxis::MAX];
|
||||||
|
|||||||
@ -151,7 +151,11 @@ GameController::GameController(int p_joy_id, GCController *p_controller) :
|
|||||||
|
|
||||||
if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) {
|
if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) {
|
||||||
if ([controller.productCategory isEqualToString:@"Switch Pro Controller"] || [controller.productCategory isEqualToString:@"Nintendo Switch Joy-Con (L/R)"]) {
|
if ([controller.productCategory isEqualToString:@"Switch Pro Controller"] || [controller.productCategory isEqualToString:@"Nintendo Switch Joy-Con (L/R)"]) {
|
||||||
nintendo_button_layout = true;
|
double_nintendo_joycon_layout = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([controller.productCategory isEqualToString:@"Nintendo Switch Joy-Con (L)"] || [controller.productCategory isEqualToString:@"Nintendo Switch Joy-Con (R)"]) {
|
||||||
|
single_nintendo_joycon_layout = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +211,7 @@ GameController::GameController(int p_joy_id, GCController *p_controller) :
|
|||||||
GCControllerButtonInput *buttonB = profile.buttons[GCInputButtonB];
|
GCControllerButtonInput *buttonB = profile.buttons[GCInputButtonB];
|
||||||
GCControllerButtonInput *buttonX = profile.buttons[GCInputButtonX];
|
GCControllerButtonInput *buttonX = profile.buttons[GCInputButtonX];
|
||||||
GCControllerButtonInput *buttonY = profile.buttons[GCInputButtonY];
|
GCControllerButtonInput *buttonY = profile.buttons[GCInputButtonY];
|
||||||
if (nintendo_button_layout) {
|
if (double_nintendo_joycon_layout) {
|
||||||
if (buttonA) {
|
if (buttonA) {
|
||||||
buttonA.pressedChangedHandler = BUTTON(JoyButton::B);
|
buttonA.pressedChangedHandler = BUTTON(JoyButton::B);
|
||||||
}
|
}
|
||||||
@ -220,6 +224,19 @@ GameController::GameController(int p_joy_id, GCController *p_controller) :
|
|||||||
if (buttonY) {
|
if (buttonY) {
|
||||||
buttonY.pressedChangedHandler = BUTTON(JoyButton::X);
|
buttonY.pressedChangedHandler = BUTTON(JoyButton::X);
|
||||||
}
|
}
|
||||||
|
} else if (single_nintendo_joycon_layout) {
|
||||||
|
if (buttonA) {
|
||||||
|
buttonA.pressedChangedHandler = BUTTON(JoyButton::A);
|
||||||
|
}
|
||||||
|
if (buttonB) {
|
||||||
|
buttonB.pressedChangedHandler = BUTTON(JoyButton::X);
|
||||||
|
}
|
||||||
|
if (buttonX) {
|
||||||
|
buttonX.pressedChangedHandler = BUTTON(JoyButton::B);
|
||||||
|
}
|
||||||
|
if (buttonY) {
|
||||||
|
buttonY.pressedChangedHandler = BUTTON(JoyButton::Y);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (buttonA) {
|
if (buttonA) {
|
||||||
buttonA.pressedChangedHandler = BUTTON(JoyButton::A);
|
buttonA.pressedChangedHandler = BUTTON(JoyButton::A);
|
||||||
@ -326,11 +343,16 @@ GameController::GameController(int p_joy_id, GCController *p_controller) :
|
|||||||
} else if (controller.extendedGamepad != nil) {
|
} else if (controller.extendedGamepad != nil) {
|
||||||
GCExtendedGamepad *gamepad = controller.extendedGamepad;
|
GCExtendedGamepad *gamepad = controller.extendedGamepad;
|
||||||
|
|
||||||
if (nintendo_button_layout) {
|
if (double_nintendo_joycon_layout) {
|
||||||
gamepad.buttonA.pressedChangedHandler = BUTTON(JoyButton::B);
|
gamepad.buttonA.pressedChangedHandler = BUTTON(JoyButton::B);
|
||||||
gamepad.buttonB.pressedChangedHandler = BUTTON(JoyButton::A);
|
gamepad.buttonB.pressedChangedHandler = BUTTON(JoyButton::A);
|
||||||
gamepad.buttonX.pressedChangedHandler = BUTTON(JoyButton::Y);
|
gamepad.buttonX.pressedChangedHandler = BUTTON(JoyButton::Y);
|
||||||
gamepad.buttonY.pressedChangedHandler = BUTTON(JoyButton::X);
|
gamepad.buttonY.pressedChangedHandler = BUTTON(JoyButton::X);
|
||||||
|
} else if (single_nintendo_joycon_layout) {
|
||||||
|
gamepad.buttonA.pressedChangedHandler = BUTTON(JoyButton::A);
|
||||||
|
gamepad.buttonB.pressedChangedHandler = BUTTON(JoyButton::X);
|
||||||
|
gamepad.buttonX.pressedChangedHandler = BUTTON(JoyButton::B);
|
||||||
|
gamepad.buttonY.pressedChangedHandler = BUTTON(JoyButton::Y);
|
||||||
} else {
|
} else {
|
||||||
gamepad.buttonA.pressedChangedHandler = BUTTON(JoyButton::A);
|
gamepad.buttonA.pressedChangedHandler = BUTTON(JoyButton::A);
|
||||||
gamepad.buttonB.pressedChangedHandler = BUTTON(JoyButton::B);
|
gamepad.buttonB.pressedChangedHandler = BUTTON(JoyButton::B);
|
||||||
|
|||||||
Reference in New Issue
Block a user