winnitron / WinnitronLauncher

The official Winnitron launcher! The meat and potatoes of the Winnitron.
winnitron.com
MIT License
34 stars 7 forks source link

Add support for gamepads #117

Open BenBergman opened 5 years ago

BenBergman commented 5 years ago

IPACs are kind of expensive, at least compared to the super cheap Zero Delay encoders. Those cheap encoders act as gamepads though, often emulating a PS3 controller.

Running this autohotkey script manually gets a Zero Delay joystick working with the Winnitron launcher: https://autohotkey.com/docs/misc/RemapJoystick.htm#joystick-axes

The Zero Delay buttons can be accessed with Joy1 through Joy12, similar to this: https://autohotkey.com/docs/misc/RemapJoystick.htm#different-approaches

Currently adding Joy1 to the custom key mapping crashes the launcher on start up. I'm also not sure how to add the joystick axis handling script - I tried manually adding it to RunGame.ahk a couple different ways but couldn't get it to fire the same way it does as a stand along script.

I don't have a second encoder to test with, but AHK does support multiple gamepads. To specify specific gamepads, you should just be able to prefix the name with the gamepad's number, ie 1Joy3 for gamepad 1's button 3.

mrmwiebe commented 5 years ago

Oo cool idea! Haven't heard of the Zero Delay encoders yet, great find! I agree, it would be great to get this stuff working with AHK since we're using it so much with the launcher already, but would it be possible to use another program like Joy2Key in the meantime?

Just tried J2K for the first time in a while and it looks like it's not free and has a popup on first run which might be annoying on a Winnitron booting up, so I found a list of other potential candidates: https://www.s-config.com/zero-delay-usb-joystick-encoder/

BenBergman commented 5 years ago

Yeah, those other options work too. I had to return the Zero Delay board I was borrowing, but we could probably just implement an AHK script that people run along side the Winnitron software as a separate thing to run for the time being. When I did my (quick and hacky) testing, I didn't see any conflicting behaviour running a script outside Winnitron with the Winnitron launcher.

aaronklaassen commented 5 years ago

I haven't had a chance to reproduce the error here yet, but I suspect adding this support will just be adding the gamepad/joy codes to to list of valid inputs in key_translation.json.

It'd be more work if we want to add support Network-side (ie for a game that uses a controller), but if we're just mapping game-key-press to winnitron-gamepad-button-press I think that's all we need.

BenBergman commented 5 years ago

It is slightly more complicated due to needing to map analog axis to button presses, but if a macro or something could be defined to allow easy mapping for users that would be great. The first script I linked shows how you can do axis to button mapping in AHK: https://autohotkey.com/docs/misc/RemapJoystick.htm#joystick-axes

Otherwise, yeah, the gamepad button to keyboard button mapping should be pretty much just a key_translation.json thing. In the couple minutes I had to try it I couldn't get it working, but I'm sure you guys being more familiar with the translation code will be able to sort it out.

aaronklaassen commented 5 years ago

Yeah I wanna get some of the bug fixes in and and released and then we can take a closer look at this.

BenBergman commented 5 years ago

Just tried J2K for the first time in a while and it looks like it's not free and has a popup on first run which might be annoying on a Winnitron booting up, so I found a list of other potential candidates: https://www.s-config.com/zero-delay-usb-joystick-encoder/

I just took a look at your link. It looks like these Zero Delay boards can be toggled into a digital mode so instead of behaving as an analog stick it acts as a d-pad. That should get us pretty much full compatibility through just the key_translation.json table.

mrmwiebe commented 5 years ago

Oops! That was the wrong link. I meant to link here: https://alternativeto.net/software/j2k/?platform=windows

I thought you could use one of those to get joystick input to map to Winnitron controls on keyboard and that way hopefully the AHK key swapping stuff from the network will still work properly.