summaryrefslogtreecommitdiff
path: root/quantum/keymap_common.c
diff options
context:
space:
mode:
authorZay950 <Zay950@users.noreply.github.com>2017-03-29 12:00:38 -0700
committerGitHub <noreply@github.com>2017-03-29 12:00:38 -0700
commit2366ebfbbdeb6ec29cc9a0facda44d666305dd6e (patch)
tree883efed0b7260f3143f5a2a879bc3844a8255e0b /quantum/keymap_common.c
parent80c5ada3394c5ad8087df00ef878eb2cbcd87d70 (diff)
parent942f2ccee44bdb2e251553e9730cd8d59307d8b2 (diff)
Merge branch 'master' into to_push
Diffstat (limited to 'quantum/keymap_common.c')
-rw-r--r--quantum/keymap_common.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index 833e5a8f8d..6cf4f031ff 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -1,5 +1,5 @@
/*
-Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
+Copyright 2012-2017 Jun Wako <wakojun@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -48,12 +48,10 @@ action_t action_for_key(uint8_t layer, keypos_t key)
action_t action;
uint8_t action_layer, when, mod;
- // The arm-none-eabi compiler generates out of bounds warnings when using the fn_actions directly for some reason
- const uint16_t* actions = fn_actions;
switch (keycode) {
case KC_FN0 ... KC_FN31:
- action.code = pgm_read_word(&actions[FN_INDEX(keycode)]);
+ action.code = keymap_function_id_to_action(FN_INDEX(keycode));
break;
case KC_A ... KC_EXSEL:
case KC_LCTRL ... KC_RGUI:
@@ -79,10 +77,13 @@ action_t action_for_key(uint8_t layer, keypos_t key)
case QK_FUNCTION ... QK_FUNCTION_MAX: ;
// Is a shortcut for function action_layer, pull last 12bits
// This means we have 4,096 FN macros at our disposal
- action.code = pgm_read_word(&actions[(int)keycode & 0xFFF]);
+ action.code = keymap_function_id_to_action( (int)keycode & 0xFFF );
break;
case QK_MACRO ... QK_MACRO_MAX:
- action.code = ACTION_MACRO(keycode & 0xFF);
+ if (keycode & 0x800) // tap macros have upper bit set
+ action.code = ACTION_MACRO_TAP(keycode & 0xFF);
+ else
+ action.code = ACTION_MACRO(keycode & 0xFF);
break;
case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
@@ -118,8 +119,11 @@ action_t action_for_key(uint8_t layer, keypos_t key)
mod = keycode & 0xFF;
action.code = ACTION_MODS_ONESHOT(mod);
break;
+ case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX:
+ action.code = ACTION_LAYER_TAP_TOGGLE(keycode & 0xFF);
+ break;
case QK_MOD_TAP ... QK_MOD_TAP_MAX:
- action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
+ action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0x1F, keycode & 0xFF);
break;
#ifdef BACKLIGHT_ENABLE
case BL_0 ... BL_15:
@@ -163,9 +167,17 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
}
-/* translates key to keycode */
+// translates key to keycode
+__attribute__ ((weak))
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
{
// Read entire word (16bits)
return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
}
+
+// translates function id to action
+__attribute__ ((weak))
+uint16_t keymap_function_id_to_action( uint16_t function_id )
+{
+ return pgm_read_word(&fn_actions[function_id]);
+}