EV_ABS doesn't work

Bug #669208 reported by Santiago Piccinini
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-uinput
Fix Released
Wishlist
a

Bug Description

I think Absolute events aren't working but maybe i am doing some wrong, am new to input drivers. I am trying to do a joystick, my code:

### joystick.py
#! /usr/bin/env python

#http://www.mjmwired.net/kernel/Documentation/input/input-programming.txt

import time

import uinput

def main():
    capabilities = {
                    uinput.EV_ABS: [uinput.ABS_X, uinput.ABS_Y],
                    }
    abs_parameters = {uinput.ABS_X:(0, 255, 0, 0)} #abs_min, abs_max, abs_fuzz, abs_flat

    device = uinput.Device(name="python-uinput-joystick",
                           capabilities=capabilities, abs_parameters=abs_parameters)
    for i in range(5):
        device.emit(uinput.EV_ABS, uinput.ABS_X, 5, syn=False)
        device.emit(uinput.EV_ABS, uinput.ABS_Y, 5)
        time.sleep(0.5) # Just to show the motion.

if __name__ == "__main__":
    main()

### Traceback

$ sudo python2 joystick.py
Traceback (most recent call last):
  File "joystick.py", line 23, in <module>
    main()
  File "joystick.py", line 18, in main
    device.emit(uinput.EV_ABS, uinput.ABS_X, 5, syn=False)
  File "/usr/lib/python2.7/site-packages/uinput/__init__.py", line 79, in emit
    suinput.uinput_write(self.__uinput_fd, ev_type, ev_code, ev_value)
IOError: [Errno 22] Invalid argument

Revision history for this message
a (tuomasjjrasanen) wrote :

Thank your for reporting this issue. You are missing the absolute parameter setting for ABS_Y axis. If you replace::

  abs_parameters = {uinput.ABS_X:(0, 255, 0, 0)} #abs_min, abs_max, abs_fuzz, abs_flat

with::

  abs_parameters = {uinput.ABS_X:(0, 255, 0, 0),
                                 uinput.ABS_Y:(0, 255, 0, 0)}

then it works. Could you please test with that change and report back here the results.

However, I'm grateful for reporting this issue, because it shows me two things:
1. The whole module is badly documented (the documentation is missing totally).
2. Device-class should provide reasonable default values for abs_parameters.

Those two things will be fixed for the next release.

Revision history for this message
Santiago Piccinini (spiccinini) wrote : Re: [Bug 669208] Re: EV_ABS doesn't work

On Sun, Oct 31, 2010 at 19:07, tuos <email address hidden> wrote:
> Thank your for reporting this issue. You are missing the absolute
> parameter setting for ABS_Y axis. If you replace::
>
>  abs_parameters = {uinput.ABS_X:(0, 255, 0, 0)} #abs_min, abs_max,
> abs_fuzz, abs_flat
>
> with::
>
>  abs_parameters = {uinput.ABS_X:(0, 255, 0, 0),
>                                 uinput.ABS_Y:(0, 255, 0, 0)}
>
> then it works. Could you please test with that change and report back
> here the results.

Yes, it works that way :)

> However, I'm grateful for reporting this issue, because it shows me two things:
> 1. The whole module is badly documented (the documentation is missing totally).

Well, i think that adding a joystick example will improve things a lot.

> 2. Device-class should provide reasonable default values for abs_parameters.
Not only that, now if you doesn't specify abs_parameters it raises the
same error.

Thanks for the help!, python-uinput is super cool!

Revision history for this message
a (tuomasjjrasanen) wrote :

Glad to hear that you find it useful. I'm marking this issue as a feature request. It will be fixed in the next release.

Changed in python-uinput:
assignee: nobody → tuos (tuos)
importance: Undecided → Wishlist
milestone: none → 0.5
status: New → In Progress
a (tuomasjjrasanen)
Changed in python-uinput:
status: In Progress → Fix Committed
a (tuomasjjrasanen)
Changed in python-uinput:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.