How to read out scroll wheel info from /dev/input/mice?
问题 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 this SO-answer. It basically reads out /dev/input/mice and converts the hex-input into integers: import struct file = open( "/dev/input/mice", "rb" ) def getMouseEvent(): buf = file.read(3) button = ord( buf[0] ) bLeft = button & 0x1 bMiddle = ( button & 0x4 ) > 0 bRight = ( button & 0x2 ) > 0 x,y = struct.unpack( "bb", buf[1:] ) print ("L:%d, M: %d,