Driver mk_arcade_joystick, multiple MCP23017 and per MCP button mapping?
-
I am currently removing some technical debt in the
mk_arcade_joystick_rpi
[1] module. I noticed (also in the current version) that when using more than one MCP23017 the button configuration from ES will end up in the same fileMCP23017 Controller.cfg
(in/opt/retropie/configs/all/retroarch-joypads
) as themk_arcade_joystick
driver only reportsMCP23017 Controller
as string identifier.From my understanding this means it is impossible to have different button configurations for each MCP?
If yes, then I can provide a change that enumerates the MCPs identified and provides the information to upper layers. The filenames then could contain the i2c address (e.g. 0x20, 0x21), and the ES button config would read
MCP23017 Controller 0x20.cfg
,MCP23017 Controller 0x21.cfg
. This would allow different "per MCP" button configurations, right?Tagging @mitu, as the fork in your repo from recalbox is currently used in RetroPie.
-
I am currently removing some technical debt in the
mk_arcade_joystick_rpi
[1] module. [...]The entire module is a technical debt :). Ideally it should be rewritten using the GPIO framework that's part of the Linux kernel.
From my understanding this means it is impossible to have different button configurations for each MCP?
That's correct. Note however that with current RetroPie version, the input's vendor/product IDs are also added to the
.cfg
file, which makes the filename match requirement a bit more lax. But I don't think it makes a difference for this driver.If yes, then I can provide a change that enumerates the MCPs identified and provides the information to upper layers. The filenames then could contain the i2c address (e.g. 0x20, 0x21), and the ES button config would read
MCP23017 Controller 0x20.cfg
,MCP23017 Controller 0x21.cfg
. This would allow different "per MCP" button configurations, right?Is this really necessary - are the MCP 'hot-pluggable' so that you can have multiple (physical) configurations without removing or adding a port expander ?
Tagging @mitu, as the fork in your repo from recalbox is currently used in RetroPie.
I'm open to any improvements you may have - I don't have the hardware to test, so as long as there's a tested improvement I'm happy to accept it.
-
That's even better to rewrite the driver, sure. Sounds like a doable challenge, but it will take me some time. I agree, the driver was initiated before Kernel 4.8 (before the GPIO API) and while I did some changes it still was odd code and looked cumbersome. Unfortunately the other GPIO drivers (e.g. db9_gpio_rpi) share the same fate/have a similar codebase.
Currently the vendor and product are hardwired in the driver ("1" and "MCP 23017 Controller"), usually they are not used like USB pluggable devices. The different button assignments for multiple MCP is more a corner case. I will start with the regular case that any MCP connected controller uses the same button mapping in ES.
I am also thinking about some test setup for before/after tests like the guy from https://inputlag.science/. If someone knows a setup for a Rpi, please let me know.
Once I have a well tested rewritten driver I will ask for additional testers here.
Then you will find a PR in your repo, @mitu -
@Lolonois said in Driver mk_arcade_joystick, multiple MCP23017 and per MCP button mapping?:
Sounds like a doable challenge, but it will take me some time.
You can use the
gpio-keys
module as an example. In theory, you create an DT fragment and don't write a driver at all, but in this case you need the GPIO to emit gamepad events instead of keyboard events. -
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.