@@ -143,6 +143,13 @@ void play_strong_pattern(CHHapticPattern *p_pattern) {
143
143
force_feedback = rumble_context->has_motors ();
144
144
}
145
145
}
146
+
147
+ if (@available (macOS 10.15 , iOS 13.0 , tvOS 13.0 , *)) {
148
+ if ([controller.productCategory isEqualToString: @" Switch Pro Controller" ]
149
+ || [controller.productCategory isEqualToString: @" Nintendo Switch Joy-Con (L/R)" ]) {
150
+ nintendo_button_layout = true ;
151
+ }
152
+ }
146
153
147
154
int l_joy_id = joy_id;
148
155
@@ -155,10 +162,18 @@ void play_strong_pattern(CHHapticPattern *p_pattern) {
155
162
if (controller.extendedGamepad != nil ) {
156
163
GCExtendedGamepad *gamepad = controller.extendedGamepad ;
157
164
158
- gamepad.buttonA .pressedChangedHandler = BUTTON (JoyButton::A);
159
- gamepad.buttonB .pressedChangedHandler = BUTTON (JoyButton::B);
160
- gamepad.buttonX .pressedChangedHandler = BUTTON (JoyButton::X);
161
- gamepad.buttonY .pressedChangedHandler = BUTTON (JoyButton::Y);
165
+ if (nintendo_button_layout) {
166
+ gamepad.buttonA .pressedChangedHandler = BUTTON (JoyButton::B);
167
+ gamepad.buttonB .pressedChangedHandler = BUTTON (JoyButton::A);
168
+ gamepad.buttonX .pressedChangedHandler = BUTTON (JoyButton::Y);
169
+ gamepad.buttonY .pressedChangedHandler = BUTTON (JoyButton::X);
170
+ } else {
171
+ gamepad.buttonA .pressedChangedHandler = BUTTON (JoyButton::A);
172
+ gamepad.buttonB .pressedChangedHandler = BUTTON (JoyButton::B);
173
+ gamepad.buttonX .pressedChangedHandler = BUTTON (JoyButton::X);
174
+ gamepad.buttonY .pressedChangedHandler = BUTTON (JoyButton::Y);
175
+ }
176
+
162
177
gamepad.leftShoulder .pressedChangedHandler = BUTTON (JoyButton::LEFT_SHOULDER);
163
178
gamepad.rightShoulder .pressedChangedHandler = BUTTON (JoyButton::RIGHT_SHOULDER);
164
179
gamepad.dpad .up .pressedChangedHandler = BUTTON (JoyButton::DPAD_UP);
0 commit comments