]> git.friedersdorff.com Git - max/tmk_keyboard.git/commitdiff
Add keymap clear/reset action
authortmk <nobody@nowhere>
Wed, 20 Feb 2013 06:52:32 +0000 (15:52 +0900)
committertmk <nobody@nowhere>
Wed, 20 Feb 2013 06:52:32 +0000 (15:52 +0900)
common/action.c
common/action.h
common/keymap.c

index 3703b4e8ccf8645262507507e0c0519e35c141a9..844a35b3e14a25852f6391d032fb9f52b954eecc 100644 (file)
@@ -355,26 +355,50 @@ static void process_action(keyrecord_t *record)
 
         case ACT_KEYMAP:
             switch (action.layer.code) {
-                /* Keymap Reset */
+                /* Keymap clear */
                 case OP_RESET:
-                    default_layer_set(action.layer.val);
+                    switch (action.layer.val & 0x03) {
+                        case 0:
+                            overlay_clear();
+                            keymap_clear();
+                            break;
+                        case ON_PRESS:
+                            if (event.pressed) {
+                                overlay_clear();
+                                keymap_clear();
+                            }
+                            break;
+                        case ON_RELEASE:
+                            if (!event.pressed) {
+                                overlay_clear();
+                                keymap_clear();
+                            }
+                            break;
+                        case ON_BOTH:
+                            overlay_clear();
+                            keymap_clear();
+                            break;
+                    }
                     break;
                 /* Keymap Reset default layer */
                 case (OP_RESET | ON_PRESS):
                     if (event.pressed) {
-                        default_layer_set(action.layer.val);
                         overlay_clear();
+                        keymap_clear();
+                        default_layer_set(action.layer.val);
                     }
                     break;
                 case (OP_RESET | ON_RELEASE):
                     if (!event.pressed) {
-                        default_layer_set(action.layer.val);
                         overlay_clear();
+                        keymap_clear();
+                        default_layer_set(action.layer.val);
                     }
                     break;
                 case (OP_RESET | ON_BOTH):
-                    default_layer_set(action.layer.val);
                     overlay_clear();
+                    keymap_clear();
+                    default_layer_set(action.layer.val);
                     break;
 
                 /* Keymap Bit invert */
index c02a2e71fc23ba5b833006233a2aec197b40944a..611490ebf06fd257c8217016ca5b808e2b3dcf98 100644 (file)
@@ -157,8 +157,8 @@ bool waiting_buffer_has_anykey_pressed(void);
  * Layer Actions
  * -------------
  * ACT_KEYMAP:
- * 1000|LLLL|0000 0000   Reset default layer
- * 1000|LLLL|0000 00xx   Reset default layer and clear overlay
+ * 1000|--xx|0000 0000   Clear keyamp and overlay
+ * 1000|LLLL|0000 00xx   Reset default layer and clear keymap and overlay
  * 1000|LLLL| keycode    Invert with tap key
  * 1000|LLLL|1111 0000   Invert with tap toggle
  * 1000|LLLL|1111 00xx   Invert[^= L]
@@ -274,22 +274,25 @@ enum layer_params {
     OP_SET   = 0xFC,
 };
 
-/*
+/* 
  * Default Layer
  */
-#define ACTION_KEYMAP(layer)                     ACTION_KEYMAP_MOMENTARY(layer)
-#define ACTION_KEYMAP_MOMENTARY(layer)           ACTION_KEYMAP_INV_B(layer)
-#define ACTION_KEYMAP_TOGGLE(layer)              ACTION_KEYMAP_INV_R(layer)
-/* Set default layer */
+#define ACTION_DEFAULT_LAYER                      ACTION(ACT_KEYMAP, 0<<8 | OP_RESET | 0)
 #define ACTION_SET_DEFAULT_LAYER(layer)           ACTION_KEYMAP_RESET(layer)
 #define ACTION_SET_DEFAULT_LAYER_P(layer)         ACTION_KEYMAP_RESET_P(layer)
 #define ACTION_SET_DEFAULT_LAYER_R(layer)         ACTION_KEYMAP_RESET_R(layer)
 #define ACTION_SET_DEFAULT_LAYER_B(layer)         ACTION_KEYMAP_RESET_B(layer)
+/*
+ * Keymap Layer
+ */
+#define ACTION_KEYMAP(layer)                     ACTION_KEYMAP_MOMENTARY(layer)
+#define ACTION_KEYMAP_MOMENTARY(layer)           ACTION_KEYMAP_ON_OFF(layer)
+#define ACTION_KEYMAP_TOGGLE(layer)              ACTION_KEYMAP_INV_R(layer)
 /* Keymap Set and clear overaly */
-#define ACTION_KEYMAP_RESET(layer)               ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | 0)
+#define ACTION_KEYMAP_RESET(layer)               ACTION_KEYMAP_RESET_R(layer)
 #define ACTION_KEYMAP_RESET_P(layer)             ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_PRESS)
-#define ACTION_KEYMAP_RESET_R(layer)             ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_PRESS)
-#define ACTION_KEYMAP_RESET_B(layer)             ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_PRESS)
+#define ACTION_KEYMAP_RESET_R(layer)             ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_RELEASE)
+#define ACTION_KEYMAP_RESET_B(layer)             ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_BOTH)
 /* Keymap Invert */
 #define ACTION_KEYMAP_INV(layer)                 ACTION_KEYMAP_INV_B(layer)
 #define ACTION_KEYMAP_TAP_TOGGLE(layer)          ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | 0)
index 3f13d4497adcbbe0d0b086b183d8d76bd9ba088e..ddc321052479756f2b0ec3333966048ced9568e3 100644 (file)
@@ -39,7 +39,7 @@ action_t action_for_key(uint8_t layer, key_t key)
 }
 
 __attribute__ ((weak))
-void action_function(keyrecord_t *event, uint8_t id, uint8_t opt)
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
 {
 }
 #else
@@ -70,7 +70,7 @@ action_t action_for_key(uint8_t layer, key_t key)
     }
 }
 /* not used for legacy keymap */
-void action_function(keyrecord_t *event, uint8_t id, uint8_t opt)
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
 {
 }
 #endif