Skip to content
This repository was archived by the owner on Dec 14, 2025. It is now read-only.

Commit 178f06d

Browse files
committed
[TESTS] Update Xbox tests
1 parent 5bfba82 commit 178f06d

File tree

1 file changed

+148
-4
lines changed

1 file changed

+148
-4
lines changed

tests/pytest_xbox_ble_controller.py

Lines changed: 148 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,146 @@
1010

1111

1212
DEVICE_NAME = 'Xbox Wireless Controller'
13+
HID_DESC = bytes([
14+
0x05, 0x01, # Usage Page (Generic Desktop)
15+
0x09, 0x05, # Usage (Gamepad)
16+
0xA1, 0x01, # Collection (Application)
17+
0x85, 0x01, # Report ID (1)
18+
0x09, 0x01, # Usage (Pointer)
19+
0xA1, 0x00, # Collection (Physical)
20+
0x09, 0x30, # Usage (X)
21+
0x09, 0x31, # Usage (Y)
22+
0x15, 0x00, # Logical Minimum (0)
23+
0x27, 0xFF, 0xFF, 0x00, 0x00, # Logical Maximum (65534)
24+
0x95, 0x02, # Report Count (2)
25+
0x75, 0x10, # Report Size (16)
26+
0x81, 0x02, # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
27+
0xC0, # End Collection
28+
0x09, 0x01, # Usage (Pointer)
29+
0xA1, 0x00, # Collection (Physical)
30+
0x09, 0x32, # Usage (Z)
31+
0x09, 0x35, # Usage (Rz)
32+
0x15, 0x00, # Logical Minimum (0)
33+
0x27, 0xFF, 0xFF, 0x00, 0x00, # Logical Maximum (65534)
34+
0x95, 0x02, # Report Count (2)
35+
0x75, 0x10, # Report Size (16)
36+
0x81, 0x02, # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
37+
0xC0, # End Collection
38+
0x05, 0x02, # Usage Page (Simulation Controls)
39+
0x09, 0xC5, # Usage (Brake)
40+
0x15, 0x00, # Logical Minimum (0)
41+
0x26, 0xFF, 0x03, # Logical Maximum (1023)
42+
0x95, 0x01, # Report Count (1)
43+
0x75, 0x0A, # Report Size (10)
44+
0x81, 0x02, # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
45+
0x15, 0x00, # Logical Minimum (0)
46+
0x25, 0x00, # Logical Maximum (0)
47+
0x75, 0x06, # Report Size (6)
48+
0x95, 0x01, # Report Count (1)
49+
0x81, 0x03, # Input (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
50+
0x05, 0x02, # Usage Page (Simulation Controls)
51+
0x09, 0xC4, # Usage (Accelerator)
52+
0x15, 0x00, # Logical Minimum (0)
53+
0x26, 0xFF, 0x03, # Logical Maximum (1023)
54+
0x95, 0x01, # Report Count (1)
55+
0x75, 0x0A, # Report Size (10)
56+
0x81, 0x02, # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
57+
0x15, 0x00, # Logical Minimum (0)
58+
0x25, 0x00, # Logical Maximum (0)
59+
0x75, 0x06, # Report Size (6)
60+
0x95, 0x01, # Report Count (1)
61+
0x81, 0x03, # Input (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
62+
0x05, 0x01, # Usage Page (Generic Desktop)
63+
0x09, 0x39, # Usage (Hat Switch)
64+
0x15, 0x01, # Logical Minimum (1)
65+
0x25, 0x08, # Logical Maximum (8)
66+
0x35, 0x00, # Physical Minimum (0)
67+
0x46, 0x3B, 0x01, # Physical Maximum (315)
68+
0x66, 0x14, 0x00, # Unit (System: English Rotation, Length: Centimeter)
69+
0x75, 0x04, # Report Size (4)
70+
0x95, 0x01, # Report Count (1)
71+
0x81, 0x42, # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,Null State)
72+
0x75, 0x04, # Report Size (4)
73+
0x95, 0x01, # Report Count (1)
74+
0x15, 0x00, # Logical Minimum (0)
75+
0x25, 0x00, # Logical Maximum (0)
76+
0x35, 0x00, # Physical Minimum (0)
77+
0x45, 0x00, # Physical Maximum (0)
78+
0x65, 0x00, # Unit (None)
79+
0x81, 0x03, # Input (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
80+
0x05, 0x09, # Usage Page (Button)
81+
0x19, 0x01, # Usage Minimum (0x01)
82+
0x29, 0x0F, # Usage Maximum (0x0F)
83+
0x15, 0x00, # Logical Minimum (0)
84+
0x25, 0x01, # Logical Maximum (1)
85+
0x75, 0x01, # Report Size (1)
86+
0x95, 0x0F, # Report Count (15)
87+
0x81, 0x02, # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
88+
0x15, 0x00, # Logical Minimum (0)
89+
0x25, 0x00, # Logical Maximum (0)
90+
0x75, 0x01, # Report Size (1)
91+
0x95, 0x01, # Report Count (1)
92+
0x81, 0x03, # Input (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
93+
0x05, 0x0C, # Usage Page (Consumer)
94+
0x0A, 0xB2, 0x00, # Usage (Record)
95+
0x15, 0x00, # Logical Minimum (0)
96+
0x25, 0x01, # Logical Maximum (1)
97+
0x95, 0x01, # Report Count (1)
98+
0x75, 0x01, # Report Size (1)
99+
0x81, 0x02, # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
100+
0x15, 0x00, # Logical Minimum (0)
101+
0x25, 0x00, # Logical Maximum (0)
102+
0x75, 0x07, # Report Size (7)
103+
0x95, 0x01, # Report Count (1)
104+
0x81, 0x03, # Input (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
105+
0x05, 0x0F, # Usage Page (Physical Input Device)
106+
0x09, 0x21, # Usage (Set Effect Report)
107+
0x85, 0x03, # Report ID (3)
108+
0xA1, 0x02, # Collection (Logical)
109+
0x09, 0x97, # Usage (DC Enable Actuators)
110+
0x15, 0x00, # Logical Minimum (0)
111+
0x25, 0x01, # Logical Maximum (1)
112+
0x75, 0x04, # Report Size (4)
113+
0x95, 0x01, # Report Count (1)
114+
0x91, 0x02, # Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
115+
0x15, 0x00, # Logical Minimum (0)
116+
0x25, 0x00, # Logical Maximum (0)
117+
0x75, 0x04, # Report Size (4)
118+
0x95, 0x01, # Report Count (1)
119+
0x91, 0x03, # Output (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
120+
0x09, 0x70, # Usage (Magnitude)
121+
0x15, 0x00, # Logical Minimum (0)
122+
0x25, 0x64, # Logical Maximum (100)
123+
0x75, 0x08, # Report Size (8)
124+
0x95, 0x04, # Report Count (4)
125+
0x91, 0x02, # Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
126+
0x09, 0x50, # Usage (Duration)
127+
0x66, 0x01, 0x10, # Unit (System: SI Linear, Time: Seconds)
128+
0x55, 0x0E, # Unit Exponent (-2)
129+
0x15, 0x00, # Logical Minimum (0)
130+
0x26, 0xFF, 0x00, # Logical Maximum (255)
131+
0x75, 0x08, # Report Size (8)
132+
0x95, 0x01, # Report Count (1)
133+
0x91, 0x02, # Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
134+
0x09, 0xA7, # Usage (Start Delay)
135+
0x15, 0x00, # Logical Minimum (0)
136+
0x26, 0xFF, 0x00, # Logical Maximum (255)
137+
0x75, 0x08, # Report Size (8)
138+
0x95, 0x01, # Report Count (1)
139+
0x91, 0x02, # Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
140+
0x65, 0x00, # Unit (None)
141+
0x55, 0x00, # Unit Exponent (0)
142+
0x09, 0x7C, # Usage (Loop Count)
143+
0x15, 0x00, # Logical Minimum (0)
144+
0x26, 0xFF, 0x00, # Logical Maximum (255)
145+
0x75, 0x08, # Report Size (8)
146+
0x95, 0x01, # Report Count (1)
147+
0x91, 0x02, # Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
148+
0xC0, # End Collection
149+
0xC0, # End Collection
150+
151+
# 283 bytes
152+
])
13153

