summaryrefslogtreecommitdiff
path: root/quantum/process_keycode
diff options
context:
space:
mode:
authorstein3 <stein3@gmail.com>2020-10-06 07:15:41 -0700
committerstein3 <stein3@gmail.com>2020-10-06 07:15:41 -0700
commit2e402741a89c5eec8cf30c966ce6f36d6ec9249b (patch)
tree3592e8c5e6bd19943ae55db7fc02a5f755afbb51 /quantum/process_keycode
parent3e5e4f74272c610bb9fa737f674f8e65ed6100ca (diff)
parent2013f6313430b977e557e482d30daa279a46e75d (diff)
Merge branch 'master' into meteor
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_auto_shift.c61
-rw-r--r--quantum/process_keycode/process_combo.c8
-rw-r--r--quantum/process_keycode/process_combo.h2
-rw-r--r--quantum/process_keycode/process_joystick.c162
-rw-r--r--quantum/process_keycode/process_joystick.h11
-rw-r--r--quantum/process_keycode/process_midi.c10
-rw-r--r--quantum/process_keycode/process_rgb.c18
-rw-r--r--quantum/process_keycode/process_space_cadet.c23
-rw-r--r--quantum/process_keycode/process_space_cadet.h5
-rw-r--r--quantum/process_keycode/process_tap_dance.c6
10 files changed, 244 insertions, 62 deletions
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c
index b474bda691..b1267922ce 100644
--- a/quantum/process_keycode/process_auto_shift.c
+++ b/quantum/process_keycode/process_auto_shift.c
@@ -25,19 +25,6 @@ static uint16_t autoshift_time = 0;
static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT;
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) {
if (autoshift_lastkey != KC_NO) {
uint16_t elapsed = timer_elapsed(autoshift_time);
@@ -53,10 +40,9 @@ void autoshift_flush(void) {
}
}
-void autoshift_enable(void) { autoshift_enabled = true; }
-void autoshift_disable(void) {
- autoshift_enabled = false;
- autoshift_flush();
+void autoshift_on(uint16_t keycode) {
+ autoshift_time = timer_read();
+ autoshift_lastkey = keycode;
}
void autoshift_toggle(void) {
@@ -68,6 +54,22 @@ void autoshift_toggle(void) {
}
}
+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; }
uint16_t get_autoshift_timeout(void) { return autoshift_timeout; }
@@ -77,21 +79,10 @@ void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; }
bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
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:
autoshift_toggle();
return true;
+
case KC_ASON:
autoshift_enable();
return true;
@@ -99,6 +90,18 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
autoshift_disable();
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
case KC_A ... KC_Z:
# endif
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index c4e299958a..f38d7d47a0 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -24,10 +24,10 @@ extern combo_t key_combos[];
extern int COMBO_LEN;
#endif
-__attribute__((weak)) void process_combo_event(uint8_t combo_index, bool pressed) {}
+__attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {}
static uint16_t timer = 0;
-static uint8_t current_combo_index = 0;
+static uint16_t current_combo_index = 0;
static bool drop_buffer = false;
static bool is_active = false;
static bool b_combo_enable = true; // defaults to enabled
@@ -82,8 +82,8 @@ static inline void dump_key_buffer(bool emit) {
} while (0)
static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record) {
- uint8_t count = 0;
- uint8_t index = -1;
+ uint8_t count = 0;
+ uint16_t index = -1;
/* Find index of keycode and number of combo keys */
for (const uint16_t *keys = combo->keys;; ++count) {
uint16_t key = pgm_read_word(&keys[count]);
diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h
index e21ee19609..0f01aae93e 100644
--- a/quantum/process_keycode/process_combo.h
+++ b/quantum/process_keycode/process_combo.h
@@ -56,7 +56,7 @@ typedef struct {
bool process_combo(uint16_t keycode, keyrecord_t *record);
void matrix_scan_combo(void);
-void process_combo_event(uint8_t combo_index, bool pressed);
+void process_combo_event(uint16_t combo_index, bool pressed);
void combo_enable(void);
void combo_disable(void);
diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c
new file mode 100644
index 0000000000..5778a7434c
--- /dev/null
+++ b/quantum/process_keycode/process_joystick.c
@@ -0,0 +1,162 @@
+#include "joystick.h"
+#include "process_joystick.h"
+
+#include "analog.h"
+
+#include <string.h>
+#include <math.h>
+
+bool process_joystick_buttons(uint16_t keycode, keyrecord_t *record);
+
+bool process_joystick(uint16_t keycode, keyrecord_t *record) {
+ if (process_joystick_buttons(keycode, record) && (joystick_status.status & JS_UPDATED) > 0) {
+ send_joystick_packet(&joystick_status);
+ joystick_status.status &= ~JS_UPDATED;
+ }
+
+ return true;
+}
+
+__attribute__((weak)) void joystick_task(void) {
+ if (process_joystick_analogread() && (joystick_status.status & JS_UPDATED)) {
+ send_joystick_packet(&joystick_status);
+ joystick_status.status &= ~JS_UPDATED;
+ }
+}
+
+bool process_joystick_buttons(uint16_t keycode, keyrecord_t *record) {
+ if (keycode < JS_BUTTON0 || keycode > JS_BUTTON_MAX) {
+ return true;
+ } else {
+ if (record->event.pressed) {
+ joystick_status.buttons[(keycode - JS_BUTTON0) / 8] |= 1 << (keycode % 8);
+ } else {
+ joystick_status.buttons[(keycode - JS_BUTTON0) / 8] &= ~(1 << (keycode % 8));
+ }
+
+ joystick_status.status |= JS_UPDATED;
+ }
+
+ return true;
+}
+
+uint16_t savePinState(pin_t pin) {
+#ifdef __AVR__
+ uint8_t pinNumber = pin & 0xF;
+ return ((PORTx_ADDRESS(pin) >> pinNumber) & 0x1) << 1 | ((DDRx_ADDRESS(pin) >> pinNumber) & 0x1);
+#elif defined(PROTOCOL_CHIBIOS)
+ /*
+ The pin configuration is backed up in the following format :
+ bit 15 9 8 7 6 5 4 3 2 1 0
+ |unused|ODR|IDR|PUPDR|OSPEEDR|OTYPER|MODER|
+ */
+ return ((PAL_PORT(pin)->MODER >> (2 * PAL_PAD(pin))) & 0x3) | (((PAL_PORT(pin)->OTYPER >> (1 * PAL_PAD(pin))) & 0x1) << 2) | (((PAL_PORT(pin)->OSPEEDR >> (2 * PAL_PAD(pin))) & 0x3) << 3) | (((PAL_PORT(pin)->PUPDR >> (2 * PAL_PAD(pin))) & 0x3) << 5) | (((PAL_PORT(pin)->IDR >> (1 * PAL_PAD(pin))) & 0x1) << 7) | (((PAL_PORT(pin)->ODR >> (1 * PAL_PAD(pin))) & 0x1) << 8);
+#else
+ return 0;
+#endif
+}
+
+void restorePinState(pin_t pin, uint16_t restoreState) {
+#if defined(PROTOCOL_LUFA)
+ uint8_t pinNumber = pin & 0xF;
+ PORTx_ADDRESS(pin) = (PORTx_ADDRESS(pin) & ~_BV(pinNumber)) | (((restoreState >> 1) & 0x1) << pinNumber);
+ DDRx_ADDRESS(pin) = (DDRx_ADDRESS(pin) & ~_BV(pinNumber)) | ((restoreState & 0x1) << pinNumber);
+#elif defined(PROTOCOL_CHIBIOS)
+ PAL_PORT(pin)->MODER = (PAL_PORT(pin)->MODER & ~(0x3 << (2 * PAL_PAD(pin)))) | (restoreState & 0x3) << (2 * PAL_PAD(pin));
+ PAL_PORT(pin)->OTYPER = (PAL_PORT(pin)->OTYPER & ~(0x1 << (1 * PAL_PAD(pin)))) | ((restoreState >> 2) & 0x1) << (1 * PAL_PAD(pin));
+ PAL_PORT(pin)->OSPEEDR = (PAL_PORT(pin)->OSPEEDR & ~(0x3 << (2 * PAL_PAD(pin)))) | ((restoreState >> 3) & 0x3) << (2 * PAL_PAD(pin));
+ PAL_PORT(pin)->PUPDR = (PAL_PORT(pin)->PUPDR & ~(0x3 << (2 * PAL_PAD(pin)))) | ((restoreState >> 5) & 0x3) << (2 * PAL_PAD(pin));
+ PAL_PORT(pin)->IDR = (PAL_PORT(pin)->IDR & ~(0x1 << (1 * PAL_PAD(pin)))) | ((restoreState >> 7) & 0x1) << (1 * PAL_PAD(pin));
+ PAL_PORT(pin)->ODR = (PAL_PORT(pin)->ODR & ~(0x1 << (1 * PAL_PAD(pin)))) | ((restoreState >> 8) & 0x1) << (1 * PAL_PAD(pin));
+#else
+ return;
+#endif
+}
+
+__attribute__((weak)) bool process_joystick_analogread() { return process_joystick_analogread_quantum(); }
+
+bool process_joystick_analogread_quantum() {
+#if JOYSTICK_AXES_COUNT > 0
+ for (int axis_index = 0; axis_index < JOYSTICK_AXES_COUNT; ++axis_index) {
+ if (joystick_axes[axis_index].input_pin == JS_VIRTUAL_AXIS) {
+ continue;
+ }
+
+ // save previous input pin status as well
+ uint16_t inputSavedState = savePinState(joystick_axes[axis_index].input_pin);
+
+ // disable pull-up resistor
+ writePinLow(joystick_axes[axis_index].input_pin);
+
+ // if pin was a pull-up input, we need to uncharge it by turning it low
+ // before making it a low input
+ setPinOutput(joystick_axes[axis_index].input_pin);
+
+ wait_us(10);
+
+ // save and apply output pin status
+ uint16_t outputSavedState = 0;
+ if (joystick_axes[axis_index].output_pin != JS_VIRTUAL_AXIS) {
+ // save previous output pin status
+ outputSavedState = savePinState(joystick_axes[axis_index].output_pin);
+
+ setPinOutput(joystick_axes[axis_index].output_pin);
+ writePinHigh(joystick_axes[axis_index].output_pin);
+ }
+
+ uint16_t groundSavedState = 0;
+ if (joystick_axes[axis_index].ground_pin != JS_VIRTUAL_AXIS) {
+ // save previous output pin status
+ groundSavedState = savePinState(joystick_axes[axis_index].ground_pin);
+
+ setPinOutput(joystick_axes[axis_index].ground_pin);
+ writePinLow(joystick_axes[axis_index].ground_pin);
+ }
+
+ wait_us(10);
+
+ setPinInput(joystick_axes[axis_index].input_pin);
+
+ wait_us(10);
+
+# if defined(__AVR__) || defined(PROTOCOL_CHIBIOS)
+ int16_t axis_val = analogReadPin(joystick_axes[axis_index].input_pin);
+# else
+ // default to resting position
+ int16_t axis_val = joystick_axes[axis_index].mid_digit;
+# endif
+
+ // test the converted value against the lower range
+ int32_t ref = joystick_axes[axis_index].mid_digit;
+ int32_t range = joystick_axes[axis_index].min_digit;
+ int32_t ranged_val = ((axis_val - ref) * -127) / (range - ref);
+
+ if (ranged_val > 0) {
+ // the value is in the higher range
+ range = joystick_axes[axis_index].max_digit;
+ ranged_val = ((axis_val - ref) * 127) / (range - ref);
+ }
+
+ // clamp the result in the valid range
+ ranged_val = ranged_val < -127 ? -127 : ranged_val;
+ ranged_val = ranged_val > 127 ? 127 : ranged_val;
+
+ if (ranged_val != joystick_status.axes[axis_index]) {
+ joystick_status.axes[axis_index] = ranged_val;
+ joystick_status.status |= JS_UPDATED;
+ }
+
+ // restore output, ground and input status
+ if (joystick_axes[axis_index].output_pin != JS_VIRTUAL_AXIS) {
+ restorePinState(joystick_axes[axis_index].output_pin, outputSavedState);
+ }
+ if (joystick_axes[axis_index].ground_pin != JS_VIRTUAL_AXIS) {
+ restorePinState(joystick_axes[axis_index].ground_pin, groundSavedState);
+ }
+
+ restorePinState(joystick_axes[axis_index].input_pin, inputSavedState);
+ }
+
+#endif
+ return true;
+}
diff --git a/quantum/process_keycode/process_joystick.h b/quantum/process_keycode/process_joystick.h
new file mode 100644
index 0000000000..7a8b82913a
--- /dev/null
+++ b/quantum/process_keycode/process_joystick.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#include <stdint.h>
+#include "quantum.h"
+
+bool process_joystick(uint16_t keycode, keyrecord_t *record);
+
+void joystick_task(void);
+
+bool process_joystick_analogread(void);
+bool process_joystick_analogread_quantum(void);
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c
index b2fb902eb4..e525770144 100644
--- a/quantum/process_keycode/process_midi.c
+++ b/quantum/process_keycode/process_midi.c
@@ -68,10 +68,12 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) {
uint8_t tone = keycode - MIDI_TONE_MIN;
uint8_t velocity = compute_velocity(midi_config.velocity);
if (record->event.pressed) {
- uint8_t note = midi_compute_note(keycode);
- midi_send_noteon(&midi_device, channel, note, velocity);
- dprintf("midi noteon channel:%d note:%d velocity:%d\n", channel, note, velocity);
- tone_status[tone] = note;
+ if (tone_status[tone] == MIDI_INVALID_NOTE) {
+ uint8_t note = midi_compute_note(keycode);
+ midi_send_noteon(&midi_device, channel, note, velocity);
+ dprintf("midi noteon channel:%d note:%d velocity:%d\n", channel, note, velocity);
+ tone_status[tone] = note;
+ }
} else {
uint8_t note = tone_status[tone];
if (note != MIDI_INVALID_NOTE) {
diff --git a/quantum/process_keycode/process_rgb.c b/quantum/process_keycode/process_rgb.c
index a1e46e0348..e0c62465f9 100644
--- a/quantum/process_keycode/process_rgb.c
+++ b/quantum/process_keycode/process_rgb.c
@@ -23,6 +23,7 @@ typedef void (*rgb_func_pointer)(void);
*
* noinline to optimise for firmware size not speed (not in hot path)
*/
+#if !(defined(RGBLIGHT_DISABLE_KEYCODES) || defined(RGB_MATRIX_DISABLE_KEYCODES))
static void __attribute__((noinline)) handleKeycodeRGB(const uint8_t is_shifted, const rgb_func_pointer inc_func, const rgb_func_pointer dec_func) {
if (is_shifted) {
dec_func();
@@ -30,6 +31,7 @@ static void __attribute__((noinline)) handleKeycodeRGB(const uint8_t is_shifted,
inc_func();
}
}
+#endif
/**
* Wrapper for animation mode
@@ -56,7 +58,9 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
// Split keyboards need to trigger on key-up for edge-case issue
if (!record->event.pressed) {
#endif
+#if !(defined(RGBLIGHT_DISABLE_KEYCODES) || defined(RGB_MATRIX_DISABLE_KEYCODES))
uint8_t shifted = get_mods() & MOD_MASK_SHIFT;
+#endif
switch (keycode) {
case RGB_TOG:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
@@ -163,7 +167,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
#endif
return false;
case RGB_MODE_RAINBOW:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RAINBOW_MOOD)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_RAINBOW_MOOD)
handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_MOOD, RGBLIGHT_MODE_RAINBOW_MOOD_end);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && !defined(DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT)
@@ -171,7 +175,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
#endif
return false;
case RGB_MODE_SWIRL:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RAINBOW_SWIRL)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL)
handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_SWIRL, RGBLIGHT_MODE_RAINBOW_SWIRL_end);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && !defined(DISABLE_RGB_MATRIX_CYCLE_PINWHEEL)
@@ -179,27 +183,27 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
#endif
return false;
case RGB_MODE_SNAKE:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_SNAKE)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_SNAKE)
handleKeycodeRGBMode(RGBLIGHT_MODE_SNAKE, RGBLIGHT_MODE_SNAKE_end);
#endif
return false;
case RGB_MODE_KNIGHT:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_KNIGHT)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_KNIGHT)
handleKeycodeRGBMode(RGBLIGHT_MODE_KNIGHT, RGBLIGHT_MODE_KNIGHT_end);
#endif
return false;
case RGB_MODE_XMAS:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_CHRISTMAS)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_CHRISTMAS)
rgblight_mode(RGBLIGHT_MODE_CHRISTMAS);
#endif
return false;
case RGB_MODE_GRADIENT:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_STATIC_GRADIENT)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_STATIC_GRADIENT)
handleKeycodeRGBMode(RGBLIGHT_MODE_STATIC_GRADIENT, RGBLIGHT_MODE_STATIC_GRADIENT_end);
#endif
return false;
case RGB_MODE_RGBTEST:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RGB_TEST)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_RGB_TEST)
rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
#endif
return false;
diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c
index 6833fdb9fb..bcaf62a964 100644
--- a/quantum/process_keycode/process_space_cadet.c
+++ b/quantum/process_keycode/process_space_cadet.c
@@ -14,9 +14,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "process_space_cadet.h"
+#include "action_tapping.h"
-#ifndef TAPPING_TERM
-# define TAPPING_TERM 200
+#ifdef NO_ACTION_TAPPING
+__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { return TAPPING_TERM; };
#endif
// ********** OBSOLETE DEFINES, STOP USING! (pls?) **********
@@ -85,7 +86,7 @@ static uint16_t sc_timer = 0;
static uint8_t sc_mods = 0;
#endif
-void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) {
+void perform_space_cadet(keyrecord_t *record, uint16_t sc_keycode, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) {
if (record->event.pressed) {
sc_last = holdMod;
sc_timer = timer_read();
@@ -96,7 +97,7 @@ void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, u
register_mods(MOD_BIT(holdMod));
}
} else {
- if (sc_last == holdMod && timer_elapsed(sc_timer) < TAPPING_TERM) {
+ if (sc_last == holdMod && timer_elapsed(sc_timer) < get_tapping_term(sc_keycode, record)) {
if (holdMod != tapMod) {
if (IS_MOD(holdMod)) {
unregister_mods(MOD_BIT(holdMod));
@@ -126,31 +127,31 @@ void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, u
bool process_space_cadet(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_LSPO: {
- perform_space_cadet(record, LSPO_KEYS);
+ perform_space_cadet(record, keycode, LSPO_KEYS);
return false;
}
case KC_RSPC: {
- perform_space_cadet(record, RSPC_KEYS);
+ perform_space_cadet(record, keycode, RSPC_KEYS);
return false;
}
case KC_LCPO: {
- perform_space_cadet(record, LCPO_KEYS);
+ perform_space_cadet(record, keycode, LCPO_KEYS);
return false;
}
case KC_RCPC: {
- perform_space_cadet(record, RCPC_KEYS);
+ perform_space_cadet(record, keycode, RCPC_KEYS);
return false;
}
case KC_LAPO: {
- perform_space_cadet(record, LAPO_KEYS);
+ perform_space_cadet(record, keycode, LAPO_KEYS);
return false;
}
case KC_RAPC: {
- perform_space_cadet(record, RAPC_KEYS);
+ perform_space_cadet(record, keycode, RAPC_KEYS);
return false;
}
case KC_SFTENT: {
- perform_space_cadet(record, SFTENT_KEYS);
+ perform_space_cadet(record, keycode, SFTENT_KEYS);
return false;
}
default: {
diff --git a/quantum/process_keycode/process_space_cadet.h b/quantum/process_keycode/process_space_cadet.h
index c823143504..3ace073997 100644
--- a/quantum/process_keycode/process_space_cadet.h
+++ b/quantum/process_keycode/process_space_cadet.h
@@ -17,5 +17,8 @@
#include "quantum.h"
-void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode);
+void perform_space_cadet(keyrecord_t *record, uint16_t sc_keycode, uint8_t holdMod, uint8_t tapMod, uint8_t keycode);
bool process_space_cadet(uint16_t keycode, keyrecord_t *record);
+#ifdef NO_ACTION_TAPPING
+uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record);
+#endif
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c
index 16756e59c2..0c7b6353eb 100644
--- a/quantum/process_keycode/process_tap_dance.c
+++ b/quantum/process_keycode/process_tap_dance.c
@@ -16,10 +16,6 @@
#include "quantum.h"
#include "action_tapping.h"
-#ifndef TAPPING_TERM
-# define TAPPING_TERM 200
-#endif
-
#ifndef NO_ACTION_ONESHOT
uint8_t get_oneshot_mods(void);
#endif
@@ -171,7 +167,7 @@ void matrix_scan_tap_dance() {
if (action->custom_tapping_term > 0) {
tap_user_defined = action->custom_tapping_term;
} else {
- tap_user_defined = TAPPING_TERM;
+ tap_user_defined = get_tapping_term(action->state.keycode, NULL);
}
if (action->state.count && timer_elapsed(action->state.timer) > tap_user_defined) {
process_tap_dance_action_on_dance_finished(action);