Пример #1
0
    def __init__(self, dead_zone=0.05, hot_zone=0.05):
        """
        Create a new Nintendo Switch Joycon 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(SwitchJoyConRight, self).__init__(controls=[
            Button("X", 305, sname="circle"),
            Button("Y", 307, sname="triangle"),
            Button("B", 306, sname="square"),
            Button("A", 304, sname="cross"),
            Button("Left Stick", 315, sname="ls"),
            Button("Home", 316, sname="home"),
            Button("Plus", 313, sname="start"),
            Button("SL", 308, sname="l1"),
            Button("SR", 309, sname="r1"),
            CentredAxis("Left Horizontal", -1, 1, 16, sname="lx"),
            CentredAxis("Left Vertical", 1, -1, 17, sname="ly")
        ],
                                                dead_zone=dead_zone,
                                                hot_zone=hot_zone)
Пример #2
0
def _parse_buttons(d: Dict) -> List:
    """
    Extract button definitions from the config. The corresponding YAML form is:

    .. code-block:: yaml

        buttons:
          - X:307:square
          - Y:309:triangle
          - B:305:circle

    Button definitions are of the form NAME:CODE:SNAME

    :param d:
        config dict built from the YAML source
    :return:
        list of :class:`~approxeng.input.Button`
    """
    if 'buttons' in d:
        buttons = list([
            Button(*button_string.split(SEPARATOR))
            for button_string in d['buttons']
        ])
        LOGGER.info(f'buttons      : {[button.name for button in buttons]}')
        return buttons
    LOGGER.info('buttons      : NONE')
    return []
Пример #3
0
    def __init__(self, dead_zone=0.05, hot_zone=0.05):
        """
        Create a new Nintendo Switch Joycon controller instance
		Left hand contorller only

        :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(SwitchJoyCon_L, self).__init__(vendor_id=SWITCH_VENDOR_ID,
                                             product_id=SWITCH_L_PRODUCT_ID,
                                             controls=[
                                                 Button("Right",
                                                        305,
                                                        sname="circle"),
                                                 Button("Up",
                                                        307,
                                                        sname="triangle"),
                                                 Button("Left",
                                                        306,
                                                        sname="square"),
                                                 Button("Down",
                                                        304,
                                                        sname="cross"),
                                                 Button("Left Stick",
                                                        314,
                                                        sname="ls"),
                                                 Button("Home",
                                                        317,
                                                        sname="home"),
                                                 Button("Minus",
                                                        312,
                                                        sname="start"),
                                                 Button("SL", 308, sname="l1"),
                                                 Button("SR", 309, sname="r1"),
                                                 CentredAxis("Left Horizontal",
                                                             -1,
                                                             1,
                                                             16,
                                                             sname="lx"),
                                                 CentredAxis("Left Vertical",
                                                             1,
                                                             -1,
                                                             17,
                                                             sname="ly")
                                             ],
                                             dead_zone=dead_zone,
                                             hot_zone=hot_zone)
Пример #4
0
    def controls(self):
        """
        Infers a list of control objects from the current set of known axes etc. This can be used to construct
        a controller class
        """
        # Get all buttons first, only picking up ones for which we've got known codes
        buttons = [Button(name=name, key_code=self.buttons[name], sname=name) for name in self.buttons if
                   self.buttons[name]]

        # Pick up trigger axes if we have them
        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)

        triggers = [trigger_axis(a, b) for a, b in [('lt', 'l2'), ('rt', 'r2')]]

        # Binary axes - these are generally just the D-pad on some controllers (some have actual buttons, some
        # have a slightly strange axis which only reports -1 and 1 when buttons are pressed
        def binary_axis(axis_name, b1name, b2name):
            if self.axes[axis_name] and self.buttons[b1name] is None and self.buttons[b2name] is None:
                axis = self.axes[axis_name]
                return BinaryAxis(name=axis_name, axis_event_code=axis.code,
                                  b1name=b1name if not axis.invert else b2name,
                                  b2name=b2name if not axis.invert else b1name)

        dpad = [binary_axis(a, b, c) for a, b, c in [('dx', 'dleft', 'dright'), ('dy', 'dup', 'ddown')]]

        # Regular centred axes
        def centred_axis(axis_name):
            if self.axes[axis_name]:
                axis = self.axes[axis_name]
                return CentredAxis(name=axis_name, min_raw_value=axis.real_min, max_raw_value=axis.real_max,
                                   axis_event_code=axis.code, sname=axis_name)

        sticks = [centred_axis(name) for name in ['lx', 'ly', 'rx', 'ry']]

        return list([control for control in [*buttons, *triggers, *dpad, *sticks] if control is not None])
Пример #5
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)
Пример #6
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__(vendor_id=PH_VENDOR_ID,
                                    product_id=PH_PRODUCT_ID,
                                    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",
                                                    0,
                                                    255,
                                                    1,
                                                    invert=True,
                                                    sname='ly'),
                                        CentredAxis("Right Vertical",
                                                    0,
                                                    255,
                                                    5,
                                                    invert=True,
                                                    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)
