aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2024-07-13 20:56:52 -0600
committerJack Sangdahl <[email protected]>2024-07-13 20:56:52 -0600
commit748b6749148678add41128cf19320c41db716a31 (patch)
tree8973852be9f596a0c1cfefd231bf7947eeccadc9
parent0eab3e161d9be4d22980a8d06250997045e21e6b (diff)
downloadqmk_me-748b6749148678add41128cf19320c41db716a31.tar.gz
qmk_me-748b6749148678add41128cf19320c41db716a31.zip
add select word & mouse jiggle
-rw-r--r--.gitignore1
-rw-r--r--img/layout.svg4
-rw-r--r--util/keymap.yaml4
-rw-r--r--waffle/rules.mk8
-rw-r--r--waffle/tapping.c86
-rw-r--r--waffle/waffle.h8
6 files changed, 102 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 7f0d883..c057eef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
-*/secrets.h
.cache
*.o
compile_commands.json
diff --git a/img/layout.svg b/img/layout.svg
index edf12fc..bd5de07 100644
--- a/img/layout.svg
+++ b/img/layout.svg
@@ -478,7 +478,7 @@ path.combo {
<g transform="translate(196, 147)" class="key keypos-23">
<rect rx="6" ry="6" x="-26" y="-26" width="52" height="52" class="key"/>
<text x="0" y="0" class="key tap">
-<tspan x="0" dy="-0.6em">Del</tspan><tspan x="0" dy="1.2em">Wrd</tspan>
+<tspan x="0" dy="-0.6em">Sel</tspan><tspan x="0" dy="1.2em">Wrd</tspan>
</text>
</g>
<g transform="translate(252, 154)" class="key keypos-24">
@@ -592,7 +592,7 @@ path.combo {
<g transform="translate(28, 105)" class="key keypos-10">
<rect rx="6" ry="6" x="-26" y="-26" width="52" height="52" class="key"/>
<text x="0" y="0" class="key tap">
-<tspan x="0" dy="-0.6em">Audio</tspan><tspan x="0" dy="1.2em">Togg</tspan>
+<tspan x="0" dy="-0.6em">Mouse</tspan><tspan x="0" dy="1.2em">Jig</tspan>
</text>
</g>
<g transform="translate(84, 91)" class="key keypos-11">
diff --git a/util/keymap.yaml b/util/keymap.yaml
index d22d976..88469ba 100644
--- a/util/keymap.yaml
+++ b/util/keymap.yaml
@@ -29,7 +29,7 @@ layers:
$$mdi:volume-minus$$,
$$mdi:keyboard-tab$$,
$$mdi:apple-keyboard-caps$$,
- "Del Wrd", {t: "`", s: "~"},
+ "Sel Wrd", {t: "`", s: "~"},
$$mdi:arrow-left$$,
$$mdi:arrow-down$$,
$$mdi:arrow-up$$,
@@ -44,7 +44,7 @@ layers:
- {t: ▽, type: trans}
RAISE:
- ["RGB Togg", "Mode +", "Hue +", "Sat +", "Val +", "No Mode", "Fancy", "Block", "Reg Indic", "Make"]
- - ["Audio Togg", "Mode -", "Hue -", "Sat -", "Val -", "Wide", "Upside Down", "Zalgo", "Tiny", "Reset"]
+ - ["Mouse Jig", "Mode -", "Hue -", "Sat -", "Val -", "Wide", "Upside Down", "Zalgo", "Tiny", "Reset"]
- [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10]
- {t: ▽, type: trans}
- {t: ▽, type: trans}
diff --git a/waffle/rules.mk b/waffle/rules.mk
index 6605ba8..eef4b9f 100644
--- a/waffle/rules.mk
+++ b/waffle/rules.mk
@@ -6,11 +6,11 @@ MAGIC_ENABLE = no
CONSOLE_ENABLE = no
UNICODE_COMMON = yes
EXTRAKEY_ENABLE = yes
-MOUSEKEY_ENABLE = yes
BOOTMAGIC_ENABLE = yes
CAPS_WORD_ENABLE = yes
TAP_DANCE_ENABLE = yes
AUTOCORRECT_ENABLE = yes
+MOUSE_JIGGLE_ENABLE = no
DEBOUNCE_TYPE = asym_eager_defer_pk
INTROSPECTION_KEYMAP_C = waffle.c
@@ -42,3 +42,9 @@ endif
ifeq ($(strip $(RANDWORD)), yes)
OPT_DEFS += -DRANDWORD
endif
+
+ifeq ($(strip $(MOUSE_JIGGLE_ENABLE)), yes)
+ OPT_DEFS += -DMOUSE_JIGGLE_ENABLE
+ MOUSEKEY_ENABLE = yes
+ DEFFERED_EXEC_ENABLE = yes
+endif
diff --git a/waffle/tapping.c b/waffle/tapping.c
index 52adccc..205326d 100644
--- a/waffle/tapping.c
+++ b/waffle/tapping.c
@@ -1,6 +1,5 @@
// Copyright 2024 [email protected]
// SPDX-License-Identifier: GPL-2.0-or-later
-#include "secrets.h"
#include "waffle.h"
#ifdef RANDWORD
#include "dict.h"
@@ -15,6 +14,64 @@ uint16_t word = 0;
} \
break;
+static uint8_t select_word_state = NONE;
+
+bool process_select_word(uint16_t keycode, keyrecord_t *record) {
+ if (keycode == KC_LSFT || keycode == KC_RSFT)
+ return true;
+ if (keycode == SELWORD && record->event.pressed) {
+ const bool shifted = get_mods() & MOD_MASK_SHIFT;
+ if (!shifted) {
+ set_mods(MOD_BIT(KC_LCTL));
+ if (select_word_state == NONE) {
+ send_keyboard_report();
+ tap_code(KC_RGHT);
+ tap_code(KC_LEFT);
+ }
+ register_mods(MOD_BIT(KC_LSFT));
+ register_code(KC_RGHT);
+ select_word_state = WORD;
+ } else {
+ if (select_word_state == NONE) {
+ clear_mods();
+ send_keyboard_report();
+ tap_code(KC_HOME);
+ register_mods(MOD_BIT(KC_LSFT));
+ tap_code(KC_END);
+ set_mods(get_mods());
+ select_word_state = FIRST_LINE;
+ } else {
+ register_code(KC_DOWN);
+ select_word_state = LINE;
+ }
+ }
+ return false;
+ }
+ switch (select_word_state) {
+ case WORD:
+ unregister_code(KC_RGHT);
+ unregister_mods(MOD_BIT(KC_LSFT) | MOD_BIT(KC_LCTL));
+ select_word_state = SELECTED;
+ break;
+ case FIRST_LINE:
+ select_word_state = SELECTED;
+ break;
+ case LINE:
+ unregister_code(KC_DOWN);
+ select_word_state = SELECTED;
+ break;
+ case SELECTED:
+ if (keycode == KC_ESC) {
+ tap_code(KC_RGHT);
+ select_word_state = NONE;
+ return false;
+ }
+ default:
+ select_word_state = NONE;
+ }
+ return true;
+}
+
uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case LWRSPC:
@@ -82,12 +139,39 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!process_record_unicode(keycode, record))
return false;
#endif
+ if (!process_select_word(keycode, record))
+ return false;
#ifdef OLED_ENABLE
if (record->event.pressed) {
oled_timer_reset();
add_keylog(keycode);
}
#endif
+#ifdef MOUSE_JIGGLE_ENABLE
+ if (record->event.pressed) {
+ static deferred_token token = INVALID_DEFERRED_TOKEN;
+ static report_mouse_t = {0};
+ if (token) {
+ cancel_deferred_exec(token);
+ token = INVALID_DEFERRED_TOKEN;
+ report = (report_mouse_t){};
+ host_mouse_send(&report);
+ } else if (keycode == M_JIGGLE) {
+ uint32_t jiggle_callback(uint32_t trigger_time, void *cb_arg) {
+ static const int8_t deltas[32] = {
+ 0, -1, -2, -2, -3, -3, -4, -4, -4, -4, -3, -3, -2, -2, -1, 0,
+ 0, 1, 2, 2, 3, 3, 4, 4, 4, 4, 3, 3, 2, 2, 1, 0};
+ static uint8_t phase = 0;
+ report.x = deltas[phase];
+ report.y = deltas[(phase + 8) & 31];
+ phase = (phase + 1) & 31;
+ host_mouse_send(&report);
+ return 16;
+ }
+ token = defer_exec(1, jiggle_callback, NULL);
+ }
+ }
+#endif
switch (keycode) {
case UPDIR:
if (record->event.pressed)
diff --git a/waffle/waffle.h b/waffle/waffle.h
index d746bbe..77ec797 100644
--- a/waffle/waffle.h
+++ b/waffle/waffle.h
@@ -19,9 +19,13 @@ enum layers { _BASE, _LOWER, _RAISE, _ADJUST };
enum tapdances { EM_DASH_MINS, PLY_NXT_PRV, PASTE_RAISE, CBRACKET, SBRACKET };
+enum sw_state { NONE, SELECTED, WORD, FIRST_LINE, LINE };
+
enum custom_keycodes {
UPDIR = QK_USER,
NUKE,
+ SELWORD,
+ M_JIGGLE,
TABLE1,
TABLE2,
KC_NOMODE,
@@ -66,11 +70,11 @@ enum unicode_mode {
#define ___LOWER1___ KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0
#define ___LOWER2___ HRML(KC_EXLM, KC_AT, KC_HASH, KC_DLR), KC_PERC, KC_CIRC, HRMR(KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN)
-#define ___LOWER3___ KC_VOLD, KC_TAB, KC_CAPS, C(KC_BSPC), KC_GRV, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_VOLU
+#define ___LOWER3___ KC_VOLD, KC_TAB, KC_CAPS, SELWORD, KC_GRV, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_VOLU
#define ___LOWER4___ _______, _______, _______, _______, _______, _______
#define ___RAISE1___ RGB_TOG, RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, KC_NOMODE, KC_SCRIPT, KC_BLOCKS, KC_REGIONAL, QK_MAKE
-#define ___RAISE2___ CK_TOGG, RGB_RMOD, RGB_HUD, RGB_SAD, RGB_VAD, KC_WIDE, KC_AUSSIE, KC_ZALGO, KC_SUPER, QK_BOOT
+#define ___RAISE2___ M_JIGGLE, RGB_RMOD, RGB_HUD, RGB_SAD, RGB_VAD, KC_WIDE, KC_AUSSIE, KC_ZALGO, KC_SUPER, QK_BOOT
#define ___RAISE3___ KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10
#define ___RAISE4___ _______, _______, _______, _______, _______, _______
// clang-format on