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

Commit ecd53dd

Browse files
committed
[ADAPTER] Combine flags & PNP based quirks in same function
1 parent de9f63a commit ecd53dd

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

main/adapter/mapping_quirks.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021-2023, Jacques Gagnon
2+
* Copyright (c) 2021-2025, Jacques Gagnon
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

@@ -265,7 +265,20 @@ static void ouya(struct raw_src_mapping *map) {
265265
map->btns_mask[PAD_RJ] = BIT(OUYA_R3);
266266
}
267267

268+
static void mapping_quirks_apply_pnp(struct bt_data *bt_data) {
269+
switch (bt_data->base.vid) {
270+
case 0x18D1: /* Google */
271+
switch (bt_data->base.pid) {
272+
case 0x9400: /* Stadia */
273+
stadia(&bt_data->raw_src_mappings[PAD]);
274+
break;
275+
}
276+
break;
277+
}
278+
}
279+
268280
void mapping_quirks_apply(struct bt_data *bt_data) {
281+
mapping_quirks_apply_pnp(bt_data);
269282
if (atomic_test_bit(&bt_data->base.flags[PAD], BT_QUIRK_FACE_BTNS_INVERT)) {
270283
face_btns_invert(&bt_data->raw_src_mappings[PAD]);
271284
}
@@ -311,16 +324,4 @@ void mapping_quirks_apply(struct bt_data *bt_data) {
311324
if (atomic_test_bit(&bt_data->base.flags[PAD], BT_QUIRK_8BITDO_GBROS)) {
312325
gc_gbros_8bitdo(&bt_data->raw_src_mappings[PAD]);
313326
}
314-
}
315-
316-
void mapping_quirks_apply_pnp(struct bt_data *bt_data) {
317-
switch (bt_data->base.vid) {
318-
case 0x18D1: /* Google */
319-
switch (bt_data->base.pid) {
320-
case 0x9400: /* Stadia */
321-
stadia(&bt_data->raw_src_mappings[PAD]);
322-
break;
323-
}
324-
break;
325-
}
326327
}

main/adapter/mapping_quirks.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Jacques Gagnon
2+
* Copyright (c) 2021-2025, Jacques Gagnon
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

@@ -8,6 +8,5 @@
88
#include "adapter.h"
99

1010
void mapping_quirks_apply(struct bt_data *bt_data);
11-
void mapping_quirks_apply_pnp(struct bt_data *bt_data);
1211

1312
#endif /* _MAPPING_QUIRKS_H_ */

main/bluetooth/att_hid.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ static void bt_att_hid_process_pnp(struct bt_dev *device,
151151
}
152152
printf("%s: VID: 0x%04X PID: 0x%04X\n", __FUNCTION__, bt_data->base.vid, bt_data->base.pid);
153153
bt_mon_log(true, "%s: VID: 0x%04X PID: 0x%04X\n", __FUNCTION__, bt_data->base.vid, bt_data->base.pid);
154-
mapping_quirks_apply_pnp(bt_data);
155154
bt_att_hid_start_next_state(device, hid_data);
156155
}
157156

main/bluetooth/sdp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ void bt_sdp_parser(struct bt_data *bt_data) {
182182
}
183183
printf("%s: VID: 0x%04X PID: 0x%04X\n", __FUNCTION__, bt_data->base.vid, bt_data->base.pid);
184184
bt_mon_log(true, "%s: VID: 0x%04X PID: 0x%04X\n", __FUNCTION__, bt_data->base.vid, bt_data->base.pid);
185-
mapping_quirks_apply_pnp(bt_data);
186185

187186
hid_desc = memmem(bt_data->base.sdp_data, bt_data->base.sdp_len, sdp_hid_desc_list, sizeof(sdp_hid_desc_list));
188187
hid_offset = hid_desc - bt_data->base.sdp_data;

0 commit comments

Comments
 (0)