class BMKSim: def __init__(self, range_x=1.2, range_y=1.2): self.bluetooth = Bluetooth() self.control = Control(range_x, range_y) self.max_try = 500 def run(self): self.bluetooth.connect() error_count = 0 # total_num_of_massages = 0 while True: data = self.bluetooth.run() if data: error_count = 0 # total_num_of_massages += 1 if data[0] == MASSAGE_MOVE: self.control.move_mouse(data[1:]) elif data[0] == MASSAGE_LEFT_CLICK: self.control.left_click() elif data[0] == MASSAGE_RIGHT_CLICK: self.control.right_click() elif data[0] == MASSAGE_PRESS: # test: self.control.press(bytes.decode(data[1])) else: error_count += 1 if error_count == self.max_try: break # print('\ntotal_num_of_massages:', total_num_of_massages) print('\nDisconnected...') self.bluetooth.disconnect()