* #define AUTO_SHIFT_SETUP
* Clarification Changed `#ifndef` to `#ifdef` and moved enable disable outside AUTO_SHIFT_SETUP * AUTO_SHIFT_NO_SETUp
This commit is contained in:
committed by
Drashna Jael're
parent
a768805945
commit
af7272b1b3
@@ -25,19 +25,6 @@ static uint16_t autoshift_time = 0;
|
|||||||
static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT;
|
static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT;
|
||||||
static uint16_t autoshift_lastkey = KC_NO;
|
static uint16_t autoshift_lastkey = KC_NO;
|
||||||
|
|
||||||
void autoshift_timer_report(void) {
|
|
||||||
char display[8];
|
|
||||||
|
|
||||||
snprintf(display, 8, "\n%d\n", autoshift_timeout);
|
|
||||||
|
|
||||||
send_string((const char *)display);
|
|
||||||
}
|
|
||||||
|
|
||||||
void autoshift_on(uint16_t keycode) {
|
|
||||||
autoshift_time = timer_read();
|
|
||||||
autoshift_lastkey = keycode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void autoshift_flush(void) {
|
void autoshift_flush(void) {
|
||||||
if (autoshift_lastkey != KC_NO) {
|
if (autoshift_lastkey != KC_NO) {
|
||||||
uint16_t elapsed = timer_elapsed(autoshift_time);
|
uint16_t elapsed = timer_elapsed(autoshift_time);
|
||||||
@@ -54,26 +41,38 @@ void autoshift_flush(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void autoshift_enable(void) { autoshift_enabled = true; }
|
void autoshift_on(uint16_t keycode) {
|
||||||
void autoshift_disable(void) {
|
autoshift_time = timer_read();
|
||||||
autoshift_enabled = false;
|
autoshift_lastkey = keycode;
|
||||||
autoshift_flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void autoshift_toggle(void) {
|
void autoshift_toggle(void) {
|
||||||
if (autoshift_enabled) {
|
if (autoshift_enabled) {
|
||||||
autoshift_enabled = false;
|
autoshift_enabled = false;
|
||||||
autoshift_flush();
|
autoshift_flush();
|
||||||
}
|
} else {
|
||||||
else {
|
autoshift_enabled = true;
|
||||||
autoshift_enabled = true;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_autoshift_state(void) {
|
void autoshift_enable(void) { autoshift_enabled = true; }
|
||||||
return autoshift_enabled;
|
void autoshift_disable(void) {
|
||||||
|
autoshift_enabled = false;
|
||||||
|
autoshift_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef AUTO_SHIFT_NO_SETUP
|
||||||
|
void autoshift_timer_report(void) {
|
||||||
|
char display[8];
|
||||||
|
|
||||||
|
snprintf(display, 8, "\n%d\n", autoshift_timeout);
|
||||||
|
|
||||||
|
send_string((const char *)display);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool get_autoshift_state(void) { return autoshift_enabled; }
|
||||||
|
|
||||||
uint16_t get_autoshift_timeout(void) {
|
uint16_t get_autoshift_timeout(void) {
|
||||||
return autoshift_timeout;
|
return autoshift_timeout;
|
||||||
}
|
}
|
||||||
@@ -86,60 +85,60 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
|
|||||||
|
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed) {
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case KC_ASUP:
|
|
||||||
autoshift_timeout += 5;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case KC_ASDN:
|
case KC_ASTG:
|
||||||
autoshift_timeout -= 5;
|
autoshift_toggle();
|
||||||
return true;
|
|
||||||
|
|
||||||
case KC_ASRP:
|
|
||||||
autoshift_timer_report();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case KC_ASTG:
|
|
||||||
autoshift_toggle();
|
|
||||||
return true;
|
|
||||||
case KC_ASON:
|
|
||||||
autoshift_enable();
|
|
||||||
return true;
|
|
||||||
case KC_ASOFF:
|
|
||||||
autoshift_disable();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
#ifndef NO_AUTO_SHIFT_ALPHA
|
|
||||||
case KC_A ... KC_Z:
|
|
||||||
#endif
|
|
||||||
#ifndef NO_AUTO_SHIFT_NUMERIC
|
|
||||||
case KC_1 ... KC_0:
|
|
||||||
#endif
|
|
||||||
#ifndef NO_AUTO_SHIFT_SPECIAL
|
|
||||||
case KC_TAB:
|
|
||||||
case KC_MINUS ... KC_SLASH:
|
|
||||||
case KC_NONUS_BSLASH:
|
|
||||||
#endif
|
|
||||||
|
|
||||||
autoshift_flush();
|
|
||||||
if (!autoshift_enabled) return true;
|
|
||||||
|
|
||||||
#ifndef AUTO_SHIFT_MODIFIERS
|
|
||||||
if (get_mods()) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
autoshift_on(keycode);
|
case KC_ASON:
|
||||||
|
autoshift_enable();
|
||||||
|
return true;
|
||||||
|
case KC_ASOFF:
|
||||||
|
autoshift_disable();
|
||||||
|
return true;
|
||||||
|
|
||||||
// We need some extra handling here for OSL edge cases
|
# ifndef AUTO_SHIFT_NO_SETUP
|
||||||
#if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING)
|
case KC_ASUP:
|
||||||
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
|
autoshift_timeout += 5;
|
||||||
#endif
|
return true;
|
||||||
return false;
|
case KC_ASDN:
|
||||||
|
autoshift_timeout -= 5;
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
case KC_ASRP:
|
||||||
autoshift_flush();
|
autoshift_timer_report();
|
||||||
return true;
|
return true;
|
||||||
|
# endif
|
||||||
|
# ifndef NO_AUTO_SHIFT_ALPHA
|
||||||
|
case KC_A ... KC_Z:
|
||||||
|
# endif
|
||||||
|
# ifndef NO_AUTO_SHIFT_NUMERIC
|
||||||
|
case KC_1 ... KC_0:
|
||||||
|
# endif
|
||||||
|
# ifndef NO_AUTO_SHIFT_SPECIAL
|
||||||
|
case KC_TAB:
|
||||||
|
case KC_MINUS ... KC_SLASH:
|
||||||
|
case KC_NONUS_BSLASH:
|
||||||
|
# endif
|
||||||
|
autoshift_flush();
|
||||||
|
if (!autoshift_enabled) return true;
|
||||||
|
|
||||||
|
# ifndef AUTO_SHIFT_MODIFIERS
|
||||||
|
if (get_mods()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
autoshift_on(keycode);
|
||||||
|
|
||||||
|
// We need some extra handling here for OSL edge cases
|
||||||
|
# if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING)
|
||||||
|
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
|
||||||
|
# endif
|
||||||
|
return false;
|
||||||
|
|
||||||
|
default:
|
||||||
|
autoshift_flush();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
autoshift_flush();
|
autoshift_flush();
|
||||||
|
|||||||
@@ -123,10 +123,12 @@ enum quantum_keycodes {
|
|||||||
KC_LEAD,
|
KC_LEAD,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Auto Shift setup
|
// Auto Shift setup
|
||||||
|
#ifndef AUTO_SHIFT_NO_SETUP
|
||||||
KC_ASUP,
|
KC_ASUP,
|
||||||
KC_ASDN,
|
KC_ASDN,
|
||||||
KC_ASRP,
|
KC_ASRP,
|
||||||
|
#endif
|
||||||
KC_ASTG,
|
KC_ASTG,
|
||||||
KC_ASON,
|
KC_ASON,
|
||||||
KC_ASOFF,
|
KC_ASOFF,
|
||||||
|
|||||||
Reference in New Issue
Block a user