Пример #1
0
def on_axis_moved(axis):
    print('Axis {0} moved to {1} {2}'.format(axis.name, axis.x, axis.y))


presets = {
    "button_a": Preset(1),
    "button_b": Preset(2),
    "button_x": Preset(3),
    "button_y": Preset(4),
}

if __name__ == '__main__':
    try:
        name = ''.join([
            x if x in string.printable else ''
            for x in Xbox360Controller.get_available()[0].name
        ])
        if name == "Logitech Logitech RumblePad 2 USB":
            switchAxisR = True
        else:
            switchAxisR = False
        print(switchAxisR)
        with Xbox360Controller(
                0, axis_threshold=0,
                switch_axis_r_with_trigger_l=switchAxisR) as controller:
            # Button A events
            controller.button_trigger_l.when_pressed = zoomout
            controller.button_trigger_r.when_pressed = zoomin
            controller.button_trigger_l.when_released = zoomstop
            controller.button_trigger_r.when_released = zoomstop
Пример #2
0
            buzzer_command = RobotBuzzer()
            buzzer_command.header = BaseTypes.PACKET_TYPE_ROBOT_BUZZER
            buzzer_command.remVersion = BaseTypes.LOCAL_REM_VERSION
            buzzer_command.id = self.robot_id
            buzzer_command.period = int(buzzer_value * 1000)
            buzzer_command.duration = 0.1

            message = np.concatenate(
                (self.command.encode(), buzzer_command.encode()))
            print(message)
            return message

        return self.command.encode()


print(Xbox360Controller.get_available())

# wrappers = [JoystickWrapper(Xbox360Controller(i)) for i in range(len(Xbox360Controller.get_available()))]
wrappers = [
    JoystickWrapper(controller)
    for controller in Xbox360Controller.get_available()
]

while True:
    # Open basestation with the basestation
    if basestation is None or not basestation.isOpen():
        basestation = utils.openContinuous(timeout=0.001)

    try:
        while True:
            # Run at {packet_Hz}fps