12345678910111213141516171819202122232425262728293031323334353637 |
- #!/usr/bin/python3
- import os
- import sys
- import dbus
- import dbus.service
- import dbus.mainloop.glib
- DBUS_OBJ_BTK_NAME = 'org.thanhle.btkbservice'
- DBUS_OBJ_BTK_PATH = '/org/thanhle/btkbservice'
- class MouseClient():
- def __init__(self):
- super().__init__()
- self.state = [0, 0, 0, 0]
- self.bus = dbus.SystemBus()
- self.btkservice = self.bus.get_object(DBUS_OBJ_BTK_NAME, DBUS_OBJ_BTK_PATH)
- self.iface = dbus.Interface(self.btkservice, DBUS_OBJ_BTK_NAME)
- 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()
|