forked from yesimxev/badbt
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmouse_emulate.py
More file actions
executable file
·36 lines (30 loc) · 853 Bytes
/
mouse_emulate.py
File metadata and controls
executable file
·36 lines (30 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/python3
import os
import sys
import dbus
import dbus.service
import dbus.mainloop.glib
class MouseClient():
def __init__(self):
super().__init__()
self.state = [0, 0, 0, 0]
self.bus = dbus.SystemBus()
self.btkservice = self.bus.get_object(
'org.thanhle.btkbservice', '/org/thanhle/btkbservice')
self.iface = dbus.Interface(self.btkservice, 'org.thanhle.btkbservice')
def send_current(self):
try:
self.iface.send_mouse(0, bytes(self.state))
except OSError as err:
error(err)
if __name__ == "__main__":
if (len(sys.argv) < 5):
print("Usage: mouse_emulate [button_num dx dy dz]")
exit()
client = MouseClient()
client.state[0] = int(sys.argv[1])
client.state[1] = int(sys.argv[2])
client.state[2] = int(sys.argv[3])
client.state[3] = int(sys.argv[4])
print("state:", client.state)
client.send_current()