diff options
| -rw-r--r-- | common/action.c | 5 | ||||
| -rw-r--r-- | common/action.h | 52 | ||||
| -rw-r--r-- | common/action_macro.h | 4 | ||||
| -rw-r--r-- | common/keymap.c | 8 |
4 files changed, 39 insertions, 30 deletions
diff --git a/common/action.c b/common/action.c index 294ce00fb..fc8818030 100644 --- a/common/action.c +++ b/common/action.c | |||
| @@ -23,8 +23,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 23 | #include "command.h" | 23 | #include "command.h" |
| 24 | #include "util.h" | 24 | #include "util.h" |
| 25 | #include "debug.h" | 25 | #include "debug.h" |
| 26 | #include "action.h" | ||
| 27 | #include "layer_switch.h" | 26 | #include "layer_switch.h" |
| 27 | #include "action_macro.h" | ||
| 28 | #include "action.h" | ||
| 28 | 29 | ||
| 29 | 30 | ||
| 30 | static void process_action(keyrecord_t *record); | 31 | static void process_action(keyrecord_t *record); |
| @@ -671,7 +672,7 @@ static void process_action(keyrecord_t *record) | |||
| 671 | 672 | ||
| 672 | /* Extentions */ | 673 | /* Extentions */ |
| 673 | case ACT_MACRO: | 674 | case ACT_MACRO: |
| 674 | // TODO | 675 | action_macro_play(action_get_macro(record, action.func.id, action.func.opt)); |
| 675 | break; | 676 | break; |
| 676 | case ACT_COMMAND: | 677 | case ACT_COMMAND: |
| 677 | break; | 678 | break; |
diff --git a/common/action.h b/common/action.h index 4892cc7fd..9dea4b0aa 100644 --- a/common/action.h +++ b/common/action.h | |||
| @@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 19 | 19 | ||
| 20 | #include "keyboard.h" | 20 | #include "keyboard.h" |
| 21 | #include "keycode.h" | 21 | #include "keycode.h" |
| 22 | #include "action_macro.h" | ||
| 22 | 23 | ||
| 23 | 24 | ||
| 24 | /* Struct to record event and tap count */ | 25 | /* Struct to record event and tap count */ |
| @@ -82,6 +83,9 @@ void action_exec(keyevent_t event); | |||
| 82 | /* action for key */ | 83 | /* action for key */ |
| 83 | action_t action_for_key(uint8_t layer, key_t key); | 84 | action_t action_for_key(uint8_t layer, key_t key); |
| 84 | 85 | ||
| 86 | /* macro */ | ||
| 87 | const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt); | ||
| 88 | |||
| 85 | /* user defined special function */ | 89 | /* user defined special function */ |
| 86 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); | 90 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); |
| 87 | 91 | ||
| @@ -107,8 +111,8 @@ bool waiting_buffer_has_anykey_pressed(void); | |||
| 107 | * ============ | 111 | * ============ |
| 108 | * 16bit code: action_kind(4bit) + action_parameter(12bit) | 112 | * 16bit code: action_kind(4bit) + action_parameter(12bit) |
| 109 | * | 113 | * |
| 110 | * Keyboard Keys | 114 | * Keyboard Keys(00XX) |
| 111 | * ------------- | 115 | * ------------------- |
| 112 | * ACT_LMODS(0000): | 116 | * ACT_LMODS(0000): |
| 113 | * 0000|0000|000000|00 No action | 117 | * 0000|0000|000000|00 No action |
| 114 | * 0000|0000|000000|01 Transparent | 118 | * 0000|0000|000000|01 Transparent |
| @@ -138,8 +142,8 @@ bool waiting_buffer_has_anykey_pressed(void); | |||
| 138 | * 0011|mods| keycode Right mods + tap Key | 142 | * 0011|mods| keycode Right mods + tap Key |
| 139 | * | 143 | * |
| 140 | * | 144 | * |
| 141 | * Other HID Usage | 145 | * Other keys(01XX) |
| 142 | * --------------- | 146 | * -------------------- |
| 143 | * This action handles other usages than keyboard. | 147 | * This action handles other usages than keyboard. |
| 144 | * ACT_USAGE(0100): | 148 | * ACT_USAGE(0100): |
| 145 | * 0100|00| usage(10) System control(0x80) - General Desktop page(0x01) | 149 | * 0100|00| usage(10) System control(0x80) - General Desktop page(0x01) |
| @@ -147,15 +151,12 @@ bool waiting_buffer_has_anykey_pressed(void); | |||
| 147 | * 0100|10| usage(10) (reserved) | 151 | * 0100|10| usage(10) (reserved) |
| 148 | * 0100|11| usage(10) (reserved) | 152 | * 0100|11| usage(10) (reserved) |
| 149 | * | 153 | * |
| 150 | * | ||
| 151 | * Mouse Keys | ||
| 152 | * ---------- | ||
| 153 | * ACT_MOUSEKEY(0110): | 154 | * ACT_MOUSEKEY(0110): |
| 154 | * 0101|XXXX| keycode Mouse key | 155 | * 0101|XXXX| keycode Mouse key |
| 155 | * | 156 | * |
| 156 | * | 157 | * |
| 157 | * Layer Actions | 158 | * Layer Actions(10XX) |
| 158 | * ------------- | 159 | * ------------------- |
| 159 | * ACT_KEYMAP: | 160 | * ACT_KEYMAP: |
| 160 | * 1000|--xx|0000 0000 Clear keyamp and overlay | 161 | * 1000|--xx|0000 0000 Clear keyamp and overlay |
| 161 | * 1000|LLLL|0000 00xx Reset default layer and clear keymap and overlay | 162 | * 1000|LLLL|0000 00xx Reset default layer and clear keymap and overlay |
| @@ -189,8 +190,6 @@ bool waiting_buffer_has_anykey_pressed(void); | |||
| 189 | * | 190 | * |
| 190 | * Extensions(11XX) | 191 | * Extensions(11XX) |
| 191 | * ---------------- | 192 | * ---------------- |
| 192 | * NOTE: NOT FIXED | ||
| 193 | * | ||
| 194 | * ACT_MACRO(1100): | 193 | * ACT_MACRO(1100): |
| 195 | * 1100|opt | id(8) Macro play? | 194 | * 1100|opt | id(8) Macro play? |
| 196 | * 1100|1111| id(8) Macro record? | 195 | * 1100|1111| id(8) Macro record? |
| @@ -253,8 +252,20 @@ enum mods_codes { | |||
| 253 | #define ACTION_RMOD_TAP_KEY(mod, key) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key)) | 252 | #define ACTION_RMOD_TAP_KEY(mod, key) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key)) |
| 254 | #define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) | 253 | #define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) |
| 255 | 254 | ||
| 255 | /* HID Usage */ | ||
| 256 | enum usage_pages { | ||
| 257 | PAGE_SYSTEM, | ||
| 258 | PAGE_CONSUMER | ||
| 259 | }; | ||
| 260 | #define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id)) | ||
| 261 | #define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id)) | ||
| 262 | |||
| 263 | /* Mousekey */ | ||
| 264 | #define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key) | ||
| 265 | |||
| 266 | |||
| 256 | 267 | ||
| 257 | /* Layer Operation: | 268 | /* Layer Actions: |
| 258 | * Invert layer ^= (1<<layer) | 269 | * Invert layer ^= (1<<layer) |
| 259 | * On layer |= (1<<layer) | 270 | * On layer |= (1<<layer) |
| 260 | * Off layer &= ~(1<<layer) | 271 | * Off layer &= ~(1<<layer) |
| @@ -362,23 +373,14 @@ enum layer_params { | |||
| 362 | 373 | ||
| 363 | 374 | ||
| 364 | /* | 375 | /* |
| 365 | * HID Usage | 376 | * Extensions |
| 366 | */ | 377 | */ |
| 367 | enum usage_pages { | ||
| 368 | PAGE_SYSTEM, | ||
| 369 | PAGE_CONSUMER | ||
| 370 | }; | ||
| 371 | #define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id)) | ||
| 372 | #define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id)) | ||
| 373 | |||
| 374 | /* Mousekey */ | ||
| 375 | #define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key) | ||
| 376 | |||
| 377 | /* Macro */ | 378 | /* Macro */ |
| 378 | #define ACTION_MACRO(opt, id) ACTION(ACT_FUNCTION, (opt)<<8 | (addr)) | 379 | #define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) |
| 380 | #define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id)) | ||
| 379 | 381 | ||
| 380 | /* Command */ | 382 | /* Command */ |
| 381 | #define ACTION_COMMAND(opt, id) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) | 383 | #define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) |
| 382 | 384 | ||
| 383 | /* Function */ | 385 | /* Function */ |
| 384 | enum function_opts { | 386 | enum function_opts { |
diff --git a/common/action_macro.h b/common/action_macro.h index 3833c7c8a..db6577959 100644 --- a/common/action_macro.h +++ b/common/action_macro.h | |||
| @@ -20,6 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | #include <avr/pgmspace.h> | 20 | #include <avr/pgmspace.h> |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | #define MACRO_NONE 0 | ||
| 24 | #define MACRO(...) ({ static prog_macro_t _m[] PROGMEM = { __VA_ARGS__ }; _m; }) | ||
| 25 | |||
| 26 | |||
| 23 | typedef uint8_t macro_t; | 27 | typedef uint8_t macro_t; |
| 24 | typedef macro_t prog_macro_t PROGMEM; | 28 | typedef macro_t prog_macro_t PROGMEM; |
| 25 | 29 | ||
diff --git a/common/keymap.c b/common/keymap.c index ddc321052..f72be5779 100644 --- a/common/keymap.c +++ b/common/keymap.c | |||
| @@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | #include "keycode.h" | 20 | #include "keycode.h" |
| 21 | #include "layer_switch.h" | 21 | #include "layer_switch.h" |
| 22 | #include "action.h" | 22 | #include "action.h" |
| 23 | #include "action_macro.h" | ||
| 23 | #include "debug.h" | 24 | #include "debug.h" |
| 24 | 25 | ||
| 25 | 26 | ||
| @@ -39,9 +40,10 @@ action_t action_for_key(uint8_t layer, key_t key) | |||
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | __attribute__ ((weak)) | 42 | __attribute__ ((weak)) |
| 42 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) | 43 | const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { return MACRO_NONE; } |
| 43 | { | 44 | |
| 44 | } | 45 | __attribute__ ((weak)) |
| 46 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {} | ||
| 45 | #else | 47 | #else |
| 46 | /* | 48 | /* |
| 47 | * legacy keymap support | 49 | * legacy keymap support |
