Skip to content

Commit

Permalink
Add mouse jiggler
Browse files Browse the repository at this point in the history
  • Loading branch information
wfdewith committed Sep 18, 2024
1 parent 2700b52 commit 5f00b47
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
31 changes: 30 additions & 1 deletion keyboards/planck/keymaps/nauxuron/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum planck_keycodes {
QWERTY = SAFE_RANGE,
COLEMAK,
DVORAK,
M_JIGL,
};

#define LOWER MO(_LOWER)
Expand Down Expand Up @@ -84,12 +85,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

[_FN] = LAYOUT_planck_grid(
KC_NUM, KC_MPLY, KC_MSTP, KC_MPRV, KC_MNXT, KC_INS, KC_HOME, KC_PGUP, KC_P7, KC_P8, KC_P9, KC_PSLS,
XXXXXXX, XXXXXXX, KC_MUTE, KC_VOLD, KC_VOLU, KC_DEL, KC_END, KC_PGDN, KC_P4, KC_P5, KC_P6, KC_PAST,
M_JIGL, XXXXXXX, KC_MUTE, KC_VOLD, KC_VOLU, KC_DEL, KC_END, KC_PGDN, KC_P4, KC_P5, KC_P6, KC_PAST,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_P1, KC_P2, KC_P3, KC_PMNS,
XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_P0, KC_PDOT, KC_PENT, KC_PPLS
)
};

static bool is_mouse_jiggle_active = false;
static bool mouse_jiggle_direction = false;
static const uint16_t mouse_jiggle_frequency = 5000;
static uint16_t mouse_jiggle_timer = 0;

layer_state_t layer_state_set_user(layer_state_t state) {
return update_tri_layer_state(state, _LOWER, _RAISE, _CONFIG);
}
Expand All @@ -111,6 +117,29 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
set_single_persistent_default_layer(_DVORAK);
}
return false;
case M_JIGL:
if (record->event.pressed) {
is_mouse_jiggle_active = !is_mouse_jiggle_active;
}
return false;
}
return true;
}

void keyboard_post_init_user(void) {
mouse_jiggle_timer = timer_read();
}

void matrix_scan_user(void) {
if (is_mouse_jiggle_active) {
if (timer_elapsed(mouse_jiggle_timer) > mouse_jiggle_frequency) {
mouse_jiggle_timer = timer_read();
if (mouse_jiggle_direction) {
tap_code(KC_MS_LEFT);
} else {
tap_code(KC_MS_RIGHT);
}
mouse_jiggle_direction = !mouse_jiggle_direction;
}
}
}
1 change: 1 addition & 0 deletions keyboards/planck/keymaps/nauxuron/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ LTO_ENABLE = yes

BOOTMAGIC_ENABLE = no
CONSOLE_ENABLE = no
MOUSEKEY_ENABLE = yes

0 comments on commit 5f00b47

Please sign in to comment.