您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

使用Python获取鼠标增量!(在Linux中)

使用Python获取鼠标增量!(在Linux中)

我在基本设备上,无法访问X或…,因此event.py无法正常工作。

因此,这是我最简单的解码代码部分,可从“已弃用的”’/ dev / input / mice’进行解释:

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, R: %d, x: %d, y: %d\n" % (bLeft,bMiddle,bRight, x, y) );
  # return stuffs

while( 1 ):
  getMouseEvent();
file.close();
python 2022/1/1 18:15:46 有657人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