我在基本设备上,无法访问X或…,因此event.py无法正常工作。
因此,这是我最简单的解码代码部分,可从“已弃用的”’/ dev / input / mice’进行解释:
import structfile = 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, R: %d, x: %d, y: %dn" % (bLeft,bMiddle,bRight, x, y) ); # return stuffswhile( 1 ): getMouseEvent();file.close();


