Skip to content

Commit

Permalink
[BT] Add 8bitdo S30 Modkit support
Browse files Browse the repository at this point in the history
  • Loading branch information
darthcloud committed Jan 15, 2023
1 parent 425d3f9 commit 782e0c0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions main/adapter/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ enum {
BT_QUIRK_8BITDO_M30,
BT_QUIRK_BLUEN64_N64,
BT_QUIRK_RF_WARRIOR,
BT_QUIRK_8BITDO_SATURN,
};

/* Wired flags */
Expand Down
13 changes: 13 additions & 0 deletions main/adapter/mapping_quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ static void m30_8bitdo(struct raw_src_mapping *map) {
map->axes_to_btns[TRIG_R] = PAD_RB_RIGHT;
}

static void saturn_diy_8bitdo(struct raw_src_mapping *map) {
uint32_t tmp = map->btns_mask[PAD_LS];

map->btns_mask[PAD_LS] = map->btns_mask[PAD_RB_LEFT];
map->btns_mask[PAD_RB_LEFT] = map->btns_mask[PAD_RB_DOWN];
map->btns_mask[PAD_RB_DOWN] = map->btns_mask[PAD_RB_RIGHT];
map->btns_mask[PAD_RB_RIGHT] = map->btns_mask[PAD_RS];
map->btns_mask[PAD_RS] = tmp;
}

static void n64_bluen64(struct raw_src_mapping *map) {
map->mask[0] = 0x23150FFF;
map->desc[0] = 0x000000FF;
Expand Down Expand Up @@ -171,6 +181,9 @@ void mapping_quirks_apply(struct bt_data *bt_data) {
if (atomic_test_bit(&bt_data->base.flags[PAD], BT_QUIRK_8BITDO_M30)) {
m30_8bitdo(&bt_data->raw_src_mappings[PAD]);
}
if (atomic_test_bit(&bt_data->base.flags[PAD], BT_QUIRK_8BITDO_SATURN)) {
saturn_diy_8bitdo(&bt_data->raw_src_mappings[PAD]);
}
if (atomic_test_bit(&bt_data->base.flags[PAD], BT_QUIRK_BLUEN64_N64)) {
n64_bluen64(&bt_data->raw_src_mappings[PAD]);
}
Expand Down
1 change: 1 addition & 0 deletions main/bluetooth/hidp/hidp.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static const struct bt_name_type bt_name_type[] = {
{"8BitDo GBros Adapter", BT_XBOX, BT_8BITDO_GBROS, 0},
{"8Bitdo N64 GamePad", BT_HID_GENERIC, BT_SUBTYPE_DEFAULT, BIT(BT_QUIRK_8BITDO_N64)},
{"8BitDo M30 gamepad", BT_XBOX, BT_XBOX_XINPUT, BIT(BT_QUIRK_8BITDO_M30)},
{"8BitDo S30 Modkit", BT_XBOX, BT_XBOX_XINPUT, BIT(BT_QUIRK_8BITDO_SATURN)},
{"8Bitdo", BT_XBOX, BT_XBOX_XINPUT, 0}, /* 8bitdo catch all, tested with SF30 Pro */
{"Retro Bit Bluetooth Controller", BT_XBOX, BT_XBOX_XINPUT, BIT(BT_QUIRK_FACE_BTNS_TRIGGER_TO_6BUTTONS) | BIT(BT_QUIRK_TRIGGER_PRI_SEC_INVERT)},
{"Joy Controller", BT_XBOX, BT_XBOX_XINPUT, BIT(BT_QUIRK_RF_WARRIOR)},
Expand Down

0 comments on commit 782e0c0

Please sign in to comment.