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

Gamepad Issue #80

Closed
thunderbird32 opened this issue Jun 3, 2022 · 5 comments
Closed

Gamepad Issue #80

thunderbird32 opened this issue Jun 3, 2022 · 5 comments

Comments

@thunderbird32
Copy link

thunderbird32 commented Jun 3, 2022

When attempting to use a gamepad (8BitDo M30, Model 80HA) with SimCoupe (ver. 1.2.11) I have an odd issue. In BASIC I get the '9' character repeating indefinitely, and in games (tested in Manic Miner specifically) this manifests as if 'Up' is being pressed repeatedly.

In options I have "Device" for "Player 1" set to "Wireless Controller", and have "Controls" set to "Joystick 1". Oddly, when I set "Device" to "None" the repeating key presses continue. I have to set "Controls" to "None" to get it to stop. When I select "Joystick 2" in the "Controls" drop-down, the number that comes up in BASIC is '1' instead of '9', and in the game nothing happens (no jumping, and no buttons on the game pad do anything). I have tried the Kempston mode, but that doesn't seem to do anything (though it's possible Manic Miner doesn't support Kempston joysticks).

To my knowledge there is nothing wrong with the gamepad. It works correctly in other emulators (for instance FUSE). I have it currently connected via USB, so I know it's not an issue with Bluetooth or the battery. I've tried using an ancient USB Microsoft Sidewinder joystick (the only other device I have at hand), and that actually works correctly. Maybe SimCoupe doesn't like D-pads? Or at the very least it doesn't like how 8BitDo implemented theirs?

EDIT: This appears to also happen in Speccy's SAM Coupe emulation, so I'm not entirely sure this is an issue with SimCoupe (unless you're both using the same library for joystick control?). Though, in Speccy it's a repeated numeral '7' instead of a '9'.

@simonowen
Copy link
Owner

It's possible I'm using an axis on the device that's used for something else, causing it to give a false direction reading. I think every axis presented by the device is used for controls, and every available button becomes fire. That does allow both D-pad and analogue sticks to be used, but there may be more hints to limit the selection.

SAM's first joystick is the same as Interface 2 on the Spectrum, so 6=left, 7=right, 8=down, 9=up, 0=fire. The second joystick should be the same but for keys 1/2/3/4/5 instead, so it's strange it's a different direction. Does the controller have any sliders or other analogue controls? If so, does moving any to a central position stop it?

I'll re-check the axis selection with the controllers I have here and let you know if there's something worth trying.

@thunderbird32
Copy link
Author

No analog controls. It's basically a Sega Saturn controller as far as buttons goes (though it adds three extra tiny buttons on the face, only two of which are mappable).

If I boot the machine and it's repeating '9', I can press right on the d-pad and it starts repeating '6'. This is odd, since you say '6' should be left. Pressing left changes nothing and it continues to say '9' (or '6' depending on it's previous state). Pressing down while it is saying '6', makes it revert back to '9'. Pressing up does nothing, which is similarly odd. Pressing any of the face buttons results in a '0' being printed and the repeating stops. As soon as another d-pad direction is pressed it starts repeating again. Also, while it is stopped typing doesn't really work correctly. For instance, if I try to type "boot" I just get "bot". It won't register the second 'o'. Nor will it let me backspace more than one character. I would imagine it's fighting with the controller because if I stop typing for a few seconds the repeating numerals start again.

One last odd behavior. If it's repeating digits, and I press one of the shoulder buttons on the controller, it doesn't just print '0' and stop. Instead, it prints '0' and then starts repeating either '6' or '9'. If I press the Left should button it prints '6', and if I press the Right button it prints '9'.

Thanks for looking into this. I would guess it's just some weird way this particular controller does things. That said, I would think 8BitDo controllers sell fairly well, so it might come up again.

Let me know if there's any tests I can do.

@simonowen
Copy link
Owner

simonowen commented Jun 11, 2022

This week I was looking into switching from DirectInput to XInput, but the version compatible with Windows 7 would be a step back on the existing support. Instead I've had a closer look at what I'm using from the DirectInput controller data to see what is going wrong.

One thing I didn't like is that it converted rotational axis to joystick directions. It's a bit of an odd thing to do though it shouldn't really cause an issue. Still, I've taken it out to see if it helps.

Could you please see if this build is any better? If not I'll cut things down further. The simcoupe-zip archive contains both 32-bit and 64-bit versions, so pick whichever is appropriate for your system (probably x64).

On my XBox 360 controller the left stick is a normal analogue x/y axis and the d-pad is seen as a hat. I'm reading all 4 possible hats, but if there's still an issue I could reduce that to use only the first. My Thrustmaster HOTAS also seems to behave as expected, even before the changes.

@thunderbird32
Copy link
Author

Yes! The new build you linked works perfectly. I booted into Manic Miner and can play the game as expected. Also, I don't get numbers printing in BASIC anymore unless I actually press the buttons (as expected). Joystick still doesn't seem to work in Prince of Persia, but I'm not convinced that game actually supports joysticks (in spite of what I've read online). I'd say this issue is resolved.

@simonowen
Copy link
Owner

Thanks for the quick test! I'll get that merged in for the next official release.

I suspect there could still be an issue with the 8BitDo gamepad reporting an axis it doesn't have. If it's plug-n-play with the standard USB HID support then a descriptor on the device itself is probably in error. If it has a driver it could be something in the INF instead. Either way it's supposed to report 0 for unsupported axis and the test results suggest a direction was showing. Most software probably won't look at the rotation axes so it's not a problem, and it's good to have SimCoupe in that category now.

You're right that Prince of Persia has no joystick support. I had a look at it in the debugger and it's definitely not reading the key rows for either joystick. Strange for a major SAM title -- probably wouldn't be hard to add in though.

simonowen added a commit that referenced this issue Jul 13, 2022
The 8BitDo M30 gamepad shows a non-centred reading on the rotation axes,
causing unwanted movement. These are unlikely to be useful for most devices
so we can safely ignore them.
simonowen added a commit that referenced this issue Jan 14, 2024
Changed the SDL joystick processing to match the Win32 changes in 2a268b0
for issue #80.

We now only use axis 0+1 for x+y movement to avoid phantom inputs causing
problems. Future versions may switch to the new high-level controller API.
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

2 participants