Add on/off/toggle keycodes for Auto Shift

This commit is contained in:
Drashna Jael're 2017-12-19 10:37:25 -08:00 committed by Jack Humbert
parent a1fa70f94d
commit 4f484bc1c9
5 changed files with 44 additions and 13 deletions

View File

@ -110,6 +110,9 @@ Map three keys temporarily in your keymap:
| KC_ASDN | Lower the Auto Shift timeout variable (down) | | KC_ASDN | Lower the Auto Shift timeout variable (down) |
| KC_ASUP | Raise the Auto Shift timeout variable (up) | | KC_ASUP | Raise the Auto Shift timeout variable (up) |
| KC_ASRP | Report your current Auto Shift timeout value | | 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. Compile and upload your new firmware.

View 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, 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, 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_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_NO,
KC_ASTG, KC_NO, KC_NO, KC_NO,
KC_NO, KC_NO,
KC_PGDOWN, KC_DELETE, KC_ENTER KC_PGDOWN, KC_DELETE, KC_ENTER
), ),

View File

@ -34,8 +34,6 @@ uint16_t autoshift_time = 0;
uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT;
uint16_t autoshift_lastkey = KC_NO; uint16_t autoshift_lastkey = KC_NO;
bool autoshift_enabled = true;
void autoshift_timer_report(void) { void autoshift_timer_report(void) {
char display[8]; 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) { bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
static uint8_t any_mod_pressed; static uint8_t any_mod_pressed;
@ -87,13 +109,14 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
return false; return false;
case KC_ASTG: case KC_ASTG:
if (autoshift_enabled) { autoshift_toggle();
autoshift_enabled = false; return false;
autoshift_flush(); case KC_ASON:
} autoshift_enable();
else { return false;
autoshift_enabled = true; case KC_ASOFF:
} autoshift_disable();
return false;
#ifndef NO_AUTO_SHIFT_ALPHA #ifndef NO_AUTO_SHIFT_ALPHA
case KC_A: case KC_A:
@ -148,9 +171,9 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
case KC_DOT: case KC_DOT:
case KC_SLSH: case KC_SLSH:
#endif #endif
if (!autoshift_enabled) return true;
autoshift_flush(); autoshift_flush();
if (!autoshift_enabled) return true;
any_mod_pressed = get_mods() & ( any_mod_pressed = get_mods() & (
MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)| MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)|

View File

@ -25,4 +25,9 @@
bool process_auto_shift(uint16_t keycode, keyrecord_t *record); 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 #endif

View File

@ -121,13 +121,13 @@ enum quantum_keycodes {
KC_LEAD, KC_LEAD,
#endif #endif
#ifdef AUTO_SHIFT_ENABLE
// Auto Shift setup // Auto Shift setup
KC_ASUP, KC_ASUP,
KC_ASDN, KC_ASDN,
KC_ASRP, KC_ASRP,
KC_ASTG, KC_ASTG,
#endif // AUTO_SHIFT_ENABLE KC_ASON,
KC_ASOFF,
// Audio on/off/toggle // Audio on/off/toggle
AU_ON, AU_ON,