yoshisuga / MAME4iOS

Multiple Arcade Machine Emulator for iOS, iPadOS, tvOS, macOS (Catalyst)
Other
667 stars 105 forks source link

iCade and joystick direction problem #448

Open GeorgeMcMullen opened 1 year ago

GeorgeMcMullen commented 1 year ago

Hello,

I'm currently running an iPad 9th Generation on iPadOS 15.5. I have an Ion iCade which is configured and verified to be working. If I open up Notes and use the joystick and buttons, it outputs the correct keys for key-down and key-up sequences as per the documentation and code comments (https://github.com/yoshisuga/MAME4iOS/blob/0a3641e5ceca555d6928147c956788a74bb98e53/iOS/KeyboardView.m#L123). I'm compiling and installing myself via XCode.

The problem arises when I try to use the joystick. The direction I press the joystick does not correlate to the graphical joystick's direction on the screen or what gets sent to MAME. If I switch the view to D-Pad, the directions do match, but the incorrect joystick direction is still being sent. Trying to reconfigure MAME does not work because the joystick events are still being sent. Here is what my MAME Player 1 Controls configuration looks like:

Some of my configuration is as follows:

Input Options:

I've not found anything in the code that would cause this. I'd appreciate the help if possible. Let me know if you need any further detail. Thank you!

GeorgeMcMullen commented 1 year ago

After a little more investigation, I found the following lines (in the same file and function as previously mentioned: KeyboardView.m:iCadeKey:

https://github.com/yoshisuga/MAME4iOS/blob/0a3641e5ceca555d6928147c956788a74bb98e53/iOS/KeyboardView.m#L587C2-L588C106

It seems as though the x and y coordinates for the analog joystick are switched, where MYOSD_UP/MYOSD_DOWN is being used for myosd_pad_x and MYOSD_RIGHT/MYOSD_LEFT are being used for myosd_pad_y. Switching x and y seems to resolve the issue, though I don't yet know how this affects other things.

    myosd_pad_y = (myosd_pad_status & MYOSD_UP)    ? +1.0 : (myosd_pad_status & MYOSD_DOWN) ? -1.0 : 0.0;
    myosd_pad_x = (myosd_pad_status & MYOSD_RIGHT) ? +1.0 : (myosd_pad_status & MYOSD_LEFT) ? -1.0 : 0.0;
ToddLa commented 1 year ago

Wow this might be totaly busted? If so it has been backward for a while.....

GeorgeMcMullen commented 1 year ago

Yeah. The iCade is pretty old though, so testing new functionality against it is probably getting hard and harder. The prior git blame shows that the x and y were correct, so it was probably just a simple mistake.

Also I found similar code in AnalogStick.m but the directions are correct. So it's probably safe to get X and Y in the proper place.

https://github.com/yoshisuga/MAME4iOS/blob/master/iOS/AnalogStick.m#L187C1-L188C114

I created a pull request to fix the code: https://github.com/yoshisuga/MAME4iOS/pull/449

simonwatson commented 1 year ago

I hit the same problem, found this issue, and was very grateful for @GeorgeMcMullen's PR which fixed the issue for me. Thanks! It'd be great to merge the PR.