]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Add on/off/toggle keycodes for Auto Shift
authorDrashna Jael're <drashna@live.com>
Tue, 19 Dec 2017 18:37:25 +0000 (10:37 -0800)
committerJack Humbert <jack.humb@gmail.com>
Wed, 20 Dec 2017 19:38:56 +0000 (14:38 -0500)
docs/feature_auto_shift.md
keyboards/ergodox_ez/keymaps/drashna/keymap.c
quantum/process_keycode/process_auto_shift.c
quantum/process_keycode/process_auto_shift.h
quantum/quantum_keycodes.h

index 27304597646596967d292b81112b1c4591c9e68b..f6c248744e9429b30a8368b8fbcf3145cb071c4d 100644 (file)
@@ -110,6 +110,9 @@ Map three keys temporarily in your keymap:
 | KC_ASDN  | Lower the Auto Shift timeout variable (down)        |
 | KC_ASUP  | Raise the Auto Shift timeout variable (up)          |
 | KC_ASRP  | Report your current Auto Shift timeout value        |
+| KC_ASON  | Turns on the Auto Shift Function                    |
+| KC_ASOFF | Turns off the Auto Shift Function                   |
+| KC_ASTG  | Toggles the statn of the Auto Shift feature         |
 
 Compile and upload your new firmware.
 
index 81231242de0c4e33c076cd03d562feda2ff0676f..8743ae2827b4d0f8b5152377b519747a05a52007 100644 (file)
@@ -294,7 +294,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
                                 KC_I,       KC_O,       KC_NO,      KC_NO,      KC_NO,      KC_NO,
                 TG(_GAMEPAD),   KC_N,       KC_M,       KC_NO,      KC_NO,      KC_NO,      KC_NO,
                                             KC_LEFT,    KC_DOWN,    KC_UP,      KC_RIGHT,      KC_NO,
-                KC_ASTG,          KC_NO,
+                KC_NO,          KC_NO,
                 KC_NO,
                 KC_PGDOWN,      KC_DELETE, KC_ENTER
             ),
index e2e6b02e0ac9f194e0e17b248c667f079227f6f6..fcce91849cb30ad68c2c202613af37c155f0deb1 100644 (file)
@@ -34,8 +34,6 @@ uint16_t autoshift_time = 0;
 uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT;
 uint16_t autoshift_lastkey = KC_NO;
 
-bool autoshift_enabled = true;
-
 void autoshift_timer_report(void) {
   char display[8];
 
@@ -69,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;
 
@@ -87,13 +109,14 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
         return false;
 
       case KC_ASTG:
-        if (autoshift_enabled) {
-          autoshift_enabled = false;
-          autoshift_flush();
-        }
-        else {
-          autoshift_enabled = true;
-        }
+        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:
@@ -148,9 +171,9 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
       case KC_DOT:
       case KC_SLSH:
 #endif
-        if (!autoshift_enabled) return true;
 
         autoshift_flush();
+        if (!autoshift_enabled) return true;
 
         any_mod_pressed = get_mods() & (
           MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)|
index a0361346bd324d920ee085beeec83acf831a1eab..a4abf04145653c82f14562774dcb55b7e9e4dd4b 100644 (file)
@@ -25,4 +25,9 @@
 
 bool process_auto_shift(uint16_t keycode, keyrecord_t *record);
 
+void autoshift_enable(void);
+void autoshift_disable(void);
+void autoshift_toggle(void);
+bool autoshift_state(void);
+
 #endif
index b0e555f2ee6bd835d140a0e838758f5141551905..65bf9e1410a535fd7b9b61875aa6c706e5c367f6 100644 (file)
@@ -121,13 +121,13 @@ enum quantum_keycodes {
     KC_LEAD,
 #endif
 
-#ifdef AUTO_SHIFT_ENABLE
     // Auto Shift setup
     KC_ASUP,
     KC_ASDN,
     KC_ASRP,
     KC_ASTG,
-#endif // AUTO_SHIFT_ENABLE
+    KC_ASON,
+    KC_ASOFF,
 
     // Audio on/off/toggle
     AU_ON,