evdev не может симулировать сенсорный ввод

Я пытаюсь использовать evdev для имитации сенсорного ввода.

from evdev import UInput, AbsInfo, ecodes as e

cap = {
    e.EV_KEY : [e.KEY_A, e.KEY_B],
    e.EV_ABS : [
        (e.ABS_X, AbsInfo(value=0, min=0, max=255,
                          fuzz=0, flat=0, resolution=0)),
        (e.ABS_Y, AbsInfo(0, 0, 255, 0, 0, 0)),
        (e.ABS_MT_POSITION_X, (0, 255, 128, 0)) ]
}

ui = UInput(cap, name='example-device', version=0x3)

Добавляю себя в input группа, ошибка:

Traceback (most recent call last):
  File "mouse.py", line 12, in <module>
    ui = UInput(cap, name='example-device', version=0x3)
  File "/home/user/.virtualenvs/venv/lib/python3.6/site-packages/evdev/uinput.py", line 125, in __init__
    self._verify()
  File "/home/user/.virtualenvs/venv/lib/python3.6/site-packages/evdev/uinput.py", line 221, in _verify
    raise UInputError(msg.format(self.devnode))
evdev.uinput.UInputError: "/dev/uinput" cannot be opened for writing

После запуска chmod +0666 /dev/uinput ошибка меняется на:

Traceback (most recent call last):
  File "mouse.py", line 12, in <module>
    ui = UInput(cap, name='example-device', version=0x3)
  File "/home/user/.virtualenvs/venv/lib/python3.6/site-packages/evdev/uinput.py", line 147, in __init__
    _uinput.create(self.fd, name, vendor, product, version, bustype, absinfo)
SystemError: /builddir/build/BUILD/Python-3.6.2/Objects/longobject.c:404: bad argument to internal function

Удаление (e.ABS_MT_POSITION_X, (0, 255, 128, 0)):

Traceback (most recent call last):
  File "mouse.py", line 12, in <module>
    print(ui)
  File "/home/user/.virtualenvs/venv/lib/python3.6/site-packages/evdev/uinput.py", line 171, in __str__
    evtypes = [i[0] for i in self.capabilities(True).keys()]
  File "/home/user/.virtualenvs/venv/lib/python3.6/site-packages/evdev/uinput.py", line 200, in capabilities
    raise UInputError('input device not opened - cannot read capabilites')
evdev.uinput.UInputError: input device not opened - cannot read capabilites

0 ответов

Другие вопросы по тегам