Skip to content

Joystickハック

https://github.com/FaBoPlatform/donkeypart_ps3_controller

F710

F710。

項目 内容
メーカー logitec
型番 F710
技適 取得済み

AXIS

コード キー
0x00 left_stick_vert
0x01 left_stick_horz
0x02 right_stick_vert
0x05 right_stick_horz

BUTTON

Number キー
0x00 青 X
0x01 緑 A
0x02 赤 B
0x03 黄 A
0x08 select
0x09 back
0x04 L1
0x05 R1
0x06 L2
0x07 R2
0x08 L3
0x09 R3

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
class F710Joystick(Joystick):
    '''
    An interface to a physical PS3 joystick available at /dev/input/js0
    Contains mapping that work for Raspian Stretch drivers
    '''

    def __init__(self, *args, **kwargs):
        super(F710Joystick, self).__init__(*args, **kwargs)

        self.axis_names = {
            0x00: 'left_stick_horz',
            0x01: 'left_stick_vert',
            0x02: 'right_stick_horz',
            0x05: 'right_stick_vert',
        }

        self.button_names = {
            0x138: 'select',  # 8 312
            0x139: 'start',  # 9 313

            0x134: 'L1',  # 4 308
            0x135: 'R1',  # 5 309
            0x136: 'L2',  # 6 310
            0x137: 'R2',  # 7 311
            0x13a: 'L3',  # a 314
            0x13b: 'R3',  # b 315

            0x130: "square",  # 0 304
            0x131: "cross",  # 1 305
            0x132: "circle",  # 2 306
            0x133: 'triangle',  # 3 307
        }

class F710JoystickController(JoystickController):
    '''
    A Controller object that maps inputs to actions
    '''
    def __init__(self, *args, **kwargs):
        super(F710JoystickController, self).__init__(*args, **kwargs)

    def init_js(self):
        '''
        attempt to init joystick
        '''
        try:
            self.js = F710Joystick(self.dev_fn)
            self.js.init()
        except FileNotFoundError:
            print(self.dev_fn, "not found.")
            self.js = None
        return self.js is not None

    def init_trigger_maps(self):
        '''
        init set of mapping from buttons to function calls
        '''
        self.button_down_trigger_map = {
            'select': self.toggle_mode,
            'circle': self.toggle_manual_recording,
            'triangle': self.erase_last_N_records,
            'cross': self.emergency_stop,
            'R2': self.increase_max_throttle,
            'L2': self.decrease_max_throttle,
            'start': self.toggle_constant_throttle,
            "R1": self.chaos_monkey_on_right,
            "L1": self.chaos_monkey_on_left,
        }

        self.button_up_trigger_map = {
            "R1": self.chaos_monkey_off,
            "L1": self.chaos_monkey_off,
        }

        self.axis_trigger_map = {
            'left_stick_horz': self.set_steering,
            'right_stick_vert': self.set_throttle,
        }

Elecom

Elecom Wireless Joystick。

項目 内容
メーカー elecom
型番 U3912T
技適 取得済み

AXIS

コード キー
0x00 left_stick_vert
0x01 left_stick_horz
0x02 right_stick_vert
0x05 right_stick_horz

BUTTON

Number キー
0x00 1
0x01 2
0x02 3
0x03 4
0x0a select
0x0b back
0x04 L1
0x05 R1
0x06 L2
0x07 R2

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class ElecomJoystick(Joystick):
    '''
    An interface to a physical PS3 joystick available at /dev/input/js0
    Contains mapping that work for Raspian Stretch drivers
    '''

    def __init__(self, *args, **kwargs):
        super(ElecomJoystick, self).__init__(*args, **kwargs)

        self.axis_names = {
            0x00: 'left_stick_horz',
            0x01: 'left_stick_vert',
            0x02: 'right_stick_horz',
            0x05: 'right_stick_vert',
        }

        self.button_names = {
            0x13a: 'select',  # a 314
            0x13b: 'start',  # b 315

            0x134: 'L1',  # 4 310
            0x135: 'R1',  # 5 311
            0x136: 'L2',  # 6 312
            0x137: 'R2',  # 7 313

            0x130: "square",  # 0 307
            0x132: "cross",  # 2 305
            0x133: "circle",  # 3 304
            0x131: 'triangle',  # 1 308
        }

class ElecomJoystickController(JoystickController):
    '''
    A Controller object that maps inputs to actions
    '''
    def __init__(self, *args, **kwargs):
        super(ElecomJoystickController, self).__init__(*args, **kwargs)

    def init_js(self):
        '''
        attempt to init joystick
        '''
        try:
            self.js = ElecomJoystick(self.dev_fn)
            self.js.init()
        except FileNotFoundError:
            print(self.dev_fn, "not found.")
            self.js = None
        return self.js is not None

    def init_trigger_maps(self):
        '''
        init set of mapping from buttons to function calls
        '''
        self.button_down_trigger_map = {
            'select': self.toggle_mode,
            'circle': self.toggle_manual_recording,
            'triangle': self.erase_last_N_records,
            'cross': self.emergency_stop,
            'R2': self.increase_max_throttle,
            'L2': self.decrease_max_throttle,
            'start': self.toggle_constant_throttle,
            "R1": self.chaos_monkey_on_right,
            "L1": self.chaos_monkey_on_left,
        }

        self.button_up_trigger_map = {
            "R1": self.chaos_monkey_off,
            "L1": self.chaos_monkey_off,
        }

        self.axis_trigger_map = {
            'left_stick_horz': self.set_steering,
            'right_stick_vert': self.set_throttle,
        }