forked from darthcloud/BlueRetro
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADAPTER] Add support for mapping quirks fixup
- Loading branch information
1 parent
759797a
commit 9b34707
Showing
9 changed files
with
184 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2021, Jacques Gagnon | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
#include "zephyr/types.h" | ||
#include "tools/util.h" | ||
#include "adapter.h" | ||
#include "mapping_quirks.h" | ||
|
||
static void face_btns_invert(uint32_t btns_mask[32]) { | ||
uint32_t tmp = btns_mask[PAD_RB_LEFT]; | ||
|
||
btns_mask[PAD_RB_LEFT] = btns_mask[PAD_RB_UP]; | ||
btns_mask[PAD_RB_UP] = tmp; | ||
|
||
tmp = btns_mask[PAD_RB_DOWN]; | ||
btns_mask[PAD_RB_DOWN] = btns_mask[PAD_RB_RIGHT]; | ||
btns_mask[PAD_RB_RIGHT] = tmp; | ||
} | ||
|
||
static void face_btns_rotate_right(uint32_t btns_mask[32]) { | ||
uint32_t tmp = btns_mask[PAD_RB_UP]; | ||
|
||
btns_mask[PAD_RB_UP] = btns_mask[PAD_RB_LEFT]; | ||
btns_mask[PAD_RB_LEFT] = btns_mask[PAD_RB_DOWN]; | ||
btns_mask[PAD_RB_DOWN] = btns_mask[PAD_RB_RIGHT]; | ||
btns_mask[PAD_RB_RIGHT] = tmp; | ||
} | ||
|
||
void mapping_quirks_apply(struct bt_data *bt_data) { | ||
if (atomic_test_bit(&bt_data->flags, BT_QUIRK_FACE_BTNS_INVERT)) { | ||
face_btns_invert(bt_data->raw_src_mappings[PAD].btns_mask); | ||
} | ||
if (atomic_test_bit(&bt_data->flags, BT_QUIRK_FACE_BTNS_ROTATE_RIGHT)) { | ||
face_btns_rotate_right(bt_data->raw_src_mappings[PAD].btns_mask); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright (c) 2021, Jacques Gagnon | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef _MAPPING_QUIRKS_H_ | ||
#define _MAPPING_QUIRKS_H_ | ||
#include "adapter.h" | ||
|
||
void mapping_quirks_apply(struct bt_data *bt_data); | ||
|
||
#endif /* _MAPPING_QUIRKS_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters