Swap controller mappings

This is for people involved in the developement of Snes9x, or SNES emulators in general.
BUG REPORTS BELONG IN TECH SUPPORT/BUG TRACKING!
Post Reply
cptnoremac
Snes9x White Belt
Posts: 3
Joined: Wed Dec 09, 2020 6:22 pm

Swap controller mappings

Post by cptnoremac »

Hi all,

I have the source code opened in Xcode and I'm trying to figure out the best place to make a change to how the gamepads are mapped. What I want is for the gamepad mapped to player 2 to suddenly be mapped to player 1, based on the value of a flag I have added to Settings that's flipped on a timer. I've got most of the changes working, but it's confusing trying to find where the input polling is happening and how to intercept the player 2 commands and reroute them to player 1.

I feel like I'm on the right track with some of the functions in mac-os.mm. Can anybody better at Objective-C and C++ than me point me in the right direction?

Thanks for your help
cptnoremac
Snes9x White Belt
Posts: 3
Joined: Wed Dec 09, 2020 6:22 pm

Re: Swap controller mappings

Post by cptnoremac »

Update: I got it working. I changed controls.cpp. In the S9xSetJoypadLatch function I swapped the 0 and 1 based on the flag in Settings. The Mac version of the app seems to have trouble with gamepads, as player 2 controller constantly moves left (even without my changes). So I redid it in Windows and it seems to work. I've put it on Github if anyone else wants to play around with it.

Thanks again
My fork of Snes9x: https://github.com/cptnoremac/snes9x
User avatar
OV2
Official Win32 Porter/Dev
Posts: 679
Joined: Thu Aug 30, 2007 10:15 pm

Re: Swap controller mappings

Post by OV2 »

There is already an existing function to swap input between port 1 and 2 (by default mapped to number key 6 in the windows version):

Code: Select all

S9xApplyCommand(S9xGetCommandT("SwapJoypads"),1,0);
You could simply call this in your timer.
cptnoremac
Snes9x White Belt
Posts: 3
Joined: Wed Dec 09, 2020 6:22 pm

Re: Swap controller mappings

Post by cptnoremac »

Awesome. I'll try that out. Thank you.
My fork of Snes9x: https://github.com/cptnoremac/snes9x
Post Reply