From: tmk Date: Mon, 25 Feb 2013 06:30:37 +0000 (+0900) Subject: Add MACRO action X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=23c32d304bcc5146a575e547bba80ee8d86a2856;p=max%2Ftmk_keyboard.git Add MACRO action --- diff --git a/common/action.c b/common/action.c index 294ce00f..fc881803 100644 --- a/common/action.c +++ b/common/action.c @@ -23,8 +23,9 @@ along with this program. If not, see . #include "command.h" #include "util.h" #include "debug.h" -#include "action.h" #include "layer_switch.h" +#include "action_macro.h" +#include "action.h" static void process_action(keyrecord_t *record); @@ -671,7 +672,7 @@ static void process_action(keyrecord_t *record) /* Extentions */ case ACT_MACRO: - // TODO + action_macro_play(action_get_macro(record, action.func.id, action.func.opt)); break; case ACT_COMMAND: break; diff --git a/common/action.h b/common/action.h index 4892cc7f..9dea4b0a 100644 --- a/common/action.h +++ b/common/action.h @@ -19,6 +19,7 @@ along with this program. If not, see . #include "keyboard.h" #include "keycode.h" +#include "action_macro.h" /* Struct to record event and tap count */ @@ -82,6 +83,9 @@ void action_exec(keyevent_t event); /* action for key */ action_t action_for_key(uint8_t layer, key_t key); +/* macro */ +const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt); + /* user defined special function */ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); @@ -107,8 +111,8 @@ bool waiting_buffer_has_anykey_pressed(void); * ============ * 16bit code: action_kind(4bit) + action_parameter(12bit) * - * Keyboard Keys - * ------------- + * Keyboard Keys(00XX) + * ------------------- * ACT_LMODS(0000): * 0000|0000|000000|00 No action * 0000|0000|000000|01 Transparent @@ -138,8 +142,8 @@ bool waiting_buffer_has_anykey_pressed(void); * 0011|mods| keycode Right mods + tap Key * * - * Other HID Usage - * --------------- + * Other keys(01XX) + * -------------------- * This action handles other usages than keyboard. * ACT_USAGE(0100): * 0100|00| usage(10) System control(0x80) - General Desktop page(0x01) @@ -147,15 +151,12 @@ bool waiting_buffer_has_anykey_pressed(void); * 0100|10| usage(10) (reserved) * 0100|11| usage(10) (reserved) * - * - * Mouse Keys - * ---------- * ACT_MOUSEKEY(0110): * 0101|XXXX| keycode Mouse key * * - * Layer Actions - * ------------- + * Layer Actions(10XX) + * ------------------- * ACT_KEYMAP: * 1000|--xx|0000 0000 Clear keyamp and overlay * 1000|LLLL|0000 00xx Reset default layer and clear keymap and overlay @@ -189,8 +190,6 @@ bool waiting_buffer_has_anykey_pressed(void); * * Extensions(11XX) * ---------------- - * NOTE: NOT FIXED - * * ACT_MACRO(1100): * 1100|opt | id(8) Macro play? * 1100|1111| id(8) Macro record? @@ -253,8 +252,20 @@ enum mods_codes { #define ACTION_RMOD_TAP_KEY(mod, key) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key)) #define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) +/* HID Usage */ +enum usage_pages { + PAGE_SYSTEM, + PAGE_CONSUMER +}; +#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id)) +#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id)) + +/* Mousekey */ +#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key) + + -/* Layer Operation: +/* Layer Actions: * Invert layer ^= (1<. #include +#define MACRO_NONE 0 +#define MACRO(...) ({ static prog_macro_t _m[] PROGMEM = { __VA_ARGS__ }; _m; }) + + typedef uint8_t macro_t; typedef macro_t prog_macro_t PROGMEM; diff --git a/common/keymap.c b/common/keymap.c index ddc32105..f72be577 100644 --- a/common/keymap.c +++ b/common/keymap.c @@ -20,6 +20,7 @@ along with this program. If not, see . #include "keycode.h" #include "layer_switch.h" #include "action.h" +#include "action_macro.h" #include "debug.h" @@ -39,9 +40,10 @@ action_t action_for_key(uint8_t layer, key_t key) } __attribute__ ((weak)) -void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) -{ -} +const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { return MACRO_NONE; } + +__attribute__ ((weak)) +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {} #else /* * legacy keymap support