jgeumlek / MoltenGamepad

Flexible Linux input device translator, geared for gamepads
MIT License
280 stars 42 forks source link

Is there a way to programatically press a virtual gamepads buttons? #103

Open patrickcorrigan opened 2 years ago

patrickcorrigan commented 2 years ago

I'm using moltenGamepad it works great. Is there a way I can send commands to the daemon and have it press buttons on the virtual gamepads?

patrickcorrigan commented 2 years ago

Can I just write to device?

jgeumlek commented 2 years ago

Sorry for a late reply.

At the moment, this is unsupported. To directly press button on a virtual gamepad, this is done by writing input_event structs to the file descriptors held by the virtual pad, which would be done inside the MG process.

I vaguely had plans at some point to support this, but never decided on a good way of doing this. introducing a command like "press EV_KEY BTN_SOUTH 1 virtpad1" might not be too hard to code, but I doubt if whatever programmatic input source you have in mind wants to submit commandline commands like that all the time.

Another approach is writing an input plugin that creates a fake input source, of which you control how it decides to generate events. These can then be translated/allocated to slots like any other input source. MG supports allocating two or more devices to a virtpad, so this fake device can output events on top of a physical device too. This sounds cleaner, but again, I have no clue what would be the best interface for those fake input devices.