You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Swap Nintendo face buttons on macOS
This commit is contained in:
@@ -43,6 +43,7 @@ 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;
|
||||||
|
|
||||||
GameController(int p_joy_id, GCController *p_controller);
|
GameController(int p_joy_id, GCController *p_controller);
|
||||||
~GameController();
|
~GameController();
|
||||||
|
|||||||
@@ -144,6 +144,12 @@ GameController::GameController(int p_joy_id, GCController *p_controller) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)"]) {
|
||||||
|
nintendo_button_layout = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int l_joy_id = joy_id;
|
int l_joy_id = joy_id;
|
||||||
|
|
||||||
auto BUTTON = [l_joy_id](JoyButton p_button) {
|
auto BUTTON = [l_joy_id](JoyButton p_button) {
|
||||||
@@ -155,10 +161,18 @@ GameController::GameController(int p_joy_id, GCController *p_controller) :
|
|||||||
if (controller.extendedGamepad != nil) {
|
if (controller.extendedGamepad != nil) {
|
||||||
GCExtendedGamepad *gamepad = controller.extendedGamepad;
|
GCExtendedGamepad *gamepad = controller.extendedGamepad;
|
||||||
|
|
||||||
gamepad.buttonA.pressedChangedHandler = BUTTON(JoyButton::A);
|
if (nintendo_button_layout) {
|
||||||
gamepad.buttonB.pressedChangedHandler = BUTTON(JoyButton::B);
|
gamepad.buttonA.pressedChangedHandler = BUTTON(JoyButton::B);
|
||||||
gamepad.buttonX.pressedChangedHandler = BUTTON(JoyButton::X);
|
gamepad.buttonB.pressedChangedHandler = BUTTON(JoyButton::A);
|
||||||
gamepad.buttonY.pressedChangedHandler = BUTTON(JoyButton::Y);
|
gamepad.buttonX.pressedChangedHandler = BUTTON(JoyButton::Y);
|
||||||
|
gamepad.buttonY.pressedChangedHandler = BUTTON(JoyButton::X);
|
||||||
|
} else {
|
||||||
|
gamepad.buttonA.pressedChangedHandler = BUTTON(JoyButton::A);
|
||||||
|
gamepad.buttonB.pressedChangedHandler = BUTTON(JoyButton::B);
|
||||||
|
gamepad.buttonX.pressedChangedHandler = BUTTON(JoyButton::X);
|
||||||
|
gamepad.buttonY.pressedChangedHandler = BUTTON(JoyButton::Y);
|
||||||
|
}
|
||||||
|
|
||||||
gamepad.leftShoulder.pressedChangedHandler = BUTTON(JoyButton::LEFT_SHOULDER);
|
gamepad.leftShoulder.pressedChangedHandler = BUTTON(JoyButton::LEFT_SHOULDER);
|
||||||
gamepad.rightShoulder.pressedChangedHandler = BUTTON(JoyButton::RIGHT_SHOULDER);
|
gamepad.rightShoulder.pressedChangedHandler = BUTTON(JoyButton::RIGHT_SHOULDER);
|
||||||
gamepad.dpad.up.pressedChangedHandler = BUTTON(JoyButton::DPAD_UP);
|
gamepad.dpad.up.pressedChangedHandler = BUTTON(JoyButton::DPAD_UP);
|
||||||
|
|||||||
Reference in New Issue
Block a user