Coren
Posts: 1
Joined: Sat Jul 30, 2022 4:47 pm

evdev input module [Linux]

Hey all,

I've written a (preliminary, still experimental) module for SDLmame/Linux that directly maps input even devices (/dev/input/event*) as inputs into mame; and I'd appreciate feedback and critique.

The source is on github: https://github.com/Cauren/mame
(It's a small patch: two files with minor changes and one new file)

Why?
* Support for devices beyond what SDL's very limited abstraction can cope with (mice with more than two axes being my most immediate concern);
* It's more universal: any HID that provides anything that looks like axes or buttons will work; and
* It minimizes input latency: events are gotten directly from the kernel with no layer of extra polling or caching. This may be a marginal gain in many/most cases but it's there

How?
* the mame process needs to have read access to device files in /dev/input; most distributions use a group with permission ("input" under debians for instance) -- make certain the mame process is a member of that group
* set the provider for the devices you want to use to "evdev" (e.g.: -keyboardprovider evdev)
* the driver will attempt to map available devices according to their types automatically (mouse-like devices as mice, etc) but you can explicitly map devices by name or ID as you would under the sdl provider (with -joy_idxN and -keyb_idxN and the like)
* If you start mame with -v you'll get some useful output as the driver identifies devices (including their ID for mapping and the like)

What's left?
* Right now, I use polling with nonblocking reads to get events from the kernel; this is probably a lot more context switches than we want/need in practice. I'll probably switch to a reader thread that does one big select() with every live device
* Error handling is minimal at the moment, this needs more graceful coping when something breaks
* Maybe not rely on SDL options? There is no actual dependency on SDL at all otherwise, but I expect that in practice all Linux builds are SDL builds?

Return to “Work In Progress (WIP)”