aboutsummaryrefslogtreecommitdiff
path: root/quantum/keymap_common.c
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2021-08-24 14:28:37 +0100
committerGitHub <noreply@github.com>2021-08-24 14:28:37 +0100
commitc4dbf4bf0118dd785802861beb247433b5b7411d (patch)
tree91e5142e9c280db4fbee6c0d7e64f1abdad79109 /quantum/keymap_common.c
parentc4a2dc9a2d1b0c053272aec7672ab8df92550e88 (diff)
downloadqmk_firmware-c4dbf4bf0118dd785802861beb247433b5b7411d.tar.gz
qmk_firmware-c4dbf4bf0118dd785802861beb247433b5b7411d.zip
Tidy up quantum.c now some of tmk_core has been merged (#14083)
Diffstat (limited to 'quantum/keymap_common.c')
-rw-r--r--quantum/keymap_common.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index 780c71ab9..008177bbe 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -36,6 +36,31 @@ extern keymap_config_t keymap_config;
36 36
37#include <inttypes.h> 37#include <inttypes.h>
38 38
39uint8_t extract_mod_bits(uint16_t code) {
40 switch (code) {
41 case QK_MODS ... QK_MODS_MAX:
42 break;
43 default:
44 return 0;
45 }
46
47 uint8_t mods_to_send = 0;
48
49 if (code & QK_RMODS_MIN) { // Right mod flag is set
50 if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RCTL);
51 if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RSFT);
52 if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RALT);
53 if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_RGUI);
54 } else {
55 if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_LCTL);
56 if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_LSFT);
57 if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_LALT);
58 if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI);
59 }
60
61 return mods_to_send;
62}
63
39/* converts key to action */ 64/* converts key to action */
40action_t action_for_key(uint8_t layer, keypos_t key) { 65action_t action_for_key(uint8_t layer, keypos_t key) {
41 // 16bit keycodes - important 66 // 16bit keycodes - important