import os f = os.popen('/usr/bin/hexdump /dev/input/mice', 'rb', 1) data = f.read(512) while(data): print data, data = f.read(512)
Да еще и hexdump почему-то каждый раз разные данные дает :(
import os f = os.popen('/usr/bin/hexdump /dev/input/mice', 'rb', 1) data = f.read(512) while(data): print data, data = f.read(512)
#!/usr/bin/python f = file("/dev/input/mice") l, r = 0, 0 while 1: buttons = ord(f.read(3)[0]) nl, nr = buttons&1, buttons&2 if l and not nl: print "left release" if r and not nr: print "right release" l, r = nl, nr