Using an EasySMX ESM-9110 controller in XInput Mode on MorphOS
A while ago I finally managed to acquire a Mac Mini G4 1.5ghz "silent upgrade" to run MorphOS on.
After upgrading the RAM to a full 1GB, replacing the dead hard disk with an SSD (affiliate link) (via an IDE to MSATA adapter (affiliate link)) I've now decided to get a game controller for it instead of borrowing one from another machine.
MorphOS Store had a wireless controller which looked good... but the store seems to have disappeared now. Luckily I was able to identify it as the EasySMX ESM-9110 and found it on Amazon (affiliate link). So I ordered it expecting to just need to plug in the receiver, charge the controller and have it work. Unfortunately it wasn't that simple...
Initially the controller wouldn't connect to the receiver, but connecting the receiver to my Mac Mini directly instead of an unpowered hub fixed that. I imagine it probably works fine with a powered hub but I haven't tested it.
Opening the USB settings in MorphOS showed the device, but no bindings were assigned to it, and the controller didn't work in E-UAE or other software. After some experimentation I found the controller works fine in HID/DInput mode (hold the Mode button the controller for around 5 seconds and it changes between XInput and DInput modes), but the controller should work in XInput mode, so I want that to work.
After a lot more digging around, it seems there's a reason the current MorphOS (3.17 at the time of writing) XBox 360 Controller USB driver (xbox360.class) doesn't identify the controller as a valid XBox controller, so we need to force it bind to the device.
I tried forcing the binding of the device, but that refused to work:
Eventually I worked out that you have to double-click into the device, then right-click the interface and force the controller to bind to xbox360.class:
After that, click class-scan again, and it should stay selected on the class. Save the settings in the USB dialog (bottom left corner of the window) and it should be detected properly, and automatically bind the device class on boot.
This gets it close to working - the only thing we need to do now is make SDL recognize it properly. There is a file called gamecontrollerdb.txt in ENVARC:. which we need to update with a line referencing the controller and buttons.
This is the line I added to the file:
03000000242f0000b700000000000000,Xbox360 Controller,platform:MorphOS,a:b7,b:b8,x:b5,y:b6,back:b2,guide:b4,start:b3,leftstick:b9,rightstick:b10,leftshoulder:b0,rightshoulder:b1,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:+a4,righttrigger:+a5,
Once adding the line to the file, reboot and test using the testgamecontroller program in SDL extras (the SDL library archive contains it), you should see it's working:
Otherwise instead of using the config above, you can generate your own using controllermap program in SDL extras (the SDL library archive also contains it) - after mapping all the buttons it will output a line for the config (the version I used output the same line twice for some reason, but you only need to add one of the lines to gamecontrollerdb.txt):
Just remember to reboot after updating gamecontrollerdb.txt in ENVARC:, otherwise the settings might not apply.