Page 1 of 1

Swap controller mappings

Posted: Wed Dec 09, 2020 6:37 pm
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

Re: Swap controller mappings

Posted: Thu Dec 10, 2020 4:45 pm
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

Re: Swap controller mappings

Posted: Fri Dec 11, 2020 11:45 am
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.

Re: Swap controller mappings

Posted: Fri Dec 11, 2020 11:55 pm
by cptnoremac
Awesome. I'll try that out. Thank you.