diff options
| author | tmk <nobody@nowhere> | 2013-02-13 13:31:01 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-02-13 13:31:01 +0900 |
| commit | 7a31451a077a55e1ad97cf8b31a111c7cd311a4d (patch) | |
| tree | 335730a0308cdb2e2ec094fe08ac63ee29ce4f80 | |
| parent | 7054203e16af627a921b503a9508ce789913471d (diff) | |
| parent | c4421f585b085d3eef5e468ff1defcbc3b4ec8d3 (diff) | |
| download | qmk_firmware-7a31451a077a55e1ad97cf8b31a111c7cd311a4d.tar.gz qmk_firmware-7a31451a077a55e1ad97cf8b31a111c7cd311a4d.zip | |
Merge branch 'actionfix'
| -rw-r--r-- | common/action.c | 16 | ||||
| -rw-r--r-- | common/action.h | 200 | ||||
| -rw-r--r-- | common/keyboard.c | 2 | ||||
| -rw-r--r-- | common/keyboard.h | 14 | ||||
| -rw-r--r-- | common/keymap.c | 11 | ||||
| -rw-r--r-- | common/keymap.h | 17 | ||||
| -rw-r--r-- | keyboard/gh60/keymap.c | 7 | ||||
| -rw-r--r-- | keyboard/hhkb/keymap.c | 7 |
8 files changed, 128 insertions, 146 deletions
diff --git a/common/action.c b/common/action.c index 710300eb3..6528cd46c 100644 --- a/common/action.c +++ b/common/action.c | |||
| @@ -26,6 +26,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 26 | #include "action.h" | 26 | #include "action.h" |
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | /* default layer indicates base layer */ | ||
| 30 | uint8_t default_layer = 0; | ||
| 31 | /* current layer indicates active layer at this time */ | ||
| 32 | uint8_t current_layer = 0; | ||
| 33 | |||
| 34 | |||
| 29 | static void process_action(keyrecord_t *record); | 35 | static void process_action(keyrecord_t *record); |
| 30 | static bool process_tapping(keyrecord_t *record); | 36 | static bool process_tapping(keyrecord_t *record); |
| 31 | static void waiting_buffer_scan_tap(void); | 37 | static void waiting_buffer_scan_tap(void); |
| @@ -203,12 +209,12 @@ void action_exec(keyevent_t event) | |||
| 203 | 209 | ||
| 204 | static action_t get_action(key_t key) | 210 | static action_t get_action(key_t key) |
| 205 | { | 211 | { |
| 206 | action_t action = keymap_get_action(current_layer, key.pos.row, key.pos.col); | 212 | action_t action = action_for_key(current_layer, key); |
| 207 | 213 | ||
| 208 | /* Transparently use default layer */ | 214 | /* Transparently use default layer */ |
| 209 | if (action.code == ACTION_TRANSPARENT) { | 215 | if (action.code == ACTION_TRANSPARENT) { |
| 210 | // TODO: layer stacking | 216 | // TODO: layer stacking |
| 211 | action = keymap_get_action(default_layer, key.pos.row, key.pos.col); | 217 | action = action_for_key(default_layer, key); |
| 212 | debug("TRNASPARENT: "); debug_hex16(action.code); debug("\n"); | 218 | debug("TRNASPARENT: "); debug_hex16(action.code); debug("\n"); |
| 213 | } | 219 | } |
| 214 | return action; | 220 | return action; |
| @@ -509,12 +515,12 @@ static void process_action(keyrecord_t *record) | |||
| 509 | 515 | ||
| 510 | /* Extentions */ | 516 | /* Extentions */ |
| 511 | case ACT_MACRO: | 517 | case ACT_MACRO: |
| 518 | // TODO | ||
| 512 | break; | 519 | break; |
| 513 | case ACT_COMMAND: | 520 | case ACT_COMMAND: |
| 514 | break; | 521 | break; |
| 515 | case ACT_FUNCTION: | 522 | case ACT_FUNCTION: |
| 516 | // TODO | 523 | action_function(record, action.func.id, action.func.opt); |
| 517 | keymap_call_function(record, action.func.id, action.func.opt); | ||
| 518 | break; | 524 | break; |
| 519 | default: | 525 | default: |
| 520 | break; | 526 | break; |
| @@ -853,7 +859,7 @@ bool is_tap_key(key_t key) | |||
| 853 | */ | 859 | */ |
| 854 | static void debug_event(keyevent_t event) | 860 | static void debug_event(keyevent_t event) |
| 855 | { | 861 | { |
| 856 | debug_hex16(event.key.raw); | 862 | debug_hex16((event.key.row<<8) | event.key.col); |
| 857 | if (event.pressed) debug("d("); else debug("u("); | 863 | if (event.pressed) debug("d("); else debug("u("); |
| 858 | debug_dec(event.time); debug(")"); | 864 | debug_dec(event.time); debug(")"); |
| 859 | } | 865 | } |
diff --git a/common/action.h b/common/action.h index bb44049ad..b9a6cb5b4 100644 --- a/common/action.h +++ b/common/action.h | |||
| @@ -21,10 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 21 | #include "keycode.h" | 21 | #include "keycode.h" |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | /* Execute action per keyevent */ | ||
| 25 | void action_exec(keyevent_t event); | ||
| 26 | |||
| 27 | |||
| 28 | /* Struct to record event and tap count */ | 24 | /* Struct to record event and tap count */ |
| 29 | typedef struct { | 25 | typedef struct { |
| 30 | keyevent_t event; | 26 | keyevent_t event; |
| @@ -33,7 +29,7 @@ typedef struct { | |||
| 33 | 29 | ||
| 34 | /* Action struct. | 30 | /* Action struct. |
| 35 | * | 31 | * |
| 36 | * In avr-gcc bit field seems to be assigned from LSB(bit0) to MSB(bit15). | 32 | * In avr-gcc bit field seems to be assigned from LSB(bit0) to MSB(bit15). |
| 37 | * AVR looks like a little endian in avr-gcc. | 33 | * AVR looks like a little endian in avr-gcc. |
| 38 | * | 34 | * |
| 39 | * NOTE: not portable across compiler/endianness? | 35 | * NOTE: not portable across compiler/endianness? |
| @@ -79,6 +75,21 @@ typedef union { | |||
| 79 | } action_t; | 75 | } action_t; |
| 80 | 76 | ||
| 81 | 77 | ||
| 78 | |||
| 79 | /* layer used currently */ | ||
| 80 | extern uint8_t current_layer; | ||
| 81 | /* layer to return or start with */ | ||
| 82 | extern uint8_t default_layer; | ||
| 83 | |||
| 84 | /* Execute action per keyevent */ | ||
| 85 | void action_exec(keyevent_t event); | ||
| 86 | |||
| 87 | /* action for key */ | ||
| 88 | action_t action_for_key(uint8_t layer, key_t key); | ||
| 89 | |||
| 90 | /* user defined special function */ | ||
| 91 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); | ||
| 92 | |||
| 82 | /* | 93 | /* |
| 83 | * Utilities for actions. | 94 | * Utilities for actions. |
| 84 | */ | 95 | */ |
| @@ -96,98 +107,97 @@ bool waiting_buffer_has_anykey_pressed(void); | |||
| 96 | 107 | ||
| 97 | 108 | ||
| 98 | 109 | ||
| 99 | |||
| 100 | /* | 110 | /* |
| 101 | * Action codes | 111 | * Action codes |
| 102 | * ============ | 112 | * ============ |
| 103 | * 16bit code: action_kind(4bit) + action_parameter(12bit) | 113 | * 16bit code: action_kind(4bit) + action_parameter(12bit) |
| 104 | * | 114 | * |
| 105 | Keyboard Keys | 115 | * Keyboard Keys |
| 106 | ------------- | 116 | * ------------- |
| 107 | ACT_LMODS(0000): | 117 | * ACT_LMODS(0000): |
| 108 | 0000|0000|000000|00 No action | 118 | * 0000|0000|000000|00 No action |
| 109 | 0000|0000|000000|01 Transparent | 119 | * 0000|0000|000000|01 Transparent |
| 110 | 0000|0000| keycode Key | 120 | * 0000|0000| keycode Key |
| 111 | 0000|mods|000000|00 Left mods | 121 | * 0000|mods|000000|00 Left mods |
| 112 | 0000|mods| keycode Key & Left mods | 122 | * 0000|mods| keycode Key & Left mods |
| 113 | 123 | * | |
| 114 | ACT_RMODS(0001): | 124 | * ACT_RMODS(0001): |
| 115 | 0001|0000|000000|00 No action(not used) | 125 | * 0001|0000|000000|00 No action(not used) |
| 116 | 0001|0000|000000|01 Transparent(not used) | 126 | * 0001|0000|000000|01 Transparent(not used) |
| 117 | 0001|0000| keycode Key(no used) | 127 | * 0001|0000| keycode Key(no used) |
| 118 | 0001|mods|000000|00 Right mods | 128 | * 0001|mods|000000|00 Right mods |
| 119 | 0001|mods| keycode Key & Right mods | 129 | * 0001|mods| keycode Key & Right mods |
| 120 | 130 | * | |
| 121 | ACT_LMODS_TAP(0010): | 131 | * ACT_LMODS_TAP(0010): |
| 122 | 0010|mods|000000|00 Left mods OneShot | 132 | * 0010|mods|000000|00 Left mods OneShot |
| 123 | 0010|mods|000000|01 (reserved) | 133 | * 0010|mods|000000|01 (reserved) |
| 124 | 0010|mods|000000|10 (reserved) | 134 | * 0010|mods|000000|10 (reserved) |
| 125 | 0010|mods|000000|11 (reserved) | 135 | * 0010|mods|000000|11 (reserved) |
| 126 | 0010|mods| keycode Left mods + tap Key | 136 | * 0010|mods| keycode Left mods + tap Key |
| 127 | 137 | * | |
| 128 | ACT_RMODS_TAP(0011): | 138 | * ACT_RMODS_TAP(0011): |
| 129 | 0011|mods|000000|00 Right mods OneShot | 139 | * 0011|mods|000000|00 Right mods OneShot |
| 130 | 0011|mods|000000|01 (reserved) | 140 | * 0011|mods|000000|01 (reserved) |
| 131 | 0011|mods|000000|10 (reserved) | 141 | * 0011|mods|000000|10 (reserved) |
| 132 | 0011|mods|000000|11 (reserved) | 142 | * 0011|mods|000000|11 (reserved) |
| 133 | 0011|mods| keycode Right mods + tap Key | 143 | * 0011|mods| keycode Right mods + tap Key |
| 134 | 144 | * | |
| 135 | 145 | * | |
| 136 | Other HID Usage | 146 | * Other HID Usage |
| 137 | --------------- | 147 | * --------------- |
| 138 | This action handles other usages than keyboard. | 148 | * This action handles other usages than keyboard. |
| 139 | ACT_USAGE(0100): | 149 | * ACT_USAGE(0100): |
| 140 | 0100|00| usage(10) System control(0x80) - General Desktop page(0x01) | 150 | * 0100|00| usage(10) System control(0x80) - General Desktop page(0x01) |
| 141 | 0100|01| usage(10) Consumer control(0x01) - Consumer page(0x0C) | 151 | * 0100|01| usage(10) Consumer control(0x01) - Consumer page(0x0C) |
| 142 | 0100|10| usage(10) (reserved) | 152 | * 0100|10| usage(10) (reserved) |
| 143 | 0100|11| usage(10) (reserved) | 153 | * 0100|11| usage(10) (reserved) |
| 144 | 154 | * | |
| 145 | 155 | * | |
| 146 | Mouse Keys | 156 | * Mouse Keys |
| 147 | ---------- | 157 | * ---------- |
| 148 | TODO: can be combined with 'Other HID Usage'? to save action kind id. | 158 | * TODO: can be combined with 'Other HID Usage'? to save action kind id. |
| 149 | ACT_MOUSEKEY(0110): | 159 | * ACT_MOUSEKEY(0110): |
| 150 | 0101|XXXX| keycode Mouse key | 160 | * 0101|XXXX| keycode Mouse key |
| 151 | 161 | * | |
| 152 | 162 | * | |
| 153 | Layer Actions | 163 | * Layer Actions |
| 154 | ------------- | 164 | * ------------- |
| 155 | ACT_LAYER(1000): Set layer | 165 | * ACT_LAYER(1000): Set layer |
| 156 | ACT_LAYER_BIT(1001): Bit-op layer | 166 | * ACT_LAYER_BIT(1001): Bit-op layer |
| 157 | 167 | * | |
| 158 | 1000|LLLL|0000 0000 set L to layer on press and set default on release(momentary) | 168 | * 1000|LLLL|0000 0000 set L to layer on press and set default on release(momentary) |
| 159 | 1000|LLLL|0000 0001 set L to layer on press | 169 | * 1000|LLLL|0000 0001 set L to layer on press |
| 160 | 1000|LLLL|0000 0010 set L to layer on release | 170 | * 1000|LLLL|0000 0010 set L to layer on release |
| 161 | 1000|----|0000 0011 set default to layer on both(return to default layer) | 171 | * 1000|----|0000 0011 set default to layer on both(return to default layer) |
| 162 | 1000|LLLL| keycode set L to layer while hold and send key on tap | 172 | * 1000|LLLL| keycode set L to layer while hold and send key on tap |
| 163 | 1000|LLLL|1111 0000 set L to layer while hold and toggle on several taps | 173 | * 1000|LLLL|1111 0000 set L to layer while hold and toggle on several taps |
| 164 | 1000|LLLL|1111 1111 set L to default and layer(on press) | 174 | * 1000|LLLL|1111 1111 set L to default and layer(on press) |
| 165 | 175 | * | |
| 166 | 1001|BBBB|0000 0000 (not used) | 176 | * 1001|BBBB|0000 0000 (not used) |
| 167 | 1001|BBBB|0000 0001 bit-xor layer with B on press | 177 | * 1001|BBBB|0000 0001 bit-xor layer with B on press |
| 168 | 1001|BBBB|0000 0010 bit-xor layer with B on release | 178 | * 1001|BBBB|0000 0010 bit-xor layer with B on release |
| 169 | 1001|BBBB|0000 0011 bit-xor layer with B on both(momentary) | 179 | * 1001|BBBB|0000 0011 bit-xor layer with B on both(momentary) |
| 170 | 1001|BBBB| keycode bit-xor layer with B while hold and send key on tap | 180 | * 1001|BBBB| keycode bit-xor layer with B while hold and send key on tap |
| 171 | 1001|BBBB|1111 0000 bit-xor layer with B while hold and toggle on several taps | 181 | * 1001|BBBB|1111 0000 bit-xor layer with B while hold and toggle on several taps |
| 172 | 1001|BBBB|1111 1111 bit-xor default with B and set layer(on press) | 182 | * 1001|BBBB|1111 1111 bit-xor default with B and set layer(on press) |
| 173 | 183 | * | |
| 174 | 184 | * | |
| 175 | 185 | * | |
| 176 | Extensions(11XX) | 186 | * Extensions(11XX) |
| 177 | ---------------- | 187 | * ---------------- |
| 178 | NOTE: NOT FIXED | 188 | * NOTE: NOT FIXED |
| 179 | 189 | * | |
| 180 | ACT_MACRO(1100): | 190 | * ACT_MACRO(1100): |
| 181 | 1100|opt | id(8) Macro play? | 191 | * 1100|opt | id(8) Macro play? |
| 182 | 1100|1111| id(8) Macro record? | 192 | * 1100|1111| id(8) Macro record? |
| 183 | 193 | * | |
| 184 | ACT_COMMAND(1110): | 194 | * ACT_COMMAND(1110): |
| 185 | 1110|opt | id(8) Built-in Command exec | 195 | * 1110|opt | id(8) Built-in Command exec |
| 186 | 196 | * | |
| 187 | ACT_FUNCTION(1111): | 197 | * ACT_FUNCTION(1111): |
| 188 | 1111| address(12) Function? | 198 | * 1111| address(12) Function? |
| 189 | 1111|opt | id(8) Function? | 199 | * 1111|opt | id(8) Function? |
| 190 | 200 | * | |
| 191 | */ | 201 | */ |
| 192 | enum action_kind_id { | 202 | enum action_kind_id { |
| 193 | ACT_LMODS = 0b0000, | 203 | ACT_LMODS = 0b0000, |
| @@ -241,7 +251,7 @@ enum mods_codes { | |||
| 241 | #define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) | 251 | #define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) |
| 242 | 252 | ||
| 243 | 253 | ||
| 244 | /* | 254 | /* |
| 245 | * Switch layer | 255 | * Switch layer |
| 246 | */ | 256 | */ |
| 247 | enum layer_codes { | 257 | enum layer_codes { |
| @@ -258,7 +268,7 @@ enum layer_vals_default { | |||
| 258 | DEFAULT_ON_BOTH = 3, | 268 | DEFAULT_ON_BOTH = 3, |
| 259 | }; | 269 | }; |
| 260 | 270 | ||
| 261 | /* | 271 | /* |
| 262 | * return to default layer | 272 | * return to default layer |
| 263 | */ | 273 | */ |
| 264 | #define ACTION_LAYER_DEFAULT ACTION_LAYER_DEFAULT_R | 274 | #define ACTION_LAYER_DEFAULT ACTION_LAYER_DEFAULT_R |
| @@ -288,7 +298,7 @@ enum layer_vals_default { | |||
| 288 | /* set default layer on both press and release */ | 298 | /* set default layer on both press and release */ |
| 289 | #define ACTION_LAYER_SET_DEFAULT(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_CHANGE_DEFAULT) | 299 | #define ACTION_LAYER_SET_DEFAULT(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_CHANGE_DEFAULT) |
| 290 | 300 | ||
| 291 | /* | 301 | /* |
| 292 | * Bit-op layer | 302 | * Bit-op layer |
| 293 | */ | 303 | */ |
| 294 | /* bit-xor on both press and release */ | 304 | /* bit-xor on both press and release */ |
diff --git a/common/keyboard.c b/common/keyboard.c index 2c88b3e43..e4bc3dc8c 100644 --- a/common/keyboard.c +++ b/common/keyboard.c | |||
| @@ -85,7 +85,7 @@ void keyboard_task(void) | |||
| 85 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { | 85 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { |
| 86 | if (matrix_change & ((matrix_row_t)1<<c)) { | 86 | if (matrix_change & ((matrix_row_t)1<<c)) { |
| 87 | action_exec((keyevent_t){ | 87 | action_exec((keyevent_t){ |
| 88 | .key.pos = (keypos_t){ .row = r, .col = c }, | 88 | .key = (key_t){ .row = r, .col = c }, |
| 89 | .pressed = (matrix_row & (1<<c)), | 89 | .pressed = (matrix_row & (1<<c)), |
| 90 | .time = (timer_read() | 1) /* time should not be 0 */ | 90 | .time = (timer_read() | 1) /* time should not be 0 */ |
| 91 | }); | 91 | }); |
diff --git a/common/keyboard.h b/common/keyboard.h index e1cab3119..78cb24034 100644 --- a/common/keyboard.h +++ b/common/keyboard.h | |||
| @@ -30,12 +30,6 @@ extern "C" { | |||
| 30 | typedef struct { | 30 | typedef struct { |
| 31 | uint8_t col; | 31 | uint8_t col; |
| 32 | uint8_t row; | 32 | uint8_t row; |
| 33 | } keypos_t; | ||
| 34 | |||
| 35 | // TODO: need raw? keypos_t -> key_t? | ||
| 36 | typedef union { | ||
| 37 | uint16_t raw; | ||
| 38 | keypos_t pos; | ||
| 39 | } key_t; | 33 | } key_t; |
| 40 | 34 | ||
| 41 | /* key event */ | 35 | /* key event */ |
| @@ -46,20 +40,20 @@ typedef struct { | |||
| 46 | } keyevent_t; | 40 | } keyevent_t; |
| 47 | 41 | ||
| 48 | /* equivalent test of key_t */ | 42 | /* equivalent test of key_t */ |
| 49 | #define KEYEQ(keya, keyb) ((keya).raw == (keyb).raw) | 43 | #define KEYEQ(keya, keyb) ((keya).row == (keyb).row && (keya).col == (keyb).col) |
| 50 | 44 | ||
| 51 | /* (time == 0) means no event and assumes matrix has no 255 line. */ | 45 | /* (time == 0) means no event and assumes matrix has no 255 line. */ |
| 52 | #define IS_NOEVENT(event) ((event).time == 0 || ((event).key.pos.row == 255 && (event).key.pos.col == 255)) | 46 | #define IS_NOEVENT(event) ((event).time == 0 || ((event).key.row == 255 && (event).key.col == 255)) |
| 53 | 47 | ||
| 54 | #define NOEVENT (keyevent_t){ \ | 48 | #define NOEVENT (keyevent_t){ \ |
| 55 | .key.pos = (keypos_t){ .row = 255, .col = 255 }, \ | 49 | .key = (key_t){ .row = 255, .col = 255 }, \ |
| 56 | .pressed = false, \ | 50 | .pressed = false, \ |
| 57 | .time = 0 \ | 51 | .time = 0 \ |
| 58 | } | 52 | } |
| 59 | 53 | ||
| 60 | /* tick event */ | 54 | /* tick event */ |
| 61 | #define TICK (keyevent_t){ \ | 55 | #define TICK (keyevent_t){ \ |
| 62 | .key.pos = (keypos_t){ .row = 255, .col = 255 }, \ | 56 | .key = (key_t){ .row = 255, .col = 255 }, \ |
| 63 | .pressed = false, \ | 57 | .pressed = false, \ |
| 64 | .time = (timer_read() | 1) \ | 58 | .time = (timer_read() | 1) \ |
| 65 | } | 59 | } |
diff --git a/common/keymap.c b/common/keymap.c index 2782ea9d6..078615814 100644 --- a/common/keymap.c +++ b/common/keymap.c | |||
| @@ -20,11 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | #include "action.h" | 20 | #include "action.h" |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | /* layer */ | ||
| 24 | uint8_t default_layer = 0; | ||
| 25 | uint8_t current_layer = 0; | ||
| 26 | |||
| 27 | |||
| 28 | action_t keymap_keycode_to_action(uint8_t keycode) | 23 | action_t keymap_keycode_to_action(uint8_t keycode) |
| 29 | { | 24 | { |
| 30 | action_t action; | 25 | action_t action; |
| @@ -60,10 +55,10 @@ action_t keymap_keycode_to_action(uint8_t keycode) | |||
| 60 | #ifndef NO_LEGACY_KEYMAP_SUPPORT | 55 | #ifndef NO_LEGACY_KEYMAP_SUPPORT |
| 61 | /* legacy support with weak reference */ | 56 | /* legacy support with weak reference */ |
| 62 | __attribute__ ((weak)) | 57 | __attribute__ ((weak)) |
| 63 | action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col) | 58 | action_t action_for_key(uint8_t layer, key_t key) |
| 64 | { | 59 | { |
| 65 | /* convert from legacy keycode to action */ | 60 | /* convert from legacy keycode to action */ |
| 66 | uint8_t keycode = keymap_get_keycode(layer, row, col); | 61 | uint8_t keycode = keymap_get_keycode(layer, key.row, key.col); |
| 67 | action_t action; | 62 | action_t action; |
| 68 | switch (keycode) { | 63 | switch (keycode) { |
| 69 | case KC_FN0 ... KC_FN31: | 64 | case KC_FN0 ... KC_FN31: |
| @@ -84,6 +79,6 @@ action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col) | |||
| 84 | #endif | 79 | #endif |
| 85 | 80 | ||
| 86 | __attribute__ ((weak)) | 81 | __attribute__ ((weak)) |
| 87 | void keymap_call_function(keyrecord_t *event, uint8_t id, uint8_t opt) | 82 | void action_function(keyrecord_t *event, uint8_t id, uint8_t opt) |
| 88 | { | 83 | { |
| 89 | } | 84 | } |
diff --git a/common/keymap.h b/common/keymap.h index ee36eab83..63bf14482 100644 --- a/common/keymap.h +++ b/common/keymap.h | |||
| @@ -23,13 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 23 | #include "action.h" | 23 | #include "action.h" |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | // TODO: move to action.h? | ||
| 27 | /* layer used currently */ | ||
| 28 | extern uint8_t current_layer; | ||
| 29 | /* layer to return or start with */ | ||
| 30 | extern uint8_t default_layer; | ||
| 31 | |||
| 32 | |||
| 33 | /* translates key_t to keycode */ | 26 | /* translates key_t to keycode */ |
| 34 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key); | 27 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key); |
| 35 | /* translates keycode to action */ | 28 | /* translates keycode to action */ |
| @@ -38,22 +31,12 @@ action_t keymap_keycode_to_action(uint8_t keycode); | |||
| 38 | action_t keymap_fn_to_action(uint8_t keycode); | 31 | action_t keymap_fn_to_action(uint8_t keycode); |
| 39 | 32 | ||
| 40 | 33 | ||
| 41 | /* action for key */ | ||
| 42 | // TODO: should use struct key_t? move to action.h? | ||
| 43 | action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col); | ||
| 44 | |||
| 45 | /* user defined special function */ | ||
| 46 | void keymap_call_function(keyrecord_t *record, uint8_t id, uint8_t opt); | ||
| 47 | |||
| 48 | |||
| 49 | 34 | ||
| 50 | #ifndef NO_LEGACY_KEYMAP_SUPPORT | 35 | #ifndef NO_LEGACY_KEYMAP_SUPPORT |
| 51 | /* keycode of key */ | 36 | /* keycode of key */ |
| 52 | uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col); | 37 | uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col); |
| 53 | |||
| 54 | /* layer to move during press Fn key */ | 38 | /* layer to move during press Fn key */ |
| 55 | uint8_t keymap_fn_layer(uint8_t fn_bits); | 39 | uint8_t keymap_fn_layer(uint8_t fn_bits); |
| 56 | |||
| 57 | /* keycode to send when release Fn key without using */ | 40 | /* keycode to send when release Fn key without using */ |
| 58 | uint8_t keymap_fn_keycode(uint8_t fn_bits); | 41 | uint8_t keymap_fn_keycode(uint8_t fn_bits); |
| 59 | #endif | 42 | #endif |
diff --git a/keyboard/gh60/keymap.c b/keyboard/gh60/keymap.c index d2da50529..a17c11fc3 100644 --- a/keyboard/gh60/keymap.c +++ b/keyboard/gh60/keymap.c | |||
| @@ -165,7 +165,7 @@ static const uint16_t PROGMEM fn_actions[] = { | |||
| 165 | /* translates key to keycode */ | 165 | /* translates key to keycode */ |
| 166 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) | 166 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) |
| 167 | { | 167 | { |
| 168 | return pgm_read_byte(&keymaps[(layer)][(key.pos.row)][(key.pos.col)]); | 168 | return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | /* translates Fn index to action */ | 171 | /* translates Fn index to action */ |
| @@ -181,11 +181,8 @@ action_t keymap_fn_to_action(uint8_t keycode) | |||
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | /* convert key to action */ | 183 | /* convert key to action */ |
| 184 | action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col) | 184 | action_t action_for_key(uint8_t layer, key_t key) |
| 185 | { | 185 | { |
| 186 | key_t key; | ||
| 187 | key.pos.row = row; | ||
| 188 | key.pos.col = col; | ||
| 189 | uint8_t keycode = keymap_key_to_keycode(layer, key); | 186 | uint8_t keycode = keymap_key_to_keycode(layer, key); |
| 190 | switch (keycode) { | 187 | switch (keycode) { |
| 191 | case KC_FN0 ... KC_FN31: | 188 | case KC_FN0 ... KC_FN31: |
diff --git a/keyboard/hhkb/keymap.c b/keyboard/hhkb/keymap.c index a5b6d3ace..ef21282ff 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) | |||
| 314 | /* translates key to keycode */ | 314 | /* translates key to keycode */ |
| 315 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) | 315 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) |
| 316 | { | 316 | { |
| 317 | return pgm_read_byte(&keymaps[(layer)][(key.pos.row)][(key.pos.col)]); | 317 | return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | /* translates Fn index to action */ | 320 | /* translates Fn index to action */ |
| @@ -330,11 +330,8 @@ action_t keymap_fn_to_action(uint8_t keycode) | |||
| 330 | } | 330 | } |
| 331 | 331 | ||
| 332 | /* convert key to action */ | 332 | /* convert key to action */ |
| 333 | action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col) | 333 | action_t action_for_key(uint8_t layer, key_t key) |
| 334 | { | 334 | { |
| 335 | key_t key; | ||
| 336 | key.pos.row = row; | ||
| 337 | key.pos.col = col; | ||
| 338 | uint8_t keycode = keymap_key_to_keycode(layer, key); | 335 | uint8_t keycode = keymap_key_to_keycode(layer, key); |
| 339 | switch (keycode) { | 336 | switch (keycode) { |
| 340 | case KC_FN0 ... KC_FN31: | 337 | case KC_FN0 ... KC_FN31: |
