1
0
Fork 0
qmk_firmware/users/zer09/tap_dance.c

204 lines
5.1 KiB
C
Raw Permalink Normal View History

My userspace and lets_split keymap (#2842) * copied lets_slit to splinter * initial splinter layout * remove unused keymaps * implemented second half of the keyboard * initial definition of tap dance * the tap dance is working now tap dance for right hand 4c 2r hold - shift single tap - n double tap - ñ triple tap - Ñ * clear the keymap.c * put the tap state on to array * the n tilde tap dance should produce right shift if hold * add esc grv tap dance * remove the defined SS_LSFT on tap_dance.h because it was added on the quantum.h * minor cleanup for the keymap * use the X_* on tap dance * added super alt tap dance * use the NO_TAP on tap dance reset * allow track what rows and cols pressed * added the RGUI_ALT * keymap arrangement * use i2c * initial rgb * layer colors * initial rgb pressed key * set the layers led * SUCCESS!!! * cleaning * improve shifted layer * led brightness * initial caps rainbow * rename SET_LED_RGB to SET_LED_RGB_HEX * clean the SET_LED_RGB_HEX and added SET_LED_RGB * clean format * caps lock rainbow * rename key_led to set_key_led * caps lock rainbow enhanced * make varibiables static * change back the loop max value to 360 for the rainbow * add scroll lock to the rainbow led * fix pos calculation of right hand board * add ative keys and make rainbow color can override by key press * remove the TOTAL_MATRIX_POINTS * some improvments for the rgb * call the rgblight_set on the process_record_user * some enhancement for the leds * pass the dim value to set_layer_led and limit the brightness on _VL set the brightness to 2 if the dim value is less than 2 because their is not enought power for the leds. * remove the rgb steps on the config * use the non rev config * remove all the revisions * favor i2c instead of serial and remove all the ref for the serial * clang formatting * allow to save to eeprom the brightness value * add bootloader caterina this will enable soft reset key * initial commit for the userspace * added my own keymap for splinter * first working userspace * move splinter to handwired keyboards * handwired splinter default keymap * move some config to my keymap * cleanup some headers on the keymap * move the EECONFIG_RGB_DIM to the user space * I fix remove the GUI on SPC and ENT * remove the default include on tap_dance.c * add lights.c and refactoring * fix wrong source for led index * seperate the variable on set_layer_led for readabilty. * set the usb max power consumption to 50 * fix led lighting * add new enums for tap dance * use romeve path avr on eeprom.h * fix wrong spelling on TP names * changed the tap dance * allow to set rainbow on some pressed key * add reset key * fix error on matrix.c if ROW2COL is used * add extraflags -flto * See e2352d4 * Got no love from i2c, serial to the rescue * Fix the led will lit up to color red after boot * Trial if the power can handle yellow color at full * Add comment * Use EE_HANDS * add config.h in the use space * KC_N on BL should wrap in SFT_T * See d13567d, put it back but increase 1 level * Fix led soldering mistake * set the tapping_term to 100 * Use TT for the changing the layer * Remove the changing space to enter and vice version on BL and UL * Increate the tapping term * Use tap dance on changing layer * Add assorted layer * propery way to tapdance * Remove DA_EGRV This also fix the wrong placement of the reset and dance lspr should register the KC_LGUI on finished not unregistered. * Remove the media control to the up and down layer * Remove the interrupted state of the tap dance * swapt the space and enter on to th caps * Shorthand * Keymap update * My keymap for lets_split * cleaning
2018-04-29 20:02:37 +00:00
#include "tap_dance.h"
#include "lights.h"
qk_tap_dance_action_t tap_dance_actions[] = {
[DA_LCTL] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_lctl_finished,
dance_lctl_reset),
[DA_LSPR] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_lspr_finished,
dance_lspr_reset),
[DA_RCTL] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_rctl_finished,
dance_rctl_reset),
[DA_RALT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_ralt_finished,
dance_ralt_reset),
[DA_UPLY] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_uply_finished,
dance_uply_reset),
[DA_DWLY] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_dwly_finished,
dance_dwly_reset),
};
volatile uint8_t active_layer = _BL;
volatile uint8_t gm_layer_act = false;
My userspace and lets_split keymap (#2842) * copied lets_slit to splinter * initial splinter layout * remove unused keymaps * implemented second half of the keyboard * initial definition of tap dance * the tap dance is working now tap dance for right hand 4c 2r hold - shift single tap - n double tap - ñ triple tap - Ñ * clear the keymap.c * put the tap state on to array * the n tilde tap dance should produce right shift if hold * add esc grv tap dance * remove the defined SS_LSFT on tap_dance.h because it was added on the quantum.h * minor cleanup for the keymap * use the X_* on tap dance * added super alt tap dance * use the NO_TAP on tap dance reset * allow track what rows and cols pressed * added the RGUI_ALT * keymap arrangement * use i2c * initial rgb * layer colors * initial rgb pressed key * set the layers led * SUCCESS!!! * cleaning * improve shifted layer * led brightness * initial caps rainbow * rename SET_LED_RGB to SET_LED_RGB_HEX * clean the SET_LED_RGB_HEX and added SET_LED_RGB * clean format * caps lock rainbow * rename key_led to set_key_led * caps lock rainbow enhanced * make varibiables static * change back the loop max value to 360 for the rainbow * add scroll lock to the rainbow led * fix pos calculation of right hand board * add ative keys and make rainbow color can override by key press * remove the TOTAL_MATRIX_POINTS * some improvments for the rgb * call the rgblight_set on the process_record_user * some enhancement for the leds * pass the dim value to set_layer_led and limit the brightness on _VL set the brightness to 2 if the dim value is less than 2 because their is not enought power for the leds. * remove the rgb steps on the config * use the non rev config * remove all the revisions * favor i2c instead of serial and remove all the ref for the serial * clang formatting * allow to save to eeprom the brightness value * add bootloader caterina this will enable soft reset key * initial commit for the userspace * added my own keymap for splinter * first working userspace * move splinter to handwired keyboards * handwired splinter default keymap * move some config to my keymap * cleanup some headers on the keymap * move the EECONFIG_RGB_DIM to the user space * I fix remove the GUI on SPC and ENT * remove the default include on tap_dance.c * add lights.c and refactoring * fix wrong source for led index * seperate the variable on set_layer_led for readabilty. * set the usb max power consumption to 50 * fix led lighting * add new enums for tap dance * use romeve path avr on eeprom.h * fix wrong spelling on TP names * changed the tap dance * allow to set rainbow on some pressed key * add reset key * fix error on matrix.c if ROW2COL is used * add extraflags -flto * See e2352d4 * Got no love from i2c, serial to the rescue * Fix the led will lit up to color red after boot * Trial if the power can handle yellow color at full * Add comment * Use EE_HANDS * add config.h in the use space * KC_N on BL should wrap in SFT_T * See d13567d, put it back but increase 1 level * Fix led soldering mistake * set the tapping_term to 100 * Use TT for the changing the layer * Remove the changing space to enter and vice version on BL and UL * Increate the tapping term * Use tap dance on changing layer * Add assorted layer * propery way to tapdance * Remove DA_EGRV This also fix the wrong placement of the reset and dance lspr should register the KC_LGUI on finished not unregistered. * Remove the media control to the up and down layer * Remove the interrupted state of the tap dance * swapt the space and enter on to th caps * Shorthand * Keymap update * My keymap for lets_split * cleaning
2018-04-29 20:02:37 +00:00
static tap upltap_state = {.state = 0};
static tap dwltap_state = {.state = 0};
static tap lsprtap_state = {.state = 0};
static tap ralttap_state = {.state = 0};
void layer_switcher_tap(uint8_t new_layer) {
if (gm_layer_act == true) {
layer_off(active_layer);
if (new_layer == _BL) {
layer_on(_GM);
active_layer = _GM;
} else {
layer_on(new_layer);
active_layer = new_layer;
}
} else {
layer_off(active_layer);
layer_on(new_layer);
active_layer = new_layer;
}
My userspace and lets_split keymap (#2842) * copied lets_slit to splinter * initial splinter layout * remove unused keymaps * implemented second half of the keyboard * initial definition of tap dance * the tap dance is working now tap dance for right hand 4c 2r hold - shift single tap - n double tap - ñ triple tap - Ñ * clear the keymap.c * put the tap state on to array * the n tilde tap dance should produce right shift if hold * add esc grv tap dance * remove the defined SS_LSFT on tap_dance.h because it was added on the quantum.h * minor cleanup for the keymap * use the X_* on tap dance * added super alt tap dance * use the NO_TAP on tap dance reset * allow track what rows and cols pressed * added the RGUI_ALT * keymap arrangement * use i2c * initial rgb * layer colors * initial rgb pressed key * set the layers led * SUCCESS!!! * cleaning * improve shifted layer * led brightness * initial caps rainbow * rename SET_LED_RGB to SET_LED_RGB_HEX * clean the SET_LED_RGB_HEX and added SET_LED_RGB * clean format * caps lock rainbow * rename key_led to set_key_led * caps lock rainbow enhanced * make varibiables static * change back the loop max value to 360 for the rainbow * add scroll lock to the rainbow led * fix pos calculation of right hand board * add ative keys and make rainbow color can override by key press * remove the TOTAL_MATRIX_POINTS * some improvments for the rgb * call the rgblight_set on the process_record_user * some enhancement for the leds * pass the dim value to set_layer_led and limit the brightness on _VL set the brightness to 2 if the dim value is less than 2 because their is not enought power for the leds. * remove the rgb steps on the config * use the non rev config * remove all the revisions * favor i2c instead of serial and remove all the ref for the serial * clang formatting * allow to save to eeprom the brightness value * add bootloader caterina this will enable soft reset key * initial commit for the userspace * added my own keymap for splinter * first working userspace * move splinter to handwired keyboards * handwired splinter default keymap * move some config to my keymap * cleanup some headers on the keymap * move the EECONFIG_RGB_DIM to the user space * I fix remove the GUI on SPC and ENT * remove the default include on tap_dance.c * add lights.c and refactoring * fix wrong source for led index * seperate the variable on set_layer_led for readabilty. * set the usb max power consumption to 50 * fix led lighting * add new enums for tap dance * use romeve path avr on eeprom.h * fix wrong spelling on TP names * changed the tap dance * allow to set rainbow on some pressed key * add reset key * fix error on matrix.c if ROW2COL is used * add extraflags -flto * See e2352d4 * Got no love from i2c, serial to the rescue * Fix the led will lit up to color red after boot * Trial if the power can handle yellow color at full * Add comment * Use EE_HANDS * add config.h in the use space * KC_N on BL should wrap in SFT_T * See d13567d, put it back but increase 1 level * Fix led soldering mistake * set the tapping_term to 100 * Use TT for the changing the layer * Remove the changing space to enter and vice version on BL and UL * Increate the tapping term * Use tap dance on changing layer * Add assorted layer * propery way to tapdance * Remove DA_EGRV This also fix the wrong placement of the reset and dance lspr should register the KC_LGUI on finished not unregistered. * Remove the media control to the up and down layer * Remove the interrupted state of the tap dance * swapt the space and enter on to th caps * Shorthand * Keymap update * My keymap for lets_split * cleaning
2018-04-29 20:02:37 +00:00
}
int cur_dance(qk_tap_dance_state_t *state) {
switch (state->count) {
case 1:
return state->pressed == 0 ? SINGLE_TAP : SINGLE_HOLD;
case 2:
return state->pressed == 0 ? DOUBLE_TAP : DOUBLE_HOLD;
case 3:
return state->pressed == 0 ? TRIPLE_TAP : TRIPLE_HOLD;
default:
return state->pressed == 0 ? DEFAULT_TAP : DEFAULT_HOLD;
}
}
void dance_lctl_finished(qk_tap_dance_state_t *state, void *user_data) {
rbw_led_keys[RBW_LCTL].status = ENABLED;
register_code(KC_LCTRL);
};
void dance_lctl_reset(qk_tap_dance_state_t *state, void *user_data) {
unregister_code(KC_LCTRL);
rbw_led_keys[RBW_LCTL].status = DISABLED;
};
void dance_lspr_finished(qk_tap_dance_state_t *state, void *user_data) {
lsprtap_state.state = cur_dance(state);
switch (lsprtap_state.state) {
case DOUBLE_HOLD:
rbw_led_keys[RBW_LSPR].status = ENABLED;
register_code(KC_LALT);
break;
default:
register_code(KC_LGUI);
break;
}
};
void dance_lspr_reset(qk_tap_dance_state_t *state, void *user_data) {
switch (lsprtap_state.state) {
case DOUBLE_HOLD:
unregister_code(KC_LALT);
rbw_led_keys[RBW_LSPR].status = DISABLED;
break;
default:
unregister_code(KC_LGUI);
break;
}
};
void dance_rctl_finished(qk_tap_dance_state_t *state, void *user_data) {
rbw_led_keys[RBW_RCTL].status = ENABLED;
register_code(KC_RCTRL);
};
void dance_rctl_reset(qk_tap_dance_state_t *state, void *user_data) {
unregister_code(KC_RCTRL);
rbw_led_keys[RBW_RCTL].status = DISABLED;
};
void dance_ralt_finished(qk_tap_dance_state_t *state, void *user_data) {
ralttap_state.state = cur_dance(state);
switch (ralttap_state.state) {
case DOUBLE_HOLD:
rbw_led_keys[RBW_RALT].status = ENABLED;
unregister_code(KC_LGUI);
break;
default:
register_code(KC_RALT);
break;
}
};
void dance_ralt_reset(qk_tap_dance_state_t *state, void *user_data) {
switch (ralttap_state.state) {
case DOUBLE_HOLD:
unregister_code(KC_RGUI);
rbw_led_keys[RBW_RALT].status = DISABLED;
break;
default:
unregister_code(KC_RALT);
break;
}
};
void dance_uply_finished(qk_tap_dance_state_t *state, void *user_data) {
upltap_state.state = cur_dance(state);
switch (upltap_state.state) {
case SINGLE_TAP:
if (active_layer == _UL) {
layer_switcher_tap(_BL);
} else {
layer_switcher_tap(_UL);
}
break;
case SINGLE_HOLD:
layer_switcher_tap(_UL);
break;
default:
layer_switcher_tap(_BL);
break;
}
}
void dance_uply_reset(qk_tap_dance_state_t *state, void *user_data) {
switch (upltap_state.state) {
case SINGLE_TAP:
break;
case SINGLE_HOLD:
default:
layer_switcher_tap(_BL);
break;
}
upltap_state.state = 0;
}
void dance_dwly_finished(qk_tap_dance_state_t *state, void *user_data) {
dwltap_state.state = cur_dance(state);
switch (dwltap_state.state) {
case SINGLE_TAP:
if (active_layer == _DL) {
layer_switcher_tap(_BL);
} else {
layer_switcher_tap(_DL);
}
break;
case SINGLE_HOLD:
layer_switcher_tap(_DL);
break;
case DOUBLE_HOLD:
layer_switcher_tap(_AL);
break;
case TRIPLE_TAP:
if (gm_layer_act == true) {
gm_layer_act = false;
layer_switcher_tap(_BL);
} else {
gm_layer_act = true;
layer_switcher_tap(_GM);
}
My userspace and lets_split keymap (#2842) * copied lets_slit to splinter * initial splinter layout * remove unused keymaps * implemented second half of the keyboard * initial definition of tap dance * the tap dance is working now tap dance for right hand 4c 2r hold - shift single tap - n double tap - ñ triple tap - Ñ * clear the keymap.c * put the tap state on to array * the n tilde tap dance should produce right shift if hold * add esc grv tap dance * remove the defined SS_LSFT on tap_dance.h because it was added on the quantum.h * minor cleanup for the keymap * use the X_* on tap dance * added super alt tap dance * use the NO_TAP on tap dance reset * allow track what rows and cols pressed * added the RGUI_ALT * keymap arrangement * use i2c * initial rgb * layer colors * initial rgb pressed key * set the layers led * SUCCESS!!! * cleaning * improve shifted layer * led brightness * initial caps rainbow * rename SET_LED_RGB to SET_LED_RGB_HEX * clean the SET_LED_RGB_HEX and added SET_LED_RGB * clean format * caps lock rainbow * rename key_led to set_key_led * caps lock rainbow enhanced * make varibiables static * change back the loop max value to 360 for the rainbow * add scroll lock to the rainbow led * fix pos calculation of right hand board * add ative keys and make rainbow color can override by key press * remove the TOTAL_MATRIX_POINTS * some improvments for the rgb * call the rgblight_set on the process_record_user * some enhancement for the leds * pass the dim value to set_layer_led and limit the brightness on _VL set the brightness to 2 if the dim value is less than 2 because their is not enought power for the leds. * remove the rgb steps on the config * use the non rev config * remove all the revisions * favor i2c instead of serial and remove all the ref for the serial * clang formatting * allow to save to eeprom the brightness value * add bootloader caterina this will enable soft reset key * initial commit for the userspace * added my own keymap for splinter * first working userspace * move splinter to handwired keyboards * handwired splinter default keymap * move some config to my keymap * cleanup some headers on the keymap * move the EECONFIG_RGB_DIM to the user space * I fix remove the GUI on SPC and ENT * remove the default include on tap_dance.c * add lights.c and refactoring * fix wrong source for led index * seperate the variable on set_layer_led for readabilty. * set the usb max power consumption to 50 * fix led lighting * add new enums for tap dance * use romeve path avr on eeprom.h * fix wrong spelling on TP names * changed the tap dance * allow to set rainbow on some pressed key * add reset key * fix error on matrix.c if ROW2COL is used * add extraflags -flto * See e2352d4 * Got no love from i2c, serial to the rescue * Fix the led will lit up to color red after boot * Trial if the power can handle yellow color at full * Add comment * Use EE_HANDS * add config.h in the use space * KC_N on BL should wrap in SFT_T * See d13567d, put it back but increase 1 level * Fix led soldering mistake * set the tapping_term to 100 * Use TT for the changing the layer * Remove the changing space to enter and vice version on BL and UL * Increate the tapping term * Use tap dance on changing layer * Add assorted layer * propery way to tapdance * Remove DA_EGRV This also fix the wrong placement of the reset and dance lspr should register the KC_LGUI on finished not unregistered. * Remove the media control to the up and down layer * Remove the interrupted state of the tap dance * swapt the space and enter on to th caps * Shorthand * Keymap update * My keymap for lets_split * cleaning
2018-04-29 20:02:37 +00:00
default:
layer_switcher_tap(_BL);
break;
}
}
void dance_dwly_reset(qk_tap_dance_state_t *state, void *user_data) {
switch (dwltap_state.state) {
case SINGLE_TAP:
break;
case SINGLE_HOLD:
case DOUBLE_HOLD:
case TRIPLE_TAP:
My userspace and lets_split keymap (#2842) * copied lets_slit to splinter * initial splinter layout * remove unused keymaps * implemented second half of the keyboard * initial definition of tap dance * the tap dance is working now tap dance for right hand 4c 2r hold - shift single tap - n double tap - ñ triple tap - Ñ * clear the keymap.c * put the tap state on to array * the n tilde tap dance should produce right shift if hold * add esc grv tap dance * remove the defined SS_LSFT on tap_dance.h because it was added on the quantum.h * minor cleanup for the keymap * use the X_* on tap dance * added super alt tap dance * use the NO_TAP on tap dance reset * allow track what rows and cols pressed * added the RGUI_ALT * keymap arrangement * use i2c * initial rgb * layer colors * initial rgb pressed key * set the layers led * SUCCESS!!! * cleaning * improve shifted layer * led brightness * initial caps rainbow * rename SET_LED_RGB to SET_LED_RGB_HEX * clean the SET_LED_RGB_HEX and added SET_LED_RGB * clean format * caps lock rainbow * rename key_led to set_key_led * caps lock rainbow enhanced * make varibiables static * change back the loop max value to 360 for the rainbow * add scroll lock to the rainbow led * fix pos calculation of right hand board * add ative keys and make rainbow color can override by key press * remove the TOTAL_MATRIX_POINTS * some improvments for the rgb * call the rgblight_set on the process_record_user * some enhancement for the leds * pass the dim value to set_layer_led and limit the brightness on _VL set the brightness to 2 if the dim value is less than 2 because their is not enought power for the leds. * remove the rgb steps on the config * use the non rev config * remove all the revisions * favor i2c instead of serial and remove all the ref for the serial * clang formatting * allow to save to eeprom the brightness value * add bootloader caterina this will enable soft reset key * initial commit for the userspace * added my own keymap for splinter * first working userspace * move splinter to handwired keyboards * handwired splinter default keymap * move some config to my keymap * cleanup some headers on the keymap * move the EECONFIG_RGB_DIM to the user space * I fix remove the GUI on SPC and ENT * remove the default include on tap_dance.c * add lights.c and refactoring * fix wrong source for led index * seperate the variable on set_layer_led for readabilty. * set the usb max power consumption to 50 * fix led lighting * add new enums for tap dance * use romeve path avr on eeprom.h * fix wrong spelling on TP names * changed the tap dance * allow to set rainbow on some pressed key * add reset key * fix error on matrix.c if ROW2COL is used * add extraflags -flto * See e2352d4 * Got no love from i2c, serial to the rescue * Fix the led will lit up to color red after boot * Trial if the power can handle yellow color at full * Add comment * Use EE_HANDS * add config.h in the use space * KC_N on BL should wrap in SFT_T * See d13567d, put it back but increase 1 level * Fix led soldering mistake * set the tapping_term to 100 * Use TT for the changing the layer * Remove the changing space to enter and vice version on BL and UL * Increate the tapping term * Use tap dance on changing layer * Add assorted layer * propery way to tapdance * Remove DA_EGRV This also fix the wrong placement of the reset and dance lspr should register the KC_LGUI on finished not unregistered. * Remove the media control to the up and down layer * Remove the interrupted state of the tap dance * swapt the space and enter on to th caps * Shorthand * Keymap update * My keymap for lets_split * cleaning
2018-04-29 20:02:37 +00:00
default:
layer_switcher_tap(_BL);
break;
}
dwltap_state.state = 0;
}