File: joystick.py

package info (click to toggle)
python-uinput 1.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 320 kB
  • sloc: python: 929; ansic: 373; makefile: 31; sh: 1
file content (18 lines) | stat: -rwxr-xr-x 467 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import uinput

def main():
    events = (
        uinput.BTN_JOYSTICK,
        uinput.ABS_X + (0, 255, 0, 0),
        uinput.ABS_Y + (0, 255, 0, 0),
        )

    with uinput.Device(events) as device:
        for i in range(20):
            # syn=False to emit an "atomic" (5, 5) event.
            device.emit(uinput.ABS_X, 5, syn=False)
            device.emit(uinput.ABS_Y, 5)
        device.emit_click(uinput.BTN_JOYSTICK)

if __name__ == "__main__":
    main()