Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iCade and joystick direction problem #448

Open
GeorgeMcMullen opened this issue Sep 1, 2023 · 4 comments
Open

iCade and joystick direction problem #448

GeorgeMcMullen opened this issue Sep 1, 2023 · 4 comments

Comments

@GeorgeMcMullen
Copy link

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 (

// iCade keys
). 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:

  • P1 Up: Joy 1 Right Joy 1 D-Pad Up
  • P1 Down: Joy 1 Left Joy 1 D-Pad Down
  • P1 Left: Joy 1 Down Joy 1 D-Pad Left
  • P1 Right: Joy 1 Up Joy 1 D-Pad Right

Some of my configuration is as follows:

Input Options:

  • Touch Type: I've tried Digital DPAD and Digital Stick
  • Ways: I've tried Auto, 4 Way, and 8 Way
  • External Controller: iCade or compatible

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
Copy link
Author

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
Copy link
Collaborator

ToddLa commented Sep 5, 2023

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

@GeorgeMcMullen
Copy link
Author

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: #449

@GeorgeMcMullen GeorgeMcMullen changed the title iCade and joystick direction conflict iCade and joystick direction problem Sep 6, 2023
@simonwatson
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants