Ejemplo n.º 1
0
    def __init__(self, dead_zone=0.05, hot_zone=0.05):
        """
        Discover and initialise a PiHut controller connected to this computer.

        :param float dead_zone:
            Used to set the dead zone for each :class:`approxeng.input.CentredAxis` in the controller.
        :param float hot_zone:
            Used to set the hot zone for each :class:`approxeng.input.CentredAxis` in the controller.
        """
        super(PiHut, self).__init__(controls=[
            Button("Select", 314, sname='select'),
            Button("Left Stick", 317, sname='ls'),
            Button("Right Stick", 318, sname='rs'),
            Button("Start", 315, sname='start'),
            Button("L1", 310, sname='l1'),
            Button("L2", 312, sname='l2'),
            Button("R1", 311, sname='r1'),
            Button("R2", 313, sname='r2'),
            Button("Triangle", 308, sname='triangle'),
            Button("Circle", 305, sname='circle'),
            Button("Cross", 304, sname='cross'),
            Button("Square", 307, sname='square'),
            Button("Analog", 316, sname='home'),
            CentredAxis("Left Vertical", 255, 0, 1, sname='ly'),
            CentredAxis("Right Vertical", 255, 0, 5, sname='ry'),
            CentredAxis("Left Horizontal", 0, 255, 0, sname='lx'),
            CentredAxis("Right Horizontal", 0, 255, 2, sname='rx'),
            TriggerAxis("Left Trigger", 0, 255, 9, sname='lt'),
            TriggerAxis("Right Trigger", 0, 255, 10, sname='rt'),
            BinaryAxis("D-pad Horizontal", 16, b1name='dleft',
                       b2name='dright'),
            BinaryAxis("D-pad Vertical", 17, b1name='dup', b2name='ddown')
        ],
                                    dead_zone=dead_zone,
                                    hot_zone=hot_zone)
Ejemplo n.º 2
0
    def __init__(self, dead_zone=0.05, hot_zone=0.05):
        """
        Create a new SF30 Pro driver

        :param float dead_zone:
            Used to set the dead zone for each :class:`approxeng.input.CentredAxis` in the controller.
        :param float hot_zone:
            Used to set the hot zone for each :class:`approxeng.input.CentredAxis` in the controller.
        """
        super(SF30Pro, self).__init__(
            controls=[
                TriggerAxis("Right Trigger", 0, 255, 9, sname='rt'),
                TriggerAxis("Left Trigger", 0, 255, 10, sname='lt'),
                CentredAxis("Right Vertical", 255, 0, 5, sname='ry'),
                CentredAxis("Left Horizontal", 0, 255, 0, sname='lx'),
                CentredAxis("Left Vertical", 255, 0, 1, sname='ly'),
                CentredAxis("Right Horizontal", 0, 255, 2, sname='rx'),
                BinaryAxis("D-pad Horizontal", 16, b1name='dleft', b2name='dright'),
                BinaryAxis("D-pad Vertical", 17, b1name='ddown', b2name='dup'),
                Button("B", 304, sname='circle'),
                Button("A", 305, sname='cross'),
                Button("Mode", 306, sname='home'),
                Button("X", 307, sname='triangle'),
                Button("Y", 308, sname='square'),
                Button("L1", 310, sname='l1'),
                Button("R1", 311, sname='r1'),
                Button("L2", 312, sname='l2'),
                Button("R2", 313, sname='r2'),
                Button("Select", 314, sname='select'),
                Button("Start", 315, sname='start'),
                Button("Left Stick", 317, sname='ls'),
                Button("Right Stick", 318, sname='rs')
            ],
            dead_zone=dead_zone,
            hot_zone=hot_zone)
