Space Cadet: Reducing unnecessary reported keypresses (#5781)
* Reducing unnecessary reported keypresses and minor docs / variable name changes * Apply suggestions from code review Co-Authored-By: XScorpion2 <rcalt2vt@gmail.com>
This commit is contained in:
committed by
Drashna Jaelre
parent
59d28fe288
commit
25aa7bcbdb
@@ -13,3 +13,4 @@
|
|||||||
04-22-2019 - Add Split RGB support
|
04-22-2019 - Add Split RGB support
|
||||||
04-24-2019 - fix LIB_SRC and QUANTUM_LIB_SRC for ARM
|
04-24-2019 - fix LIB_SRC and QUANTUM_LIB_SRC for ARM
|
||||||
04-24-2019 - Add RGB Split fixes and RGB Names
|
04-24-2019 - Add RGB Split fixes and RGB Names
|
||||||
|
05-05-2019 - Fix issue with Space Cadet
|
||||||
|
|||||||
@@ -62,16 +62,16 @@
|
|||||||
#ifndef LCPO_KEYS
|
#ifndef LCPO_KEYS
|
||||||
#define LCPO_KEYS KC_LCTL, KC_LCTL, KC_9
|
#define LCPO_KEYS KC_LCTL, KC_LCTL, KC_9
|
||||||
#endif
|
#endif
|
||||||
#ifndef RCPO_KEYS
|
#ifndef RCPC_KEYS
|
||||||
#define RCPO_KEYS KC_RCTL, KC_RCTL, KC_0
|
#define RCPC_KEYS KC_RCTL, KC_RCTL, KC_0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Alt / paren setup
|
// Alt / paren setup
|
||||||
#ifndef LAPO_KEYS
|
#ifndef LAPO_KEYS
|
||||||
#define LAPO_KEYS KC_LALT, KC_LALT, KC_9
|
#define LAPO_KEYS KC_LALT, KC_LALT, KC_9
|
||||||
#endif
|
#endif
|
||||||
#ifndef RAPO_KEYS
|
#ifndef RAPC_KEYS
|
||||||
#define RAPO_KEYS KC_RALT, KC_RALT, KC_0
|
#define RAPC_KEYS KC_RALT, KC_RALT, KC_0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Shift / Enter setup
|
// Shift / Enter setup
|
||||||
@@ -82,27 +82,32 @@
|
|||||||
static uint8_t sc_last = 0;
|
static uint8_t sc_last = 0;
|
||||||
static uint16_t sc_timer = 0;
|
static uint16_t sc_timer = 0;
|
||||||
|
|
||||||
void perform_space_cadet(keyrecord_t *record, uint8_t normalMod, uint8_t tapMod, uint8_t keycode) {
|
void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) {
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed) {
|
||||||
sc_last = normalMod;
|
sc_last = holdMod;
|
||||||
sc_timer = timer_read ();
|
sc_timer = timer_read ();
|
||||||
if (IS_MOD(normalMod)) {
|
if (IS_MOD(holdMod)) {
|
||||||
register_mods(MOD_BIT(normalMod));
|
register_mods(MOD_BIT(holdMod));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (IS_MOD(normalMod)) {
|
if (sc_last == holdMod && timer_elapsed(sc_timer) < TAPPING_TERM) {
|
||||||
unregister_mods(MOD_BIT(normalMod));
|
if (holdMod != tapMod) {
|
||||||
}
|
if (IS_MOD(holdMod)) {
|
||||||
|
unregister_mods(MOD_BIT(holdMod));
|
||||||
if (sc_last == normalMod && timer_elapsed(sc_timer) < TAPPING_TERM) {
|
}
|
||||||
if (IS_MOD(tapMod)) {
|
if (IS_MOD(tapMod)) {
|
||||||
register_mods(MOD_BIT(tapMod));
|
register_mods(MOD_BIT(tapMod));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tap_code(keycode);
|
tap_code(keycode);
|
||||||
if (IS_MOD(tapMod)) {
|
if (IS_MOD(tapMod)) {
|
||||||
unregister_mods(MOD_BIT(tapMod));
|
unregister_mods(MOD_BIT(tapMod));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (IS_MOD(holdMod)) {
|
||||||
|
unregister_mods(MOD_BIT(holdMod));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +127,7 @@ bool process_space_cadet(uint16_t keycode, keyrecord_t *record) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case KC_RCPC: {
|
case KC_RCPC: {
|
||||||
perform_space_cadet(record, RCPO_KEYS);
|
perform_space_cadet(record, RCPC_KEYS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case KC_LAPO: {
|
case KC_LAPO: {
|
||||||
@@ -130,7 +135,7 @@ bool process_space_cadet(uint16_t keycode, keyrecord_t *record) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case KC_RAPC: {
|
case KC_RAPC: {
|
||||||
perform_space_cadet(record, RAPO_KEYS);
|
perform_space_cadet(record, RAPC_KEYS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case KC_SFTENT: {
|
case KC_SFTENT: {
|
||||||
|
|||||||
@@ -17,5 +17,5 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
|
|
||||||
void perform_space_cadet(keyrecord_t *record, uint8_t normalMod, uint8_t tapMod, uint8_t keycode);
|
void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode);
|
||||||
bool process_space_cadet(uint16_t keycode, keyrecord_t *record);
|
bool process_space_cadet(uint16_t keycode, keyrecord_t *record);
|
||||||
|
|||||||
Reference in New Issue
Block a user