diff options
author | tmk <nobody@nowhere> | 2013-02-13 11:22:33 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2013-02-13 11:22:33 +0900 |
commit | 7054203e16af627a921b503a9508ce789913471d (patch) | |
tree | 9e5d1fd4aed7682e0e45579e6d6c311773fd50df /keyboard/hhkb | |
parent | 821563417565776d2dc3a02b0265e6fcd5218739 (diff) | |
parent | 2fe406de3ae4210e90acbf65ae926fcf382938e6 (diff) | |
download | firmware-7054203e16af627a921b503a9508ce789913471d.tar.gz firmware-7054203e16af627a921b503a9508ce789913471d.tar.bz2 firmware-7054203e16af627a921b503a9508ce789913471d.zip |
Merge branch 'transparent'
Diffstat (limited to 'keyboard/hhkb')
-rw-r--r-- | keyboard/hhkb/keymap.c | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/keyboard/hhkb/keymap.c b/keyboard/hhkb/keymap.c index 65ef89ad7..a5b6d3ace 100644 --- a/keyboard/hhkb/keymap.c +++ b/keyboard/hhkb/keymap.c @@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "keycode.h" #include "action.h" #include "action_macro.h" +#include "report.h" #include "host.h" #include "debug.h" #include "keymap.h" @@ -48,7 +49,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. } -// TODO: use [1] = KEYMAP(...) to prevent from changing index of element? static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Layer 0: Default Layer * ,-----------------------------------------------------------. @@ -309,40 +309,37 @@ void keymap_call_function(keyrecord_t *record, uint8_t id, uint8_t opt) } } -/* convert keycode to action */ -action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col) { - uint8_t key = (pgm_read_byte(&keymaps[(layer)][(row)][(col)])); + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.pos.row)][(key.pos.col)]); +} + +/* translates Fn index to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ action_t action; - switch (key) { - case KC_A ... KC_EXSEL: - action.code = ACTION_KEY(key); - break; - case KC_LCTRL ... KC_LGUI: - action.code = ACTION_LMOD(key); - break; - case KC_RCTRL ... KC_RGUI: - action.code = ACTION_RMOD(key); - break; - case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: - action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(key)); - break; - case KC_AUDIO_MUTE ... KC_WWW_FAVORITES: - action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(key)); - break; - case KC_MS_UP ... KC_MS_ACCEL2: - action.code = ACTION_MOUSEKEY(key); - break; + if (FN_INDEX(keycode) < sizeof(fn_actions) / sizeof(fn_actions[0])) { + action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); + } else { + action.code = ACTION_NO; + } + return action; +} + +/* convert key to action */ +action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col) +{ + key_t key; + key.pos.row = row; + key.pos.col = col; + uint8_t keycode = keymap_key_to_keycode(layer, key); + switch (keycode) { case KC_FN0 ... KC_FN31: - if (FN_INDEX(key) < sizeof(fn_actions) / sizeof(fn_actions[0])) { - action.code = pgm_read_word(&fn_actions[FN_INDEX(key)]); - } else { - action.code = ACTION_NO; - } - break; - case KC_NO ... KC_UNDEFINED: + return keymap_fn_to_action(keycode); default: - action.code = ACTION_NO; - break; + return keymap_keycode_to_action(keycode); } - return action; } |