@@ -151,7 +151,11 @@ void play_strong_pattern(CHHapticPattern *p_pattern) {
151151
152152 if (@available (macOS 10.15 , iOS 13.0 , tvOS 13.0 , *)) {
153153 if ([controller.productCategory isEqualToString: @" Switch Pro Controller" ] || [controller.productCategory isEqualToString: @" Nintendo Switch Joy-Con (L/R)" ]) {
154- nintendo_button_layout = true ;
154+ double_nintendo_joycon_layout = true ;
155+ }
156+
157+ if ([controller.productCategory isEqualToString: @" Nintendo Switch Joy-Con (L)" ] || [controller.productCategory isEqualToString: @" Nintendo Switch Joy-Con (R)" ]) {
158+ single_nintendo_joycon_layout = true ;
155159 }
156160 }
157161
@@ -207,7 +211,7 @@ void play_strong_pattern(CHHapticPattern *p_pattern) {
207211 GCControllerButtonInput *buttonB = profile.buttons [GCInputButtonB];
208212 GCControllerButtonInput *buttonX = profile.buttons [GCInputButtonX];
209213 GCControllerButtonInput *buttonY = profile.buttons [GCInputButtonY];
210- if (nintendo_button_layout ) {
214+ if (double_nintendo_joycon_layout ) {
211215 if (buttonA) {
212216 buttonA.pressedChangedHandler = BUTTON (JoyButton::B);
213217 }
@@ -220,6 +224,19 @@ void play_strong_pattern(CHHapticPattern *p_pattern) {
220224 if (buttonY) {
221225 buttonY.pressedChangedHandler = BUTTON (JoyButton::X);
222226 }
227+ } else if (single_nintendo_joycon_layout) {
228+ if (buttonA) {
229+ buttonA.pressedChangedHandler = BUTTON (JoyButton::A);
230+ }
231+ if (buttonB) {
232+ buttonB.pressedChangedHandler = BUTTON (JoyButton::X);
233+ }
234+ if (buttonX) {
235+ buttonX.pressedChangedHandler = BUTTON (JoyButton::B);
236+ }
237+ if (buttonY) {
238+ buttonY.pressedChangedHandler = BUTTON (JoyButton::Y);
239+ }
223240 } else {
224241 if (buttonA) {
225242 buttonA.pressedChangedHandler = BUTTON (JoyButton::A);
@@ -326,11 +343,16 @@ void play_strong_pattern(CHHapticPattern *p_pattern) {
326343 } else if (controller.extendedGamepad != nil ) {
327344 GCExtendedGamepad *gamepad = controller.extendedGamepad ;
328345
329- if (nintendo_button_layout ) {
346+ if (double_nintendo_joycon_layout ) {
330347 gamepad.buttonA .pressedChangedHandler = BUTTON (JoyButton::B);
331348 gamepad.buttonB .pressedChangedHandler = BUTTON (JoyButton::A);
332349 gamepad.buttonX .pressedChangedHandler = BUTTON (JoyButton::Y);
333350 gamepad.buttonY .pressedChangedHandler = BUTTON (JoyButton::X);
351+ } else if (single_nintendo_joycon_layout) {
352+ gamepad.buttonA .pressedChangedHandler = BUTTON (JoyButton::A);
353+ gamepad.buttonB .pressedChangedHandler = BUTTON (JoyButton::X);
354+ gamepad.buttonX .pressedChangedHandler = BUTTON (JoyButton::B);
355+ gamepad.buttonY .pressedChangedHandler = BUTTON (JoyButton::Y);
334356 } else {
335357 gamepad.buttonA .pressedChangedHandler = BUTTON (JoyButton::A);
336358 gamepad.buttonB .pressedChangedHandler = BUTTON (JoyButton::B);
0 commit comments