Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to read out scroll wheel info from /dev/input/mice?
    primarykey
    data
    text
    <p>For a home robotics project I need to read out the raw mouse movement information. I partially succeeded in this by using the python script from <a href="https://stackoverflow.com/a/12286738/1650012">this SO-answer</a>. It basically reads out /dev/input/mice and converts the hex-input into integers:</p> <pre><code>import struct file = open( "/dev/input/mice", "rb" ) def getMouseEvent(): buf = file.read(3) button = ord( buf[0] ) bLeft = button &amp; 0x1 bMiddle = ( button &amp; 0x4 ) &gt; 0 bRight = ( button &amp; 0x2 ) &gt; 0 x,y = struct.unpack( "bb", buf[1:] ) print ("L:%d, M: %d, R: %d, x: %d, y: %d\n" % (bLeft,bMiddle,bRight, x, y) ) while True: getMouseEvent() file.close() </code></pre> <p>This works fine, except for the fact that the scroll wheel information is missing. Does anybody know how I can get (preferably with python) the scroll wheel information from /dev/input/mice?</p> <p>[EDIT] Okay, although I didn't manage to read out the /dev/input/mice, I think I found a solution. I just found the evdev module (sudo pip install evdev) with which you can read out input events. I now have the following code:</p> <pre><code>from evdev import InputDevice from select import select dev = InputDevice('/dev/input/event3') # This can be any other event number. On my Raspi it turned out to be event0 while True: r,w,x = select([dev], [], []) for event in dev.read(): # The event.code for a scroll wheel event is 8, so I do the following if event.code == 8: print(event.value) </code></pre> <p>I'm now going to test this on my raspi and see how that works. Thanks for all the inspiration guys and girls!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload