summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/action.c5
-rw-r--r--common/action.h52
-rw-r--r--common/action_macro.h4
-rw-r--r--common/keymap.c8
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/>.
#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 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/>.
#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<<layer)
* On layer |= (1<<layer)
* Off layer &= ~(1<<layer)
@@ -362,23 +373,14 @@ enum layer_params {
/*
- * HID Usage
+ * Extensions
*/
-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)
-
/* Macro */
-#define ACTION_MACRO(opt, id) ACTION(ACT_FUNCTION, (opt)<<8 | (addr))
+#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id))
+#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id))
/* Command */
-#define ACTION_COMMAND(opt, id) ACTION(ACT_COMMAND, (opt)<<8 | (addr))
+#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr))
/* Function */
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/>.
#include <avr/pgmspace.h>
+#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 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/>.
#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