Ejemplo n.º 3
0
    def __init__(self, dead_zone=0.1, hot_zone=0.05):
        """
        Create a new xbox one s controller instance

        :param float dead_zone:
            Used to set the dead zone for each :class:`approxeng.input.CentredAxis` and
            :class:`approxeng.input.TriggerAxis` in the controller.
        :param float hot_zone:
            Used to set the hot zone for each :class:`approxeng.input.CentredAxis` and
            :class:`approxeng.input.TriggerAxis` in the controller.
        """
        super(WiredXBoxOneSPad, self).__init__(controls=[
            Button("X", 307, sname='square'),
            Button("Y", 308, sname='triangle'),
            Button("B", 305, sname='circle'),
            Button("A", 304, sname='cross'),
            Button("Right Stick", 318, sname='rs'),
            Button("Left Stick", 317, sname='ls'),
            Button("View", 314, sname='select'),
            Button("Menu", 315, sname='start'),
            Button("XBox", 316, sname='home'),
            Button("LB", 310, sname='l1'),
            Button("RB", 311, sname='r1'),
            CentredAxis("Left Horizontal", -32768, 32768, 0, sname='lx'),
            CentredAxis("Left Vertical",
                        -32768,
                        32768,
                        1,
                        invert=True,
                        sname='ly'),
            CentredAxis("Right Horizontal", -32768, 32768, 3, sname='rx'),
            CentredAxis("Right Vertical",
                        -32768,
                        32768,
                        4,
                        invert=True,
                        sname='ry'),
            TriggerAxis("Left Trigger",
                        0,
                        1023,
                        2,
                        sname='lt',
                        button_sname='l2',
                        button_trigger_value=0.2),
            TriggerAxis("Right Trigger",
                        0,
                        1023,
                        5,
                        sname='rt',
                        button_sname='r2',
                        button_trigger_value=0.2),
            BinaryAxis("D-pad Horizontal", 16, b1name='dleft',
                       b2name='dright'),
            BinaryAxis("D-pad Vertical", 17, b1name='dup', b2name='ddown')
        ],
                                               dead_zone=dead_zone,
                                               hot_zone=hot_zone)
Ejemplo n.º 4
0
    def __init__(self, dead_zone=0.05, hot_zone=0.05):
        """
        Create a new DualShock4 driver

        :param float dead_zone:
            Used to set the dead zone for each :class:`approxeng.input.CentredAxis` in the controller.
        :param float hot_zone:
            Used to set the hot zone for each :class:`approxeng.input.CentredAxis` in the controller.
        """
        super(DualShock4, self).__init__(vendor_id=DS4_VENDOR_ID,
                                         product_id=DS4_PRODUCT_ID,
                                         controls=[
                                             Button("Circle", 305, sname='circle'),
                                             Button("Cross", 304, sname='cross'),
                                             Button("Square", 308, sname='square'),
                                             Button("Triangle", 307, sname='triangle'),
                                             Button("Home (PS)", 316, sname='home'),
                                             Button("Share", 314, sname='select'),
                                             Button("Options", 315, sname='start'),
                                             Button("Trackpad", 'touch272', sname='ps4_pad'),
                                             Button("L1", 310, sname='l1'),
                                             Button("R1", 311, sname='r1'),
                                             Button("L2", 312, sname='l2'),
                                             Button("R2", 313, sname='r2'),
                                             Button("Left Stick", 317, sname='ls'),
                                             Button("Right Stick", 318, sname='rs'),
                                             CentredAxis("Left Horizontal", 0, 255, 0, sname='lx'),
                                             CentredAxis("Left Vertical", 0, 255, 1, invert=True, sname='ly'),
                                             CentredAxis("Right Horizontal", 0, 255, 2, sname='rx'),
                                             CentredAxis("Right Vertical", 0, 255, 5, invert=True, sname='ry'),
                                             TriggerAxis("Left Trigger", 0, 255, 3, sname='lt'),
                                             TriggerAxis("Right Trigger", 0, 255, 4, sname='rt'),
                                             BinaryAxis("D-pad Horizontal", 16, b1name='dleft', b2name='dright'),
                                             BinaryAxis("D-pad Vertical", 17, b1name='dup', b2name='ddown'),
                                             # CentredAxis("Motion 3", -1, 1, 'motion3', sname='zm3'),
                                             CentredAxis("Yaw rate", -2097152, 2097152, 'motion4', sname='yaw_rate',
                                                         invert=True),
                                             # CentredAxis("Motion 5", -1, 1, 'motion5', sname='zm5'),
                                             CentredAxis("Roll", -8500, 8500, 'motion0', sname='roll', invert=True),
                                             # CentredAxis("Motion 1", -1, 1, 'motion1', sname='zm1'),
                                             CentredAxis("Pitch", -8500, 8500, 'motion2', sname='pitch',
                                                         invert=True),
                                             CentredAxis("Touch X", 0, 1920, 'touch53', sname='tx'),
                                             CentredAxis("Touch Y", 0, 942, 'touch54', sname='ty', invert=True)

                                         ],
                                         node_mappings={
                                             'Sony Interactive Entertainment Wireless Controller Touchpad':
                                                 'touch',
                                             'Sony Interactive Entertainment Wireless Controller Motion Sensors':
                                                 'motion',
                                             'Wireless Controller Touchpad': 'touch',
                                             'Wireless Controller Motion Sensors': 'motion'},
                                         dead_zone=dead_zone,
                                         hot_zone=hot_zone)
        self.axes['roll'].hot_zone = 0.2
        self.axes['pitch'].hot_zone = 0.2
