Skip to content

Something wrong with AbsInfo #40

Open

Description

@tapir

I'm trying to mirror a gamepad with code below.

from evdev import InputDevice, UInput, AbsInfo, ecodes as e

cap = {
    e.EV_MSC : [e.MSC_SCAN],
    e.EV_KEY : [e.BTN_A, e.BTN_B, e.BTN_C, e.BTN_X, e.BTN_Y, e.BTN_Z, e.BTN_TL, e.BTN_TR, e.BTN_TL2],
    e.EV_ABS : [(e.ABS_X, AbsInfo(value=128, min=0, max=255, fuzz=0, flat=15, resolution=0)), (e.ABS_Y, AbsInfo(value=128, min=0, max=255, fuzz=0, flat=15, resolution=0))]
}

dev_real = InputDevice('/dev/input/event20')
dev_virt = UInput(cap, name='Cypress Virtual')

for event in dev_real.read_loop():
    dev_virt.write_event(event)

Above code keeps getting the error below.

Traceback (most recent call last):
  File "pytest.py", line 10, in <module>
    dev_virt = UInput(cap, name='Cypress Virtual')
  File "/usr/lib/python3.5/site-packages/evdev/uinput.py", line 83, in __init__
    _uinput.create(self.fd, name, vendor, product, version, bustype, absinfo)
OSError: [Errno 22] Invalid argument

But when I change the value=128 to value=0 for both AbsInfo()'s. it runs without an error.
Printing the uinput device capabilities with evtest.py reveals this:

  Type EV_ABS 3:
    Code ABS_X 0:
      val 139, min 0, max 0, fuzz 255, flat 0, res 0
    Code ABS_Y 1:
      val 101, min 0, max 0, fuzz 255, flat 0, res 0

Any help would be appreciated.

Thanks

Activity

  1. tapir commented on Oct 7, 2015

    @tapir
    Author
            # set device capabilities
            for etype, codes in events.items():
                for code in codes:
                    # handle max, min, fuzz, flat
                    if isinstance(code, (tuple, list, device.AbsInfo)):
                        # flatten (ABS_Y, (0, 255, 0, 0)) to (ABS_Y, 0, 255, 0, 0)
                        f = [code[0]]; f += code[1]
                        absinfo.append(f)
                        code = code[0]

    Could it be related to this part in uinput.py:70?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions