[Keymap] add an autoclicker to my plaid keymap (#10743)
This commit is contained in:
parent
27b8046867
commit
db9204c7e1
2 changed files with 31 additions and 2 deletions
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
|
#include "mousekey.h"
|
||||||
|
|
||||||
|
|
||||||
enum plaid_layers {
|
enum plaid_layers {
|
||||||
|
@ -25,9 +26,13 @@ enum plaid_layers {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum plaid_keycodes {
|
enum plaid_keycodes {
|
||||||
QWERTY = SAFE_RANGE
|
AUTOCLICK = SAFE_RANGE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool autoclick = false;
|
||||||
|
static bool autoclick_state = false;
|
||||||
|
static uint16_t autoclick_timer = 0;
|
||||||
|
|
||||||
#define XMONAD LM(_XMONAD, MOD_LGUI)
|
#define XMONAD LM(_XMONAD, MOD_LGUI)
|
||||||
#define SPC_LWR LT(_LOWER, KC_SPACE)
|
#define SPC_LWR LT(_LOWER, KC_SPACE)
|
||||||
#define ENT_RSE LT(_RAISE, KC_ENT)
|
#define ENT_RSE LT(_RAISE, KC_ENT)
|
||||||
|
@ -89,7 +94,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
KC_F12, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
|
KC_F12, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
|
||||||
_______, _______, MU_MOD, AU_ON, AU_OFF, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, RESET,
|
_______, _______, MU_MOD, AU_ON, AU_OFF, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, RESET,
|
||||||
_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, TERM_ON, TERM_OFF,_______, _______, _______,
|
_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, TERM_ON, TERM_OFF,_______, _______, _______,
|
||||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX, _______, AUTOCLICK
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -167,6 +172,16 @@ void matrix_scan_user(void) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (autoclick && timer_elapsed(autoclick_timer) > (autoclick_state ? 20 : 100)) {
|
||||||
|
if (!autoclick_state) {
|
||||||
|
mousekey_on(KC_MS_BTN1);
|
||||||
|
} else {
|
||||||
|
mousekey_off(KC_MS_BTN1);
|
||||||
|
}
|
||||||
|
mousekey_send();
|
||||||
|
autoclick_state = !autoclick_state;
|
||||||
|
autoclick_timer = timer_read();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layer_state_t layer_state_set_user(layer_state_t state) {
|
layer_state_t layer_state_set_user(layer_state_t state) {
|
||||||
|
@ -186,3 +201,15 @@ layer_state_t layer_state_set_user(layer_state_t state) {
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
switch (keycode) {
|
||||||
|
case AUTOCLICK:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
autoclick = !autoclick;
|
||||||
|
autoclick_timer = timer_read();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
|
@ -15,3 +15,5 @@ old machine.
|
||||||
|
|
||||||
When any layer is active, the LEDs are "startled".
|
When any layer is active, the LEDs are "startled".
|
||||||
|
|
||||||
|
There is an autoclicker for minecraft.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue