beebem-windows
beebem-windows copied to clipboard
Support for Xbox controllers
Have had a couple of requests recently for adding support for use of Xbox controllers with BeebEm. I guess some of the Xbox inputs could be mapped to the analogue joystick inputs of the Beeb. The Win32 joySetCapture() implemented in BeebEm does not work with Xbox controllers.
Suggest that this issue is re-worded as "Support for XInput to emulate Analogue port input". This would allow for any XInput compatible controllers to be used, not just specifically XBox controllers.
One could raise a similar feature request for DirectInput to allow for use of a wider range of legacy controllers, but this has more complexity to implement. XInput support would be higher priority for me.
Having read the Analogue port docs here http://chrisacorns.computinghistory.org.uk/docs/Acorn/AN/021.pdf I think this should be pretty straight-forward. When I have time, I may have a go at this, but I have some other features to contribute first.
Does XInput still only support the 360 controller, if so, maybe DirectInput might be better as it supports all joysticks inc the 360 (apart from mapping the triggers together) AFAIK, but I haven't used XInput for nearly 10 years!
Two things:
-
the original request was for Xbox controllers and, effectively Xbox=XInput. Xbox controllers don’t support DirectInput at all.
-
XInput supports the newer Xbox controllers too, not just 360 ones. It has also garnered a lot more support from third parties over the years - it’s effectively become the defacto standard and Microsoft only continue to support DirectInput for edge cases. As a result, almost all the typical games controllers support it rather than DirectInput. (E.g. the 8bitDo line and similar). DirectInput has largely fallen out of favour for standard handheld controllers, but does get used for things like HOTAS and specialist controllers in cases where more axes or buttons are needed than XInput supports.
XInput is far superior in its analogue reading stability and ability to handle multiple controllers and should give wide support for the majority of people. People wanting to use PlayStation controllers will already be perfectly comfortable with the necessary software to convert its standard to XInput. Only people with 20 year old controllers will be disappointed with the lack of DirectInput support.
Thanks for the update - I did say it had been a long time.
I have just checked and my 360 controller is using the default driver and the analogue channels work correctly with BeebEm 416 (and 414 joySetCapture) although I am on Win7.
Please ignore the rest of this with regard to this issue, I am including it for background info.
I thought that the 360 controller was always supported by joySetCapture and DInput, but to encourage the move, the triggers are presented as a single analogue channel and oppose each other such that you can only really use one (not that that matters here). There are a few custom drivers that "fixed" this, but I haven't used them for years. Having run several DirectX Driver teams, I know how newer APIs can be an improvement, but also that the old APIs are often just redirected to the new ones internally.
I have always used all my controllers inc my 360 controllers through joySetCapture or DirectInput (when I wanted the name). I have a HORI fighting stick mini 3 (PS3) that I use on my PC, but can't find an XInput driver - maybe I just haven't looked hard enough - DInput works fine. I still use Win7 and do have a selection of up to 40 year old controllers, most don't work as they are not USB, but are fine on my old XP machine.
joySetCapture info available thought joySetCapture for 360 and HORI PS3 mini: -joy:0 MID 1118 PID 654 Axes 5/6 btn 10/32 X:0..65535 Y:0..65535 Z:0..65535 R:0..65535 U:0..65535 POV 0,9000,18000,27000 -joy:1 MID 3853 PID 64 Axes 4/6 btn 13/32 X:0..65535 Y:0..65535 Z:0..65535 R:0..65535 POV 0,9000,18000,27000 This does lack the system supported configurability of XInput, the 360 controller is as expected. The PS3 one is not!
I'd be happy to take a look at implementing this, as well as integrating https://github.com/stardot/beebem-windows/pull/44, which is related, but I don't have the controller hardware to test with.
In issue #73, @richard-broadhurst asked:
Do you know which platform that the 360 controller doesn't work in analogue mode? I'm guessing win 10, but wondering if it isn't something else. It would be a shame to break any existing controllers for no reason.
and followed up with:
I'm not sure what he is saying as the current joyXxx code can access 5 analogue channels and I think 10 buttons - I attached the numbers. If win 10 has removed 360 controller support from joyXxx then it makes sense. Either way, xinput isn't needed as the current code supports every controller that I know of on Windows and has for decades. If the request is to add the second thumb stick as joystick 2, again the current API supports that.