14154

15155
@pytest.mark.parametrize('blueretro', [[system.GC, dev_mode.PAD, bt_conn_type.BT_LE]], indirect=True)
@@ -18,8 +158,10 @@ def test_xbox_ble_controller_default_buttons_mapping(blueretro):
18158
# Set device name
19159
rsp = blueretro.send_name(DEVICE_NAME)
20160
assert rsp['type_update']['device_id'] == 0
21-
assert rsp['type_update']['device_type'] == 3
22-
assert rsp['type_update']['device_subtype'] == 9
161+
assert rsp['type_update']['device_type'] == 0
162+
assert rsp['type_update']['device_subtype'] == 0
163+
164+
rsp = blueretro.send_hid_desc(HID_DESC)
23165

24166
# Init adapter with a few neutral state report
25167
for _ in range(2):
@@ -65,8 +207,10 @@ def test_xbox_ble_controller_axes_default_scaling(blueretro):
65207
# Set device name
66208
rsp = blueretro.send_name(DEVICE_NAME)
67209
assert rsp['type_update']['device_id'] == 0
68-
assert rsp['type_update']['device_type'] == 3
69-
assert rsp['type_update']['device_subtype'] == 9
210+
assert rsp['type_update']['device_type'] == 0
211+
assert rsp['type_update']['device_subtype'] == 0
212+
213+
rsp = blueretro.send_hid_desc(HID_DESC)
70214

71215
# Init adapter with a few neutral state report
72216
for _ in range(2):

0 commit comments

Comments
 (0)