evdev.looks_like_stick

evdev

looks_like_stick(dev) -> stick

Check whether a device is a stick or a gamepad

dev needs axes and buttons, each keyed by code, as an open device has them. Any true value marks a code, so plain tables serve.

True when the device reports ABS_X, ABS_Y and one key udev counts as a joystick button:

A touchscreen and a touchpad report X and Y too, but their keys sit in the digitizer block, 0x140 to 0x14f, so neither passes. A mouse with more than sixteen buttons runs into the joystick range. It reports 0x11f, the code below BTN_JOYSTICK, and a device with that code is never a stick.