]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - quantum/process_keycode/process_auto_shift.c
Add on/off/toggle keycodes for Auto Shift
[qmk_firmware.git] / quantum / process_keycode / process_auto_shift.c
index d096cde567eaf210444a16720b36d8e96bef48c5..fcce91849cb30ad68c2c202613af37c155f0deb1 100644 (file)
@@ -67,6 +67,30 @@ void autoshift_flush(void) {
   }
 }
 
+bool autoshift_enabled = true;
+
+void autoshift_enable(void) {
+    autoshift_enabled = true;
+}
+void autoshift_disable(void) {
+  autoshift_enabled = false;
+  autoshift_flush();
+}
+
+void autoshift_toggle(void) {
+  if (autoshift_enabled) {
+    autoshift_enabled = false;
+    autoshift_flush();
+  }
+  else {
+    autoshift_enabled = true;
+  }
+}
+
+bool autoshift_state(void) {
+  return autoshift_enabled;
+}
+
 bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
   static uint8_t any_mod_pressed;
 
@@ -84,6 +108,16 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
         autoshift_timer_report();
         return false;
 
+      case KC_ASTG:
+        autoshift_toggle();
+        return false;
+      case KC_ASON:
+        autoshift_enable();
+        return false;
+      case KC_ASOFF:
+        autoshift_disable();
+        return false;
+
 #ifndef NO_AUTO_SHIFT_ALPHA
       case KC_A:
       case KC_B:
@@ -137,7 +171,9 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
       case KC_DOT:
       case KC_SLSH:
 #endif
+
         autoshift_flush();
+        if (!autoshift_enabled) return true;
 
         any_mod_pressed = get_mods() & (
           MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)|