-
-// TODO: proper names
-/* action_t utility */
-#define ACTION_NO 0
-#define ACTION(kind, param) ((kind)<<12 | (param))
-#define MOD_BITS(mods) (((mods)>>4 | (mods)) & 0x0F)
-
-/* Key & Mods */
-#define ACTION_KEY(key) ACTION(ACT_LMODS, key)
-#define ACTION_LMODS(mods) ACTION(ACT_LMODS, (mods)<<8 | 0x00)
-#define ACTION_LMODS_KEY(mods, key) ACTION(ACT_LMODS, (mods)<<8 | (key))
-#define ACTION_LMODS_ONESHOT(mods) ACTION(ACT_LMODS, (mods)<<8 | 0x01)
-#define ACTION_LMODS_SWITCH(mods, tap) ACTION(ACT_LMODS, (mods)<<8 | 0xF0 | (tap))
-#define ACTION_LMODS_TOGGLE(mods, tap) ACTION(ACT_LMODS, (mods)<<8 | 0xF1 | (tap))
-#define ACTION_RMODS(mods) ACTION(ACT_RMODS, (mods)<<8 | 0x00)
-#define ACTION_RMODS_KEY(mods, key) ACTION(ACT_RMODS, (mods)<<8 | (key))
-#define ACTION_RMODS_ONESHOT(mods) ACTION(ACT_RMODS, (mods)<<8 | 0x01)
-#define ACTION_RMODS_SWITCH(mods, tap) ACTION(ACT_RMODS, (mods)<<8 | 0xF0 | (tap))
-#define ACTION_RMODS_TOGGLE(mods, tap) ACTION(ACT_RMODS, (mods)<<8 | 0xF1 | (tap))
-/* Mods + Tap key */
-#define ACTION_LMODS_TAP(mods, key) ACTION(ACT_LMODS_TAP, MOD_BITS(mods)<<8 | (key))
-#define ACTION_RMODS_TAP(mods, key) ACTION(ACT_RMODS_TAP, MOD_BITS(mods)<<8 | (key))
-
-/* Layer Switch */
-#define ACTION_LAYER_SET_ON_PRESSED(layer) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | 0x00)
-#define ACTION_LAYER_SET_ON_RELEASED(layer) ACTION(ACT_LAYER_RELEASED, (layer)<<8 | 0x00)
-#define ACTION_LAYER_BIT(bits) ACTION(ACT_LAYER_BIT, (layer)<<8 | 0x00)
-#define ACTION_LAYER_TO_DEFAULT_ON_PRESSED ACTION(ACT_LAYER_EXT, 0x0<<8 | 0x00)
-#define ACTION_LAYER_TO_DEFAULT_ON_RELEASED ACTION(ACT_LAYER_EXT, 0x1<<8 | 0x00)
-
-#define ACTION_LAYER_TAP_TOGGLE(layer) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | 0xF0)
-#define ACTION_LAYER_BIT_TAP_TOGGLE(layer) ACTION(ACT_LAYER_BIT, (layer)<<8 | 0xF0)
-#define ACTION_LAYER_DEFAULT_TAP_TOGGLE ACTION(ACT_LAYER_EXT, 0x0<<8 | 0xF0)
-
-#define ACTION_LAYER_DEFAULT_SET_ON_PRESSED(layer) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | 0xFF)
-#define ACTION_LAYER_DEFAULT_SET_ON_RELEASED(layer) ACTION(ACT_LAYER_RELEASED, (layer)<<8 | 0xFF)
-#define ACTION_LAYER_DEFAULT_BIT(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | 0xFF)
-#define ACTION_LAYER_DEFAULT_SET_CURRENT_ON_PRESSED ACTION(ACT_LAYER_EXT, 0x0<<8 | 0xFF)
-#define ACTION_LAYER_DEFAULT_SET_CURRENT_ON_RELEASED ACTION(ACT_LAYER_EXT, 0x1<<8 | 0xFF)
-
-#define ACTION_LAYER_SET_TAP_KEY(layer, key) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | (key))
-#define ACTION_LAYER_BIT_TAP_KEY(bits, key) ACTION(ACT_LAYER_BIT, (layer)<<8 | (key))
-#define ACTION_LAYER_DEFAULT_SET_TAP_KEY(key) ACTION(ACT_LAYER_EXT, 0x0<<8 | (key))
-
-/* HID Usage */
-#define ACTION_USAGE_PAGE_SYSTEM 0
-#define ACTION_USAGE_PAGE_CONSUMER 1
-#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, ACTION_USAGE_PAGE_SYSTEM<<10 | (id))
-#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, ACTION_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))
-/* Command */
-#define ACTION_COMMAND(opt, id) ACTION(ACT_COMMAND, (opt)<<8 | (addr))
-/* Function */
-#define ACTION_FUNCTION(addr) ACTION(ACT_FUNCTION, addr)
-
-
-/* helpers for readability */
-#define LAYER(layer) (layer)
-#define TAP(tap) (tap)
-#define DOUBLE_TAP 2
-#define TRIPLE_TAP 3
-#define QUADRUPLE_TAP 4
-#define QUINTUPLE_TAP 5
-#define DOWN(key) (key)
-#define UP(key) STROKE_UP, (key)
+/* action for key */
+action_t action_for_key(uint8_t layer, key_t key);
+
+/* macro */
+const 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);
+
+/* Utilities for actions. */
+void process_action(keyrecord_t *record);
+void register_code(uint8_t code);
+void unregister_code(uint8_t code);
+void add_mods(uint8_t mods);
+void del_mods(uint8_t mods);
+void set_mods(uint8_t mods);
+void clear_keyboard(void);
+void clear_keyboard_but_mods(void);
+bool sending_anykey(void);
+void layer_switch(uint8_t new_layer);
+bool is_tap_key(key_t key);
+
+/* debug */
+void debug_event(keyevent_t event);
+void debug_record(keyrecord_t record);
+void debug_action(action_t action);