summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--quantum/keymap_extras/keymap_dvorak.h15
-rw-r--r--quantum/keymap_extras/keymap_fr_ch.h2
-rw-r--r--quantum/keymap_extras/keymap_french.h4
-rw-r--r--quantum/keymap_extras/keymap_german.h2
-rw-r--r--quantum/keymap_extras/keymap_german_ch.h2
-rw-r--r--quantum/keymap_extras/keymap_nordic.h2
-rw-r--r--quantum/keymap_extras/keymap_spanish.h2
-rw-r--r--quantum/keymap_extras/keymap_uk.h4
-rw-r--r--quantum/process_keycode/process_tap_dance.c52
-rw-r--r--quantum/process_keycode/process_tap_dance.h19
-rw-r--r--readme.md48
11 files changed, 123 insertions, 29 deletions
diff --git a/quantum/keymap_extras/keymap_dvorak.h b/quantum/keymap_extras/keymap_dvorak.h
index e855056e83..17f2059774 100644
--- a/quantum/keymap_extras/keymap_dvorak.h
+++ b/quantum/keymap_extras/keymap_dvorak.h
@@ -18,18 +18,19 @@
#define DV_LBRC KC_MINS
#define DV_RBRC KC_EQL
-#define DV_QUOT KC_Q
+#define DV_QUOT KC_Q
#define DV_COMM KC_W
#define DV_DOT KC_E
#define DV_P KC_R
#define DV_Y KC_T
#define DV_F KC_Y
#define DV_G KC_U
-#define DV_C KC_I
+#define DV_C KC_I
#define DV_R KC_O
#define DV_L KC_P
#define DV_SLSH KC_LBRC
#define DV_EQL KC_RBRC
+#define DV_BSLS KC_BSLS
#define DV_A KC_A
#define DV_O KC_S
@@ -68,7 +69,13 @@
#define DV_RPRN LSFT(DV_0)
#define DV_LCBR LSFT(DV_LBRC)
#define DV_RCBR LSFT(DV_RBRC)
-#define DV_UNDS LSFT(DV_MINS)
-#define DV_PLUS LSFT(DV_EQL)
+
+#define DV_QUES LSFT(DV_SLSH)
+#define DV_PLUS LSFT(DV_EQL)
+#define DV_PIPE LSFT(DV_BSLS)
+
+#define DV_UNDS LSFT(DV_MINS)
+
+#define DV_COLN LSFT(DV_SCLN)
#endif
diff --git a/quantum/keymap_extras/keymap_fr_ch.h b/quantum/keymap_extras/keymap_fr_ch.h
index 3fd9713575..87d4bb24cf 100644
--- a/quantum/keymap_extras/keymap_fr_ch.h
+++ b/quantum/keymap_extras/keymap_fr_ch.h
@@ -4,7 +4,7 @@
#include "keymap.h"
// Alt gr
-#define ALGR(kc) kc | 0x1400
+#define ALGR(kc) RALT(kc)
#define FR_CH_ALGR KC_RALT
// normal characters
diff --git a/quantum/keymap_extras/keymap_french.h b/quantum/keymap_extras/keymap_french.h
index 2a44c80b14..834c69650e 100644
--- a/quantum/keymap_extras/keymap_french.h
+++ b/quantum/keymap_extras/keymap_french.h
@@ -4,7 +4,7 @@
#include "keymap.h"
// Alt gr
-#define ALGR(kc) kc | 0x1400
+#define ALGR(kc) RALT(kc)
#define NO_ALGR KC_RALT
// Normal characters
@@ -80,4 +80,4 @@
#define FR_EURO ALGR(KC_E)
#define FR_BULT ALGR(FR_DLR)
-#endif \ No newline at end of file
+#endif
diff --git a/quantum/keymap_extras/keymap_german.h b/quantum/keymap_extras/keymap_german.h
index 3f9ae8bade..7e2e0ed44e 100644
--- a/quantum/keymap_extras/keymap_german.h
+++ b/quantum/keymap_extras/keymap_german.h
@@ -4,7 +4,7 @@
#include "keymap.h"
// Alt gr
-#define ALGR(kc) kc | 0x1400
+#define ALGR(kc) RALT(kc)
#define DE_ALGR KC_RALT
// normal characters
diff --git a/quantum/keymap_extras/keymap_german_ch.h b/quantum/keymap_extras/keymap_german_ch.h
index 6a782bcd7b..b66d582a44 100644
--- a/quantum/keymap_extras/keymap_german_ch.h
+++ b/quantum/keymap_extras/keymap_german_ch.h
@@ -4,7 +4,7 @@
#include "keymap.h"
// Alt gr
-#define ALGR(kc) kc | 0x1400
+#define ALGR(kc) RALT(kc)
#define CH_ALGR KC_RALT
// normal characters
diff --git a/quantum/keymap_extras/keymap_nordic.h b/quantum/keymap_extras/keymap_nordic.h
index 3acb8b6983..f8cf4e2e43 100644
--- a/quantum/keymap_extras/keymap_nordic.h
+++ b/quantum/keymap_extras/keymap_nordic.h
@@ -4,7 +4,7 @@
#include "keymap.h"
// Alt gr
-#define ALGR(kc) kc | 0x1400
+#define ALGR(kc) RALT(kc)
#define NO_ALGR KC_RALT
// Normal characters
diff --git a/quantum/keymap_extras/keymap_spanish.h b/quantum/keymap_extras/keymap_spanish.h
index af76e39fcb..4ba568af23 100644
--- a/quantum/keymap_extras/keymap_spanish.h
+++ b/quantum/keymap_extras/keymap_spanish.h
@@ -4,7 +4,7 @@
#include "keymap.h"
// Alt gr
-#define ALGR(kc) kc | 0x1400
+#define ALGR(kc) RALT(kc)
#define NO_ALGR KC_RALT
// Normal characters
diff --git a/quantum/keymap_extras/keymap_uk.h b/quantum/keymap_extras/keymap_uk.h
index 5c5d951791..00c87afc3e 100644
--- a/quantum/keymap_extras/keymap_uk.h
+++ b/quantum/keymap_extras/keymap_uk.h
@@ -4,7 +4,7 @@
#include "keymap.h"
// Alt gr
-#define ALGR(kc) kc | 0x1400
+#define ALGR(kc) RALT(kc)
#define NO_ALGR KC_RALT
// Normal characters
@@ -33,4 +33,4 @@
#define UK_AACT ALGR(KC_A)
-#endif \ No newline at end of file
+#endif
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c
index 9b172e1b6c..b9b836df2e 100644
--- a/quantum/process_keycode/process_tap_dance.c
+++ b/quantum/process_keycode/process_tap_dance.c
@@ -22,10 +22,29 @@ static void _process_tap_dance_action_pair (qk_tap_dance_state_t *state,
static void _process_tap_dance_action_fn (qk_tap_dance_state_t *state,
qk_tap_dance_user_fn_t fn)
{
- fn(state);
+ if (fn) {
+ fn(state);
+ }
+}
+
+void process_tap_dance_action_on_each_tap (uint16_t keycode)
+{
+ uint16_t idx = keycode - QK_TAP_DANCE;
+ qk_tap_dance_action_t action;
+
+ action = tap_dance_actions[idx];
+
+ switch (action.type) {
+ case QK_TAP_DANCE_TYPE_FN:
+ _process_tap_dance_action_fn (&qk_tap_dance_state, action.fn.on_each_tap);
+ break;
+
+ default:
+ break;
+ }
}
-void process_tap_dance_action (uint16_t keycode)
+void process_tap_dance_action_on_dance_finished (uint16_t keycode)
{
uint16_t idx = keycode - QK_TAP_DANCE;
qk_tap_dance_action_t action;
@@ -38,7 +57,7 @@ void process_tap_dance_action (uint16_t keycode)
action.pair.kc1, action.pair.kc2);
break;
case QK_TAP_DANCE_TYPE_FN:
- _process_tap_dance_action_fn (&qk_tap_dance_state, action.fn);
+ _process_tap_dance_action_fn (&qk_tap_dance_state, action.fn.on_dance_finished);
break;
default:
@@ -51,8 +70,9 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
switch(keycode) {
case QK_TAP_DANCE ... QK_TAP_DANCE_MAX:
+ process_tap_dance_action_on_each_tap (qk_tap_dance_state.keycode);
if (qk_tap_dance_state.keycode && qk_tap_dance_state.keycode != keycode) {
- process_tap_dance_action (qk_tap_dance_state.keycode);
+ process_tap_dance_action_on_dance_finished (qk_tap_dance_state.keycode);
} else {
r = false;
}
@@ -66,8 +86,9 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
default:
if (qk_tap_dance_state.keycode) {
- process_tap_dance_action (qk_tap_dance_state.keycode);
-
+ // if we are here, the tap dance was interrupted by a different key
+ process_tap_dance_action_on_each_tap (qk_tap_dance_state.keycode);
+ process_tap_dance_action_on_dance_finished (qk_tap_dance_state.keycode);
reset_tap_dance (&qk_tap_dance_state);
}
break;
@@ -78,13 +99,28 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
void matrix_scan_tap_dance () {
if (qk_tap_dance_state.keycode && timer_elapsed (qk_tap_dance_state.timer) > TAPPING_TERM) {
- process_tap_dance_action (qk_tap_dance_state.keycode);
-
+ // if we are here, the tap dance was timed out
+ process_tap_dance_action_on_dance_finished (qk_tap_dance_state.keycode);
reset_tap_dance (&qk_tap_dance_state);
}
}
void reset_tap_dance (qk_tap_dance_state_t *state) {
+ uint16_t idx = state->keycode - QK_TAP_DANCE;
+ qk_tap_dance_action_t action;
+
+ action = tap_dance_actions[idx];
+ switch (action.type) {
+ case QK_TAP_DANCE_TYPE_FN:
+ if (action.fn.on_reset) {
+ action.fn.on_reset(state);
+ }
+ break;
+
+ default:
+ break;
+ }
+
state->keycode = 0;
state->count = 0;
}
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
index b9d7c7fcf4..7b820584a8 100644
--- a/quantum/process_keycode/process_tap_dance.h
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -31,18 +31,27 @@ typedef struct
uint16_t kc1;
uint16_t kc2;
} pair;
- qk_tap_dance_user_fn_t fn;
+ struct {
+ qk_tap_dance_user_fn_t on_each_tap;
+ qk_tap_dance_user_fn_t on_dance_finished;
+ qk_tap_dance_user_fn_t on_reset;
+ } fn;
};
} qk_tap_dance_action_t;
#define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) { \
- .type = QK_TAP_DANCE_TYPE_PAIR, \
- .pair = { kc1, kc2 } \
+ .type = QK_TAP_DANCE_TYPE_PAIR, \
+ .pair = { kc1, kc2 } \
}
-#define ACTION_TAP_DANCE_FN(user_fn) { \
+#define ACTION_TAP_DANCE_FN(user_fn) { \
.type = QK_TAP_DANCE_TYPE_FN, \
- .fn = user_fn \
+ .fn = { NULL, user_fn, NULL } \
+ }
+
+#define ACTION_TAP_DANCE_FN_ADVANCED(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_reset) { \
+ .type = QK_TAP_DANCE_TYPE_FN, \
+ .fn = { user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_reset } \
}
extern const qk_tap_dance_action_t tap_dance_actions[];
diff --git a/readme.md b/readme.md
index e0dcd56088..b5f7f6945d 100644
--- a/readme.md
+++ b/readme.md
@@ -372,10 +372,11 @@ But lets start with how to use it, first!
First, you will need `TAP_DANCE_ENABLE=yes` in your `Makefile`, because the feature is disabled by default. This adds a little less than 1k to the firmware size. Next, you will want to define some tap-dance keys, which is easiest to do with the `TD()` macro, that - similar to `F()`, takes a number, which will later be used as an index into the `tap_dance_actions` array.
-This array specifies what actions shall be taken when a tap-dance key is in action. Currently, there are two possible options:
+This array specifies what actions shall be taken when a tap-dance key is in action. Currently, there are three possible options:
* `ACTION_TAP_DANCE_DOUBLE(kc1, kc2)`: Sends the `kc1` keycode when tapped once, `kc2` otherwise.
-* `ACTION_TAP_DANCE_FN(fn)`: Calls the specified function - defined in the user keymap - with the current state of the tap-dance action.
+* `ACTION_TAP_DANCE_FN(fn)`: Calls the specified function - defined in the user keymap - with the final tap count of the tap dance action.
+* `ACTION_TAP_DANCE_FN_ADVANCED(on_each_tap_fn, on_dance_finished_fn, on_reset_fn)`: Calls the first specified function - defined in the user keymap - on every tap, the second function on when the dance action finishes (like the previous option), and the last function when the tap dance action resets.
The first option is enough for a lot of cases, that just want dual roles. For example, `ACTION_TAP_DANCE(KC_SPC, KC_ENT)` will result in `Space` being sent on single-tap, `Enter` otherwise.
@@ -399,7 +400,8 @@ In the end, let's see a full example!
enum {
CT_SE = 0,
CT_CLN,
- CT_EGG
+ CT_EGG,
+ CT_FLSH,
};
/* Have the above three on the keymap, TD(CT_SE), etc... */
@@ -424,10 +426,50 @@ void dance_egg (qk_tap_dance_state_t *state) {
}
}
+// on each tap, light up one led, from right to left
+// on the forth tap, turn them off from right to left
+void dance_flsh_each(qk_tap_dance_state_t *state) {
+ switch (state->count) {
+ case 1:
+ ergodox_right_led_3_on();
+ break;
+ case 2:
+ ergodox_right_led_2_on();
+ break;
+ case 3:
+ ergodox_right_led_1_on();
+ break;
+ case 4:
+ ergodox_right_led_3_off();
+ _delay_ms(50);
+ ergodox_right_led_2_off();
+ _delay_ms(50);
+ ergodox_right_led_1_off();
+ }
+}
+
+// on the fourth tap, set the keyboard on flash state
+void dance_flsh_finished(qk_tap_dance_state_t *state) {
+ if (state->count >= 4) {
+ reset_keyboard();
+ reset_tap_dance(state);
+ }
+}
+
+// if the flash state didnt happen, then turn off leds, left to right
+void dance_flsh_reset(qk_tap_dance_state_t *state) {
+ ergodox_right_led_1_off();
+ _delay_ms(50);
+ ergodox_right_led_2_off();
+ _delay_ms(50);
+ ergodox_right_led_3_off();
+}
+
const qk_tap_dance_action_t tap_dance_actions[] = {
[CT_SE] = ACTION_TAP_DANCE_DOUBLE (KC_SPC, KC_ENT)
,[CT_CLN] = ACTION_TAP_DANCE_FN (dance_cln)
,[CT_EGG] = ACTION_TAP_DANCE_FN (dance_egg)
+ ,[CT_FLSH] = ACTION_TAP_DANCE_FN_ADVANCED (dance_flsh_each, dance_flsh_finished, dance_flsh_reset)
};
```