Skip to content

Commit 244b2aa

Browse files
author
harunkurt.me
committed
add communcation with mouse with file
1 parent a4a65b2 commit 244b2aa

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

read_from_mouse.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
mouse=open('/dev/input/mice')
21

2+
import struct
3+
4+
5+
mouse=open('/dev/input/mice',"rb") #read byte
36

47
while True:
58

69
event=mouse.read(3)
7-
8-
print(event)
10+
# print(event)
11+
12+
x,y=struct.unpack_from("bb",event[1:])# from byte read
13+
#currently mouse x and y position
14+
15+
print(x,y)
16+
17+
mouse.close()

0 commit comments

Comments
 (0)