def err_obj_num_string(): test("Press button 0 or 1") arr_success = pyspacemouse.ButtonCallback("1", call1) dev = pyspacemouse.open(button_callback_arr=arr_success) while True: state = dev.read()
def success_dof_callback_set_p(): test("Move X axis") arr_success = [ pyspacemouse.DofCallback("x", lambda state, axis: print("x:",axis), 0.05), # pyspacemouse.DofCallback("pitch", lambda state, axis: pyautogui.scroll((axis*2)**3), 0.08), pyspacemouse.DofCallback("pitch", lambda state, axis: pyautogui.scroll((axis*5)), 0.09), # pyspacemouse.ButtonCallback([1], call2), ] cfg = pyspacemouse.Config(dof_callback_arr=arr_success) pyspacemouse.open() pyspacemouse.config_set(cfg) # pyspacemouse.config_remove() while True: state = pyspacemouse.read() time.sleep(0.0001)
def err_arr_arr_string(): test("Press button 0 or 1") arr_success = [ pyspacemouse.ButtonCallback(["1", "1.1"], call1), pyspacemouse.ButtonCallback(["2"], call2), ] dev = pyspacemouse.open(button_callback_arr=arr_success) while True: state = dev.read()
def success(): test("Press button 0 or 1") arr_success = [ pyspacemouse.ButtonCallback([0], call1), pyspacemouse.ButtonCallback([1], call2), ] dev = pyspacemouse.open(button_callback_arr=arr_success) while True: state = dev.read()
def success_dof_callback(): test("Move X axis") arr_success = [ pyspacemouse.DofCallback("x", lambda axis: print("x:", axis)), pyspacemouse.DofCallback("pitch", lambda axis: print("pitch:", axis)), # pyspacemouse.ButtonCallback([1], call2), ] dev = pyspacemouse.open(dof_callback_arr=arr_success) while True: state = dev.read() time.sleep(0.0001)
# import pyspacemouse # import time # # # pyspacemouse.open(dof_callback_arr=[ # pyspacemouse.DofCallback("x", lambda state, axis: print(f"X plus {axis}"), 0.01, lambda state, axis: print(f"X minus {axis}")), # pyspacemouse.DofCallback("y", lambda state, axis: print(f"Y plus {axis}"), 0.01, lambda state, axis: print(f"Y minus {axis}"), 0.5), # ]) # # # while True: # out = pyspacemouse.read() # # print(out.x) # time.sleep(0.0001) import pyspacemouse import time pyspacemouse.open(dof_callback_arr=[ pyspacemouse.DofCallback( "x", lambda state, axis: print(f"X filter {axis}"), 0.01, None, 0.3), pyspacemouse.DofCallback( "y", lambda state, axis: print(f"Y filter {axis}"), 0.01, None, 0.8), # pyspacemouse.DofCallback("z", lambda state, axis: print(f"z filter {axis}"), 0.01), ]) while True: out = pyspacemouse.read() # print(out.x) time.sleep(0.0001)
def setup(self): mouse = pyspacemouse.open() # disable SpaceMouse as mouse input in Linux os.system( f"xinput --disable '{mouse.vendor_name} {mouse.product_name}'")
# # success = pyspacemouse.open(dof_callback=pyspacemouse.print_state, button_callback=someButton, # button_callback_arr=button_arr) # if success: # while True: # pyspacemouse.read() # time.sleep(0.01) # # # if __name__ == '__main__': # callback() import pyspacemouse import time success = pyspacemouse.open(dof_callback=pyspacemouse.print_state, button_callback=pyspacemouse.print_buttons) if success: while 1: state = pyspacemouse.read() time.sleep(0.01) # import pyspacemouse # import time # # cfg = pyspacemouse.Config( # dof_callback_arr=[ # pyspacemouse.DofCallback("x", lambda state, buttons: print("Button: 0")), # pyspacemouse.DofCallback("y", lambda state, buttons: print("Button: 1")), # ], # button_callback_arr=[ # pyspacemouse.ButtonCallback(1, lambda axis: print(f"DoF y: {axis}")),