Пример #7
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)
Пример #8
0
    def __init__(self, dead_zone=0.05, hot_zone=0.05):
        """
        Create a new Rock Candy 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(RockCandy,
              self).__init__(vendor_id=RC_VENDOR_ID,
                             product_id=RC_PRODUCT_ID,
                             controls=[
                                 Button("6 Dot", 306, sname='circle'),
                                 Button("5 Dot", 305, sname='cross'),
                                 Button("4 Dot", 304, sname='square'),
                                 Button("3 Dot", 307, sname='triangle'),
                                 Button("Home", 316, sname='home'),
                                 Button("Select", 312, sname='select'),
                                 Button("Start", 313, sname='start'),
                                 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'),
                                 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)
Пример #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(WiiRemotePro, self).__init__(
            controls=[
                Button("X", 307, sname='triangle'),
                Button("Y", 308, sname='square'),
                Button("A", 305, sname='circle'),
                Button("B", 304, sname='cross'),
                Button("Right Stick", 318, sname='rs'),
                Button("Left Stick", 317, sname='ls'),
                Button("Select", 314, sname='select'),
                Button("Start", 315, sname='start'),
                Button("Home", 316, sname='home'),
                Button("L", 310, sname='l1'),
                Button("R", 311, sname='r1'),
                Button("LZ", 312, sname='l2'),
                Button("RZ", 313, sname='r2'),
                Button("D Up", 544, sname='dup'),
                Button("D Right", 547, sname='dright'),
                Button("D Down", 545, sname='ddown'),
                Button("D Left", 546, sname='dleft'),
                CentredAxis("Left Horizontal", -1000, 1000, 0, sname='lx'),
                CentredAxis("Left Vertical", 1000, -1000, 1, sname='ly'),
                CentredAxis("Right Horizontal", -1000, 1000, 3, sname='rx'),
                CentredAxis("Right Vertical", 1000, -1000, 4, sname='ry'),
            ],
            dead_zone=dead_zone,
            hot_zone=hot_zone)
Пример #10
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__(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", 255, 0, 1, sname='ly'),
            CentredAxis("Right Horizontal", 0, 255, 3, sname='rx'),
            CentredAxis("Right Vertical", 255, 0, 4, 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'),
            CentredAxis("Yaw rate", 2097152, -2097152, 'motion4', sname='yaw_rate'),
            CentredAxis("Roll", 8500, -8500, 'motion0', sname='roll'),
            CentredAxis("Pitch", 8500, -8500, 'motion2', sname='pitch'),
            CentredAxis("Touch X", 0, 1920, 'touch53', sname='tx'),
            CentredAxis("Touch Y", 942, 0, 'touch54', sname='ty')

        ],
            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
Пример #11
0
 def __init__(self, dead_zone=0.05, hot_zone=0.01):
     super(SpaceMousePro, self).__init__(controls=[
         CentredAxis('X', -350, 350, 0, sname='lx'),
         CentredAxis('Y', -350, 350, 1, sname='ly', invert=True),
         CentredAxis('Z', -350, 350, 2, sname='lz', invert=True),
         CentredAxis('Roll', -350, 350, 3, sname='pitch'),
         CentredAxis('Pitch', -350, 350, 4, sname='roll', invert=True),
         CentredAxis('Yaw', -350, 350, 5, sname='yaw'),
         Button('Menu', 256, sname='menu'),
         Button('Alt', 279, sname='alt'),
         Button('Ctrl', 281, sname='ctrl'),
         Button('Shift', 280, sname='shift'),
         Button('Esc', 278, sname='esc'),
         Button('1', 268, sname='1'),
         Button('2', 269, sname='2'),
         Button('3', 270, sname='3'),
         Button('4', 271, sname='4'),
         Button('Rotate', 264, sname='rotate'),
         Button('T', 258, sname='t'),
         Button('F', 261, sname='f'),
         Button('R', 260, sname='r'),
         Button('Lock', 282, sname='lock'),
         Button('Fit', 257, sname='fit')
     ],
                                         dead_zone=dead_zone,
                                         hot_zone=hot_zone)
Пример #12
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)
Пример #13
0
    def __init__(self, dead_zone=0.05, hot_zone=0.05, **kwargs):
        """
        Create a new WiiMote 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(WiiMote, self).__init__(controls=[
            Button("Nunchuck Z", 309, sname="r1"),
            Button("Nunchuck C", 306, sname="r2"),
            Button("Wiimote A", 304, sname="cross"),
            Button("Wiimote B", 305, sname="circle"),
            Button("Wiimote DUp", 103, sname="dup"),
            Button("Wiimote DDown", 108, sname="ddown"),
            Button("Wiimote DLeft", 105, sname="dleft"),
            Button("Wiimote DRight", 106, sname="dright"),
            Button("Wiimote -", 412, sname="select"),
            Button("Wiimote +", 407, sname="start"),
            Button("Wiimote home", 316, sname="home"),
            Button("Wiimote 1", 257, sname="cross"),
            Button("Wiimote 2", 258, sname="circle"),
            CentredAxis("Wiimote Roll", -100, 100, 3, sname="roll"),
            CentredAxis("Wiimote Pitch", -90, 125, 4, sname="pitch"),
            CentredAxis("Wiimote ???", -90, 125, 5, sname="???"),
            CentredAxis("Nunchuck Y", -100, 100, 17, sname="ry"),
            CentredAxis("Nunchuck X", -100, 100, 16, sname="rx"),
            CentredAxis("Classic lx", -32, 32, 18, sname="lx"),
            CentredAxis("Classic ly", -32, 32, 19, sname="ly"),
            CentredAxis("Classic rx", -32, 32, 20, sname="rx"),
            CentredAxis("Classic ry", -32, 32, 21, sname="ly"),
            Button("Classic x", 307, sname="square"),
            Button("Classic y", 308, sname="triangle"),
            Button("Classic zr", 313, sname="r2"),
            Button("Classic zl", 312, sname="l2"),
        ],
                                      dead_zone=dead_zone,
                                      hot_zone=hot_zone,
                                      **kwargs)
