From 9bc82bf61c342ca96e6f942b169b7c88b6bf95cf Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 13 Feb 2013 11:47:19 +0900 Subject: Change action API --- common/action.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'common/action.c') diff --git a/common/action.c b/common/action.c index 710300eb30..840d70f34c 100644 --- a/common/action.c +++ b/common/action.c @@ -26,6 +26,12 @@ along with this program. If not, see . #include "action.h" +/* default layer indicates base layer */ +uint8_t default_layer = 0; +/* current layer indicates active layer at this time */ +uint8_t current_layer = 0; + + static void process_action(keyrecord_t *record); static bool process_tapping(keyrecord_t *record); static void waiting_buffer_scan_tap(void); @@ -203,12 +209,12 @@ void action_exec(keyevent_t event) static action_t get_action(key_t key) { - action_t action = keymap_get_action(current_layer, key.pos.row, key.pos.col); + action_t action = action_for_key(current_layer, key); /* Transparently use default layer */ if (action.code == ACTION_TRANSPARENT) { // TODO: layer stacking - action = keymap_get_action(default_layer, key.pos.row, key.pos.col); + action = action_for_key(default_layer, key); debug("TRNASPARENT: "); debug_hex16(action.code); debug("\n"); } return action; @@ -509,12 +515,12 @@ static void process_action(keyrecord_t *record) /* Extentions */ case ACT_MACRO: + // TODO break; case ACT_COMMAND: break; case ACT_FUNCTION: - // TODO - keymap_call_function(record, action.func.id, action.func.opt); + action_function(record, action.func.id, action.func.opt); break; default: break; -- cgit v1.2.3 From c4421f585b085d3eef5e468ff1defcbc3b4ec8d3 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 13 Feb 2013 12:16:24 +0900 Subject: Change struct key_t --- common/action.c | 2 +- common/keyboard.c | 2 +- common/keyboard.h | 14 ++++---------- common/keymap.c | 2 +- keyboard/gh60/keymap.c | 2 +- keyboard/hhkb/keymap.c | 2 +- 6 files changed, 9 insertions(+), 15 deletions(-) (limited to 'common/action.c') diff --git a/common/action.c b/common/action.c index 840d70f34c..6528cd46c8 100644 --- a/common/action.c +++ b/common/action.c @@ -859,7 +859,7 @@ bool is_tap_key(key_t key) */ static void debug_event(keyevent_t event) { - debug_hex16(event.key.raw); + debug_hex16((event.key.row<<8) | event.key.col); if (event.pressed) debug("d("); else debug("u("); debug_dec(event.time); debug(")"); } diff --git a/common/keyboard.c b/common/keyboard.c index 2c88b3e437..e4bc3dc8c2 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -85,7 +85,7 @@ void keyboard_task(void) for (uint8_t c = 0; c < MATRIX_COLS; c++) { if (matrix_change & ((matrix_row_t)1< key_t? -typedef union { - uint16_t raw; - keypos_t pos; } key_t; /* key event */ @@ -46,20 +40,20 @@ typedef struct { } keyevent_t; /* equivalent test of key_t */ -#define KEYEQ(keya, keyb) ((keya).raw == (keyb).raw) +#define KEYEQ(keya, keyb) ((keya).row == (keyb).row && (keya).col == (keyb).col) /* (time == 0) means no event and assumes matrix has no 255 line. */ -#define IS_NOEVENT(event) ((event).time == 0 || ((event).key.pos.row == 255 && (event).key.pos.col == 255)) +#define IS_NOEVENT(event) ((event).time == 0 || ((event).key.row == 255 && (event).key.col == 255)) #define NOEVENT (keyevent_t){ \ - .key.pos = (keypos_t){ .row = 255, .col = 255 }, \ + .key = (key_t){ .row = 255, .col = 255 }, \ .pressed = false, \ .time = 0 \ } /* tick event */ #define TICK (keyevent_t){ \ - .key.pos = (keypos_t){ .row = 255, .col = 255 }, \ + .key = (key_t){ .row = 255, .col = 255 }, \ .pressed = false, \ .time = (timer_read() | 1) \ } diff --git a/common/keymap.c b/common/keymap.c index 6bae17f993..078615814e 100644 --- a/common/keymap.c +++ b/common/keymap.c @@ -58,7 +58,7 @@ __attribute__ ((weak)) action_t action_for_key(uint8_t layer, key_t key) { /* convert from legacy keycode to action */ - uint8_t keycode = keymap_get_keycode(layer, key.pos.row, key.pos.col); + uint8_t keycode = keymap_get_keycode(layer, key.row, key.col); action_t action; switch (keycode) { case KC_FN0 ... KC_FN31: diff --git a/keyboard/gh60/keymap.c b/keyboard/gh60/keymap.c index 9cef2137b6..a17c11fc3b 100644 --- a/keyboard/gh60/keymap.c +++ b/keyboard/gh60/keymap.c @@ -165,7 +165,7 @@ static const uint16_t PROGMEM fn_actions[] = { /* 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)]); + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); } /* translates Fn index to action */ diff --git a/keyboard/hhkb/keymap.c b/keyboard/hhkb/keymap.c index b1407e1ad8..ef21282ff1 100644 --- a/keyboard/hhkb/keymap.c +++ b/keyboard/hhkb/keymap.c @@ -314,7 +314,7 @@ void keymap_call_function(keyrecord_t *record, uint8_t id, uint8_t opt) /* 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)]); + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); } /* translates Fn index to action */ -- cgit v1.2.3