From 24cb5ce657208ed67b1a31048b56ab73497e5816 Mon Sep 17 00:00:00 2001 From: Seth Cantrell Date: Mon, 29 May 2023 23:09:55 -0400 Subject: [PATCH 1/2] Support Nimbus+ controller in mac-joypad.mm findControls() The findControls() routine was not finding several of the buttons on my Nimbus+ controller so that I could not configure those buttons in Settings > Controls > Nimbus+ A, B, X, Y, and the L and R shoulder buttons are detected by the existing code. The D-pad and the 'start' and 'select' standins are not. One odd thing that happened the first time I played with this change was that after configuring the new buttons and loading up a game the buttons seemed to be initially in a random state and so the game seemed to behave like some random buttons were held down. After pressing and releasing all the new buttons the game seemed to behave more normally. I'm not sure of my diagnosis because it only happened the one time and I didn't have an opportunity to reproduce or debug whatever happened. --- macosx/mac-joypad.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/macosx/mac-joypad.mm b/macosx/mac-joypad.mm index 2cf74035..1bd79334 100755 --- a/macosx/mac-joypad.mm +++ b/macosx/mac-joypad.mm @@ -282,7 +282,9 @@ void findControls(struct JoypadDevice &device, NSDictionary *properties, NSMutab int usagePage = [properties[@kIOHIDElementUsagePageKey] intValue]; int usage = [properties[@kIOHIDElementUsageKey] intValue]; - if (usagePage == kHIDPage_Button) + if (usagePage == kHIDPage_Button || + (usagePage == kHIDPage_GenericDesktop && (usage == kHIDUsage_GD_DPadUp || usage == kHIDUsage_GD_DPadDown || usage == kHIDUsage_GD_DPadLeft || usage == kHIDUsage_GD_DPadRight)) + || (usagePage == kHIDPage_Consumer && (usage == kHIDUsage_Csmr_ACProperties || usage == kHIDUsage_Csmr_ACExit))) { [buttons addObject:properties]; } From fa7922da4a19ef3205bb2c2f27a108284dab3d81 Mon Sep 17 00:00:00 2001 From: Seth Cantrell Date: Tue, 30 May 2023 16:39:19 -0400 Subject: [PATCH 2/2] Apply recommended changes from review https://github.com/snes9xgit/snes9x/pull/852#pullrequestreview-1451205573 --- macosx/mac-joypad.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/macosx/mac-joypad.mm b/macosx/mac-joypad.mm index 1bd79334..253238c8 100755 --- a/macosx/mac-joypad.mm +++ b/macosx/mac-joypad.mm @@ -283,8 +283,9 @@ void findControls(struct JoypadDevice &device, NSDictionary *properties, NSMutab int usagePage = [properties[@kIOHIDElementUsagePageKey] intValue]; int usage = [properties[@kIOHIDElementUsageKey] intValue]; if (usagePage == kHIDPage_Button || - (usagePage == kHIDPage_GenericDesktop && (usage == kHIDUsage_GD_DPadUp || usage == kHIDUsage_GD_DPadDown || usage == kHIDUsage_GD_DPadLeft || usage == kHIDUsage_GD_DPadRight)) - || (usagePage == kHIDPage_Consumer && (usage == kHIDUsage_Csmr_ACProperties || usage == kHIDUsage_Csmr_ACExit))) + usagePage == kHIDPage_Consumer || + (usagePage == kHIDPage_GenericDesktop && (usage == kHIDUsage_GD_DPadUp || usage == kHIDUsage_GD_DPadDown || usage == kHIDUsage_GD_DPadLeft || usage == kHIDUsage_GD_DPadRight || + usage == kHIDUsage_GD_Start || usage == kHIDUsage_GD_Select || usage == kHIDUsage_GD_SystemMainMenu))) { [buttons addObject:properties]; }