summaryrefslogtreecommitdiffstats
path: root/keyboard/gh60
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-02-13 11:20:47 +0900
committertmk <nobody@nowhere>2013-02-13 11:20:47 +0900
commit63c03dc137afe6600156a060b592662feaad0cdc (patch)
treec69cb8e797ac407028426a96dfebd56cf29211e3 /keyboard/gh60
parent48e6d0848cdeac26ffab101ea2ef48e5ac60acd3 (diff)
Change keymap API
Diffstat (limited to 'keyboard/gh60')
-rw-r--r--keyboard/gh60/keymap.c60
1 files changed, 26 insertions, 34 deletions
diff --git a/keyboard/gh60/keymap.c b/keyboard/gh60/keymap.c
index 39bb474c4a..d2da50529e 100644
--- a/keyboard/gh60/keymap.c
+++ b/keyboard/gh60/keymap.c
@@ -162,43 +162,35 @@ static const uint16_t PROGMEM fn_actions[] = {
-/* 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_TRNS:
- action.code = ACTION_TRANSPARENT;
- break;
+ return keymap_fn_to_action(keycode);
default:
- action.code = ACTION_NO;
- break;
+ return keymap_keycode_to_action(keycode);
}
- return action;
}