Ejemplo n.º 5
0
    def __init__(self, dead_zone=0.1, hot_zone=0.05):
        """
        Create a new xbox one controller instance
        :param float dead_zone:
            Used to set the dead zone for each :class:`approxeng.input.CentredAxis` and
            :class:`approxeng.input.TriggerAxis` in the controller.
        :param float hot_zone:
            Used to set the hot zone for each :class:`approxeng.input.CentredAxis` and
            :class:`approxeng.input.TriggerAxis` in the controller.
        """
        super(WirelessXBoxOnePad, self).__init__(controls=[
            Button("BTN_NORTH", 307, sname='square'),
            Button("BTN_WEST", 308, sname='triangle'),
            Button("BTN_B", 305, sname='circle'),
            Button("BTN_A", 304, sname='cross'),
            Button("BTN_THUMBR", 318, sname='rs'),
            Button("BTN_THUMBL", 317, sname='ls'),
            Button("BTN_SELECT", 314, sname='select'),
            Button("BTN_START", 315, sname='start'),
            Button("BTN_MODE", 316, sname='home'),
            Button("BTN_TL", 310, sname='l1'),
            Button("BTN_TR", 311, sname='r1'),
            CentredAxis("ABS_X", -32768, 32767, 0, sname='lx'),
            CentredAxis("ABS_Y", -32768, 32767, 1, invert=True, sname='ly'),
            CentredAxis("ABS_RX", -32768, 32767, 3, sname='rx'),
            CentredAxis("ABS_RY", -32768, 32767, 4, invert=True, sname='ry'),
            TriggerAxis("ABS_Z",
                        0,
                        1023,
                        2,
                        sname='lt',
                        button_sname='l2',
                        button_trigger_value=0.2),
            TriggerAxis("ABS_RZ",
                        0,
                        1023,
                        5,
                        sname='rt',
                        button_sname='r2',
                        button_trigger_value=0.2),
            BinaryAxis("ABS_HAT0X", 16, b1name='dleft', b2name='dright'),
            BinaryAxis("ABS_HAT0Y", 17, b1name='dup', b2name='ddown')
        ],
                                                 dead_zone=dead_zone,
                                                 hot_zone=hot_zone)

        @staticmethod
        def registration_ids():
            """
            :return: list of (vendor_id, product_id) for this controller
            """
            return [(0x45e, 0x2d1)]

        def __repr__(self):
            return 'Microsoft X-Box One pad'
Ejemplo n.º 6
0
 def trigger_axis(axis_name, button_name):
     if self.axes[axis_name]:
         axis = self.axes[axis_name]
         if self.buttons[button_name]:
             # We have a trigger button defined, no need to include it in the trigger definition
             return TriggerAxis(name=axis_name, min_raw_value=axis.real_min, max_raw_value=axis.real_max,
                                axis_event_code=axis.code, sname=axis_name)
         else:
             # Have an analogue trigger but no trigger button, set the trigger axis to create a
             # virtual button triggered at 20% activation, this is what we use for e.g. xbox controllers
             return TriggerAxis(name=axis_name, min_raw_value=axis.real_min, max_raw_value=axis.real_max,
                                axis_event_code=axis.code, sname=axis_name, button_sname=button_name,
                                button_trigger_value=0.2)
Ejemplo n.º 7
0
 def __init__(self, dead_zone=0.1, hot_zone=0.05, **kwargs):
     super(SteamController, self).__init__(controls=[
         Button("X", 307, sname='square'),
         Button("Y", 308, sname='triangle'),
         Button("B", 305, sname='circle'),
         Button("A", 304, sname='cross'),
         Button("Left", 314, sname='select'),
         Button("Right", 315, sname='start'),
         Button("Steam", 316, sname='home'),
         Button("Left Stick Click", 317, sname='ls'),
         Button("Right Trackpad Click", 318, sname='rs'),
         Button("Right Trackpad Touch", 290, sname='rtouch'),
         Button("Left Trackpad Touch", 289, sname='dtouch'),
         Button('Top Left Trigger', 310, sname='l1'),
         Button('Mid Left Trigger', 312, sname='l2'),
         Button('Bottom Left Trigger', 336, sname='l3'),
         Button('Top Right Trigger', 311, sname='r1'),
         Button('Mid Right Trigger', 313, sname='r2'),
         Button('Bottom Right Trigger', 337, sname='r3'),
         Button('D-pad left', 546, sname='dleft'),
         Button('D-pad right', 547, sname='dright'),
         Button('D-pad up', 544, sname='dup'),
         Button('D-pad down', 545, sname='ddown'),
         CentredAxis("Left Stick Horizontal", -32768, 32768, 0, sname='lx'),
         CentredAxis("Left Stick Vertical", 32768, -32768, 1, sname='ly'),
         CentredAxis("Right Trackpad Horizontal",
                     -32768,
                     32768,
                     3,
                     sname='rx'),
         CentredAxis("Right Trackpad Vertical",
                     32768,
                     -32768,
                     4,
                     sname='ry'),
         CentredAxis("Left Trackpad Horizontal",
                     -32768,
                     32768,
                     16,
                     sname='dx'),
         CentredAxis("Left Trackpad Vertical",
                     32768,
                     -32768,
                     17,
                     sname='dy'),
         TriggerAxis("Left Trigger", 0, 255, 21, sname='lt'),
         TriggerAxis("Right Trigger", 0, 255, 20, sname='rt')
     ],
                                           dead_zone=dead_zone,
                                           hot_zone=hot_zone,
                                           **kwargs)
Ejemplo n.º 8
0
    def __init__(self, dead_zone=0.05, hot_zone=0.0, **kwargs):
        """
        Discover and initialise a PS3 SixAxis controller connected to this computer.

        :param float dead_zone:
            Used to set the dead zone for each :class:`approxeng.input.CentredAxis` in the controller.
        :param float hot_zone:
            Used to set the hot zone for each :class:`approxeng.input.CentredAxis` in the controller.
        """
        super(DualShock3, self).__init__(
            controls=[
                Button("Select", 314, sname='select'),
                Button("Left Stick", 317, sname='ls'),
                Button("Right Stick", 318, sname='rs'),
                Button("Start", 315, sname='start'),
                Button("D Up", 544, sname='dup'),
                Button("D Right", 547, sname='dright'),
                Button("D Down", 545, sname='ddown'),
                Button("D Left", 546, sname='dleft'),
                Button("L2", 312, sname='l2'),
                Button("R2", 313, sname='r2'),
                Button("L1", 310, sname='l1'),
                Button("R1", 311, sname='r1'),
                Button("Triangle", 307, sname='triangle'),
                Button("Circle", 305, sname='circle'),
                Button("Cross", 304, sname='cross'),
                Button("Square", 308, sname='square'),
                Button("Home (PS)", 316, sname='home'),
                TriggerAxis("Left Trigger", 0, 255, 2, sname='lt'),
                TriggerAxis("Right Trigger", 0, 255, 5, sname='rt'),
                CentredAxis("Left Vertical", 255, 0, 1, sname='ly'),
                CentredAxis("Right Vertical", 255, 0, 4, sname='ry'),
                CentredAxis("Left Horizontal", 0, 255, 0, sname='lx'),
                CentredAxis("Right Horizontal", 0, 255, 3, sname='rx'),
                CentredAxis("Motion 0", 127, -128, 'motion0', sname='roll'),
                CentredAxis("Motion 2", 127, -128, 'motion2', sname='pitch'),
            ],
            node_mappings={
                'Sony PLAYSTATION(R)3 Controller Motion Sensors': 'motion'
            },
            dead_zone=dead_zone,
            hot_zone=hot_zone,
            **kwargs)
        self.axes['roll'].hot_zone = 0.2
        self.axes['pitch'].hot_zone = 0.2
Ejemplo n.º 9
0
    def __init__(self, dead_zone=0.1, hot_zone=0.05):
        """
        Create a new steam controller

        :param float dead_zone:
            Used to set the dead zone for each :class:`~approxeng.input.CentredAxis` and
            :class:`~approxeng.input.TriggerAxis` in the controller.
        :param float hot_zone:
            Used to set the hot zone for each :class:`~approxeng.input.CentredAxis` and
            :class:`~approxeng.input.TriggerAxis` in the controller.
        """
        super(SteamController, self).__init__(controls=[
            Button("X", 307, sname='square'),
            Button("Y", 308, sname='triangle'),
            Button("B", 305, sname='circle'),
            Button("A", 304, sname='cross'),
            Button("Right Stick", 318, sname='rs'),
            Button("Left Stick", 317, sname='ls'),
            Button("Left", 314, sname='select'),
            Button("Right", 315, sname='start'),
            Button("Steam", 316, sname='home'),
            Button("LB", 310, sname='l1'),
            Button("RB", 311, sname='r1'),
            CentredAxis("Left Horizontal", -32768, 32768, 0, sname='lx'),
            CentredAxis("Left Vertical",
                        -32768,
                        32768,
                        1,
                        invert=True,
                        sname='ly'),
            CentredAxis("Right Horizontal", -32768, 32768, 3, sname='rx'),
            CentredAxis("Right Vertical",
                        -32768,
                        32768,
                        4,
                        invert=True,
                        sname='ry'),
            TriggerAxis("Left Trigger", 0, 255, 2, sname='lt'),
            TriggerAxis("Right Trigger", 0, 255, 5, sname='rt'),
            BinaryAxis("D-pad Horizontal", 16, b1name='dleft',
                       b2name='dright'),
            BinaryAxis("D-pad Vertical", 17, b1name='dup', b2name='ddown')
        ],
                                              dead_zone=dead_zone,
                                              hot_zone=hot_zone)
Ejemplo n.º 10
0
 def _parse_trigger_axis(axis_string: str) -> TriggerAxis:
     split = axis_string.split(SEPARATOR)
     if len(split) == 5:
         name, min_raw, max_raw, code, sname = split
         return TriggerAxis(name=name,
                            min_raw_value=min_raw,
                            max_raw_value=max_raw,
                            axis_event_code=code,
                            sname=sname)
     elif len(split) == 7:
         # Trigger axes optionally have a button sname and trigger value for cases where
         # the controller has an analogue trigger but doesn't also generate button press
         # events itself.
         name, min_raw, max_raw, code, sname, button_sname, button_trigger_value = split
         return TriggerAxis(name=name,
                            min_raw_value=min_raw,
                            max_raw_value=max_raw,
                            axis_event_code=code,
                            sname=sname,
                            button_sname=button_sname,
                            button_trigger_value=button_trigger_value)
Ejemplo n.º 11
0
    def __init__(self, dead_zone=0.05, hot_zone=0.05):
        """
        Create a new DualShock4 driver

        :param float dead_zone:
            Used to set the dead zone for each :class:`approxeng.input.CentredAxis` in the controller.
        :param float hot_zone:
            Used to set the hot zone for each :class:`approxeng.input.CentredAxis` in the controller.
        """
        super(DualShock4, self).__init__(vendor_id=DS4_VENDOR_ID,
                                         product_id=DS4_PRODUCT_ID,
                                         controls=[
                                             Button("Circle", 306, sname='circle'),
                                             Button("Cross", 305, sname='cross'),
                                             Button("Square", 304, sname='square'),
                                             Button("Triangle", 307, sname='triangle'),
                                             Button("Home (PS)", 316, sname='home'),
                                             Button("Share", 312, sname='select'),
                                             Button("Options", 313, sname='start'),
                                             Button("Trackpad", 317, sname='ps4_pad'),
                                             Button("L1", 308, sname='l1'),
                                             Button("R1", 309, sname='r1'),
                                             Button("L2", 310, sname='l2'),
                                             Button("R2", 311, sname='r2'),
                                             Button("Left Stick", 314, sname='ls'),
                                             Button("Right Stick", 315, sname='rs'),
                                             CentredAxis("Left Horizontal", 0, 255, 0, sname='lx'),
                                             CentredAxis("Left Vertical", 0, 255, 1, invert=True, sname='ly'),
                                             CentredAxis("Right Horizontal", 0, 255, 2, sname='rx'),
                                             CentredAxis("Right Vertical", 0, 255, 5, invert=True, sname='ry'),
                                             TriggerAxis("Left Trigger", 0, 255, 3, sname='lt'),
                                             TriggerAxis("Right Trigger", 0, 255, 4, sname='rt'),
                                             BinaryAxis("D-pad Horizontal", 16, b1name='dleft', b2name='dright'),
                                             BinaryAxis("D-pad Vertical", 17, b1name='dup', b2name='ddown')
                                         ],
                                         dead_zone=dead_zone,
                                         hot_zone=hot_zone)