summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDrashna Jael're <drashna@live.com>2017-12-19 10:37:25 -0800
committerJack Humbert <jack.humb@gmail.com>2017-12-20 14:38:56 -0500
commit4f484bc1c990793f019deb54448ad534389cc938 (patch)
tree0509a2a43953c73803dfc4e9666df7703d119954
parenta1fa70f94ddddcd6b51914a89cee7218ae1281ce (diff)
Add on/off/toggle keycodes for Auto Shift
-rw-r--r--docs/feature_auto_shift.md3
-rw-r--r--keyboards/ergodox_ez/keymaps/drashna/keymap.c2
-rw-r--r--quantum/process_keycode/process_auto_shift.c43
-rw-r--r--quantum/process_keycode/process_auto_shift.h5
-rw-r--r--quantum/quantum_keycodes.h4
5 files changed, 44 insertions, 13 deletions
diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md
index 2730459764..f6c248744e 100644
--- a/docs/feature_auto_shift.md
+++ b/docs/feature_auto_shift.md
@@ -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.
diff --git a/keyboards/ergodox_ez/keymaps/drashna/keymap.c b/keyboards/ergodox_ez/keymaps/drashna/keymap.c
index 81231242de..8743ae2827 100644
--- a/keyboards/ergodox_ez/keymaps/drashna/keymap.c
+++ b/keyboards/ergodox_ez/keymaps/drashna/keymap.c
@@ -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
),
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c
index e2e6b02e0a..fcce91849c 100644
--- a/quantum/process_keycode/process_auto_shift.c
+++ b/quantum/process_keycode/process_auto_shift.c
@@ -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)|
diff --git a/quantum/process_keycode/process_auto_shift.h b/quantum/process_keycode/process_auto_shift.h
index a0361346bd..a4abf04145 100644
--- a/quantum/process_keycode/process_auto_shift.h
+++ b/quantum/process_keycode/process_auto_shift.h
@@ -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
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index b0e555f2ee..65bf9e1410 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -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,