aboutsummaryrefslogtreecommitdiff
path: root/quantum/keymap_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/keymap_common.c')
-rw-r--r--quantum/keymap_common.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index 833e5a8f8..eced3d2bb 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -48,12 +48,10 @@ action_t action_for_key(uint8_t layer, keypos_t key)
48 48
49 action_t action; 49 action_t action;
50 uint8_t action_layer, when, mod; 50 uint8_t action_layer, when, mod;
51 // The arm-none-eabi compiler generates out of bounds warnings when using the fn_actions directly for some reason
52 const uint16_t* actions = fn_actions;
53 51
54 switch (keycode) { 52 switch (keycode) {
55 case KC_FN0 ... KC_FN31: 53 case KC_FN0 ... KC_FN31:
56 action.code = pgm_read_word(&actions[FN_INDEX(keycode)]); 54 action.code = keymap_function_id_to_action(FN_INDEX(keycode));
57 break; 55 break;
58 case KC_A ... KC_EXSEL: 56 case KC_A ... KC_EXSEL:
59 case KC_LCTRL ... KC_RGUI: 57 case KC_LCTRL ... KC_RGUI:
@@ -79,7 +77,7 @@ action_t action_for_key(uint8_t layer, keypos_t key)
79 case QK_FUNCTION ... QK_FUNCTION_MAX: ; 77 case QK_FUNCTION ... QK_FUNCTION_MAX: ;
80 // Is a shortcut for function action_layer, pull last 12bits 78 // Is a shortcut for function action_layer, pull last 12bits
81 // This means we have 4,096 FN macros at our disposal 79 // This means we have 4,096 FN macros at our disposal
82 action.code = pgm_read_word(&actions[(int)keycode & 0xFFF]); 80 action.code = keymap_function_id_to_action( (int)keycode & 0xFFF );
83 break; 81 break;
84 case QK_MACRO ... QK_MACRO_MAX: 82 case QK_MACRO ... QK_MACRO_MAX:
85 action.code = ACTION_MACRO(keycode & 0xFF); 83 action.code = ACTION_MACRO(keycode & 0xFF);
@@ -163,9 +161,17 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
163{ 161{
164} 162}
165 163
166/* translates key to keycode */ 164// translates key to keycode
165__attribute__ ((weak))
167uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) 166uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
168{ 167{
169 // Read entire word (16bits) 168 // Read entire word (16bits)
170 return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]); 169 return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
171} 170}
171
172// translates function id to action
173__attribute__ ((weak))
174uint16_t keymap_function_id_to_action( uint16_t function_id )
175{
176 return pgm_read_word(&fn_actions[function_id]);
177}