Пример #14
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'
Пример #15
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__(vendor_id=SC_VENDOR_ID,
                             product_id=SC_PRODUCT_ID,
                             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)
Пример #16
0
    def __init__(self, dead_zone=0.05, hot_zone=0.0):
        """
        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__(vendor_id=DS3_VENDOR_ID,
                                         product_id=DS3_PRODUCT_ID,
                                         controls=[
                                             Button("Select", 288, sname='select'),
                                             Button("Left Stick", 289, sname='ls'),
                                             Button("Right Stick", 290, sname='rs'),
                                             Button("Start", 291, sname='start'),
                                             Button("D Up", 292, sname='dup'),
                                             Button("D Right", 293, sname='dright'),
                                             Button("D Down", 294, sname='ddown'),
                                             Button("D Left", 295, sname='dleft'),
                                             Button("L2", 296, sname='l2'),
                                             Button("R2", 297, sname='r2'),
                                             Button("L1", 298, sname='l1'),
                                             Button("R1", 299, sname='r1'),
                                             Button("Triangle", 300, sname='triangle'),
                                             Button("Circle", 301, sname='circle'),
                                             Button("Cross", 302, sname='cross'),
                                             Button("Square", 303, sname='square'),
                                             Button("Home (PS)", 704, sname='home'),
                                             CentredAxis("Left Vertical", 0, 255, 1, invert=True, sname='ly'),
                                             CentredAxis("Right Vertical", 0, 255, 5, invert=True, sname='ry'),
                                             CentredAxis("Left Horizontal", 0, 255, 0, sname='lx'),
                                             CentredAxis("Right Horizontal", 0, 255, 2, sname='rx')
                                         ],
                                         dead_zone=dead_zone,
                                         hot_zone=hot_zone)
Пример #17
0
    def __init__(self, dead_zone=0.1, hot_zone=0.05):
        """
        Create a new xbox one controller instance Product: 733

        :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(WiredXBoxOnePadJack, 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)
Пример #18
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(WirelessXBoxOneSPad,
              self).__init__(vendor_id=XB1S_VENDOR_ID,
                             product_id=XB1S_WIRELESS_PRODUCT_ID,
                             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", 158, sname='select'),
                                 Button("Menu", 315, sname='start'),
                                 Button("XBox", 172, sname='home'),
                                 Button("LB", 310, sname='l1'),
                                 Button("RB", 311, sname='r1'),
                                 CentredAxis("Left Horizontal",
                                             0,
                                             65335,
                                             0,
                                             sname='lx'),
                                 CentredAxis("Left Vertical",
                                             0,
                                             65335,
                                             1,
                                             invert=True,
                                             sname='ly'),
                                 CentredAxis("Right Horizontal",
                                             0,
                                             65335,
                                             2,
                                             sname='rx'),
                                 CentredAxis("Right Vertical",
                                             0,
                                             65335,
                                             5,
                                             invert=True,
                                             sname='ry'),
                                 TriggerAxis("Left Trigger",
                                             0,
                                             1023,
                                             10,
                                             sname='lt',
                                             button_sname='l2',
                                             button_trigger_value=0.1),
                                 TriggerAxis("Right Trigger",
                                             0,
                                             1023,
                                             9,
                                             sname='rt',
                                             button_sname='r2',
                                             button_trigger_value=0.1),
                                 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)
Пример #19
0
    def __init__(self, dead_zone=0.05, hot_zone=0.0):
        """
        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)
        self.axes['roll'].hot_zone = 0.2
        self.axes['pitch'].hot_zone = 0.2