#define AUTO_SHIFT_SETUP (#8441)
* #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:
parent
167daa9cf8
commit
568cae28ec
@ -139,7 +139,7 @@ completely normal and with no intention of shifted keys.
|
|||||||
`KC_ASRP`. The keyboard will type by itself the value of your
|
`KC_ASRP`. The keyboard will type by itself the value of your
|
||||||
`AUTO_SHIFT_TIMEOUT`.
|
`AUTO_SHIFT_TIMEOUT`.
|
||||||
7. Update `AUTO_SHIFT_TIMEOUT` in your `config.h` with the value reported.
|
7. Update `AUTO_SHIFT_TIMEOUT` in your `config.h` with the value reported.
|
||||||
8. Remove `AUTO_SHIFT_SETUP` from your `config.h`.
|
8. Add `AUTO_SHIFT_NO_SETUP` to your `config.h`.
|
||||||
9. Remove the key bindings `KC_ASDN`, `KC_ASUP` and `KC_ASRP`.
|
9. Remove the key bindings `KC_ASDN`, `KC_ASUP` and `KC_ASRP`.
|
||||||
10. Compile and upload your new firmware.
|
10. Compile and upload your new firmware.
|
||||||
|
|
||||||
|
@ -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);
|
||||||
@ -53,21 +40,36 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void autoshift_enable(void) { autoshift_enabled = true; }
|
||||||
|
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; }
|
bool get_autoshift_state(void) { return autoshift_enabled; }
|
||||||
|
|
||||||
uint16_t get_autoshift_timeout(void) { return autoshift_timeout; }
|
uint16_t get_autoshift_timeout(void) { return autoshift_timeout; }
|
||||||
@ -77,21 +79,11 @@ void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; }
|
|||||||
bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
|
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:
|
|
||||||
autoshift_timeout -= 5;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case KC_ASRP:
|
|
||||||
autoshift_timer_report();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case KC_ASTG:
|
case KC_ASTG:
|
||||||
autoshift_toggle();
|
autoshift_toggle();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case KC_ASON:
|
case KC_ASON:
|
||||||
autoshift_enable();
|
autoshift_enable();
|
||||||
return true;
|
return true;
|
||||||
@ -99,6 +91,18 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
|
|||||||
autoshift_disable();
|
autoshift_disable();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
# ifndef AUTO_SHIFT_NO_SETUP
|
||||||
|
case KC_ASUP:
|
||||||
|
autoshift_timeout += 5;
|
||||||
|
return true;
|
||||||
|
case KC_ASDN:
|
||||||
|
autoshift_timeout -= 5;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case KC_ASRP:
|
||||||
|
autoshift_timer_report();
|
||||||
|
return true;
|
||||||
|
# endif
|
||||||
# ifndef NO_AUTO_SHIFT_ALPHA
|
# ifndef NO_AUTO_SHIFT_ALPHA
|
||||||
case KC_A ... KC_Z:
|
case KC_A ... KC_Z:
|
||||||
# endif
|
# endif
|
||||||
|
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user