Cleaned up tapdance code + added screenshot tapdance
parent
7004285fd7
commit
7fe192e4b3
|
@ -15,7 +15,7 @@
|
||||||
KC_LCTRL, KC_Z, KC_X, KC_C, KC_V, KC_B, TO(LAYER_NUMPAD),\
|
KC_LCTRL, KC_Z, KC_X, KC_C, KC_V, KC_B, TO(LAYER_NUMPAD),\
|
||||||
OSL(LAYER_DESKTOP), KC_NO, KC_LALT, KC_LSHIFT, MO(LAYER_ARROWS),\
|
OSL(LAYER_DESKTOP), KC_NO, KC_LALT, KC_LSHIFT, MO(LAYER_ARROWS),\
|
||||||
\
|
\
|
||||||
KC_PSCREEN, LSFT(KC_PSCREEN),\
|
TD(TD_SCREENSHOT), TD(TD_OCR),\
|
||||||
TD(TD_WMLAYOUT),\
|
TD(TD_WMLAYOUT),\
|
||||||
KC_SPACE, KC_BSPACE, LCTL(KC_BSPACE),\
|
KC_SPACE, KC_BSPACE, LCTL(KC_BSPACE),\
|
||||||
\
|
\
|
||||||
|
|
|
@ -5,5 +5,6 @@ TAP_DANCE_ENABLE = yes
|
||||||
|
|
||||||
SRC += \
|
SRC += \
|
||||||
tapdance/wmlayout.c \
|
tapdance/wmlayout.c \
|
||||||
|
tapdance/screenshot.c \
|
||||||
tapdance/tapdance.c \
|
tapdance/tapdance.c \
|
||||||
layers/layers.c
|
layers/layers.c
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
#include "keymap.h"
|
||||||
|
#include "tapdance.h"
|
||||||
|
|
||||||
|
// Called on every tap
|
||||||
|
void td_screenshot_dance(qk_tap_dance_state_t *state, void *user_data) {}
|
||||||
|
|
||||||
|
// Called when action finishes
|
||||||
|
void td_screenshot_finished(qk_tap_dance_state_t *state, void *user_data) {
|
||||||
|
dance_state[1].step = dance_step(state);
|
||||||
|
switch (dance_state[1].step) {
|
||||||
|
case SINGLE_TAP:
|
||||||
|
register_code16(KC_PRINT_SCREEN);
|
||||||
|
break;
|
||||||
|
case DOUBLE_TAP:
|
||||||
|
register_code16(LSFT(KC_PRINT_SCREEN));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when action resets
|
||||||
|
void td_screenshot_reset(qk_tap_dance_state_t *state, void *user_data) {
|
||||||
|
wait_ms(10);
|
||||||
|
switch (dance_state[1].step) {
|
||||||
|
case SINGLE_TAP:
|
||||||
|
unregister_code16(KC_PSCREEN);
|
||||||
|
break;
|
||||||
|
case DOUBLE_TAP:
|
||||||
|
unregister_code16(LSFT(KC_PSCREEN));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dance_state[1].step = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Called on every tap
|
||||||
|
void td_ocr_dance(qk_tap_dance_state_t *state, void *user_data) {}
|
||||||
|
|
||||||
|
// Called when action finishes
|
||||||
|
void td_ocr_finished(qk_tap_dance_state_t *state, void *user_data) {
|
||||||
|
dance_state[1].step = dance_step(state);
|
||||||
|
switch (dance_state[1].step) {
|
||||||
|
case SINGLE_TAP:
|
||||||
|
register_code16(LCTL(KC_PSCREEN));
|
||||||
|
break;
|
||||||
|
case DOUBLE_TAP:
|
||||||
|
register_code16(LCTL(LSFT(KC_PSCREEN)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when action resets
|
||||||
|
void td_ocr_reset(qk_tap_dance_state_t *state, void *user_data) {
|
||||||
|
wait_ms(10);
|
||||||
|
switch (dance_state[1].step) {
|
||||||
|
case SINGLE_TAP:
|
||||||
|
unregister_code16(LCTL(KC_PRINT_SCREEN));
|
||||||
|
break;
|
||||||
|
case DOUBLE_TAP:
|
||||||
|
unregister_code16(LCTL(LSFT(KC_PSCREEN)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dance_state[1].step = 0;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
#include "tapdance.h"
|
#include "tapdance.h"
|
||||||
|
|
||||||
|
tap dance_state[2];
|
||||||
|
|
||||||
uint8_t dance_step(qk_tap_dance_state_t *state) {
|
uint8_t dance_step(qk_tap_dance_state_t *state) {
|
||||||
if (state->count == 1) {
|
if (state->count == 1) {
|
||||||
if (state->interrupted || !state->pressed) {
|
if (state->interrupted || !state->pressed) {
|
||||||
|
@ -22,4 +24,6 @@ uint8_t dance_step(qk_tap_dance_state_t *state) {
|
||||||
|
|
||||||
qk_tap_dance_action_t tap_dance_actions[] = {
|
qk_tap_dance_action_t tap_dance_actions[] = {
|
||||||
[TD_WMLAYOUT] = ACTION_TAP_DANCE_FN_ADVANCED(td_wmlayout_dance, td_wmlayout_finished, td_wmlayout_reset),
|
[TD_WMLAYOUT] = ACTION_TAP_DANCE_FN_ADVANCED(td_wmlayout_dance, td_wmlayout_finished, td_wmlayout_reset),
|
||||||
};
|
[TD_SCREENSHOT] = ACTION_TAP_DANCE_FN_ADVANCED(td_screenshot_dance, td_screenshot_finished, td_screenshot_reset),
|
||||||
|
[TD_OCR] = ACTION_TAP_DANCE_FN_ADVANCED(td_ocr_dance, td_ocr_finished, td_ocr_reset),
|
||||||
|
};
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
enum tap_dance_codes {
|
enum tap_dance_codes {
|
||||||
TD_WMLAYOUT,
|
TD_WMLAYOUT,
|
||||||
|
TD_SCREENSHOT,
|
||||||
|
TD_OCR
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -14,8 +16,22 @@ enum {
|
||||||
MORE_TAPS
|
MORE_TAPS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool is_press_action;
|
||||||
|
uint8_t step;
|
||||||
|
} tap;
|
||||||
|
|
||||||
|
extern tap dance_state[2];
|
||||||
|
|
||||||
uint8_t dance_step(qk_tap_dance_state_t *state);
|
uint8_t dance_step(qk_tap_dance_state_t *state);
|
||||||
|
|
||||||
void td_wmlayout_dance(qk_tap_dance_state_t *state, void *user_data);
|
void td_wmlayout_dance(qk_tap_dance_state_t *state, void *user_data);
|
||||||
void td_wmlayout_finished(qk_tap_dance_state_t *state, void *user_data);
|
void td_wmlayout_finished(qk_tap_dance_state_t *state, void *user_data);
|
||||||
void td_wmlayout_reset(qk_tap_dance_state_t *state, void *user_data);
|
void td_wmlayout_reset(qk_tap_dance_state_t *state, void *user_data);
|
||||||
|
|
||||||
|
void td_screenshot_dance(qk_tap_dance_state_t *state, void *user_data);
|
||||||
|
void td_screenshot_finished(qk_tap_dance_state_t *state, void *user_data);
|
||||||
|
void td_screenshot_reset(qk_tap_dance_state_t *state, void *user_data);
|
||||||
|
void td_ocr_dance(qk_tap_dance_state_t *state, void *user_data);
|
||||||
|
void td_ocr_finished(qk_tap_dance_state_t *state, void *user_data);
|
||||||
|
void td_ocr_reset(qk_tap_dance_state_t *state, void *user_data);
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
#include "tapdance.h"
|
#include "tapdance.h"
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
bool is_press_action;
|
|
||||||
uint8_t step;
|
|
||||||
} tap;
|
|
||||||
|
|
||||||
static tap dance_state[1];
|
|
||||||
|
|
||||||
// Called on every tap
|
// Called on every tap
|
||||||
void td_wmlayout_dance(qk_tap_dance_state_t *state, void *user_data) {
|
void td_wmlayout_dance(qk_tap_dance_state_t *state, void *user_data) {
|
||||||
if(state->count == 3) {
|
if(state->count == 3) {
|
||||||
|
|
Loading…
Reference in New Issue