Merge 9afefe5177
into db9ab30335
This commit is contained in:
commit
83f09e7b66
3 changed files with 56 additions and 1 deletions
|
@ -39,6 +39,15 @@ properties:
|
|||
- "tap-unless-interrupted"
|
||||
retro-tap:
|
||||
type: boolean
|
||||
retro-tap-behavior:
|
||||
type: string
|
||||
default: ""
|
||||
retro-tap-param1:
|
||||
type: int
|
||||
default: 0
|
||||
retro-tap-param2:
|
||||
type: int
|
||||
default: 0
|
||||
hold-trigger-key-positions:
|
||||
type: array
|
||||
required: false
|
||||
|
|
|
@ -40,6 +40,7 @@ enum flavor {
|
|||
enum status {
|
||||
STATUS_UNDECIDED,
|
||||
STATUS_TAP,
|
||||
STATUS_RETRO_TAP,
|
||||
STATUS_HOLD_INTERRUPT,
|
||||
STATUS_HOLD_TIMER,
|
||||
};
|
||||
|
@ -60,6 +61,9 @@ struct behavior_hold_tap_config {
|
|||
int require_prior_idle_ms;
|
||||
enum flavor flavor;
|
||||
bool retro_tap;
|
||||
char *retro_tap_behavior;
|
||||
uint32_t retro_tap_param1;
|
||||
uint32_t retro_tap_param2;
|
||||
bool hold_trigger_on_release;
|
||||
int32_t hold_trigger_key_positions_len;
|
||||
int32_t hold_trigger_key_positions[];
|
||||
|
@ -375,6 +379,11 @@ static int press_binding(struct active_hold_tap *hold_tap) {
|
|||
if (hold_tap->status == STATUS_HOLD_TIMER || hold_tap->status == STATUS_HOLD_INTERRUPT) {
|
||||
binding.behavior_dev = hold_tap->config->hold_behavior_dev;
|
||||
binding.param1 = hold_tap->param_hold;
|
||||
} else if (hold_tap->status == STATUS_RETRO_TAP) {
|
||||
binding.behavior_dev = hold_tap->config->retro_tap_behavior;
|
||||
binding.param1 = hold_tap->config->retro_tap_param1;
|
||||
binding.param2 = hold_tap->config->retro_tap_param2;
|
||||
store_last_hold_tapped(hold_tap);
|
||||
} else {
|
||||
binding.behavior_dev = hold_tap->config->tap_behavior_dev;
|
||||
binding.param1 = hold_tap->param_tap;
|
||||
|
@ -397,6 +406,10 @@ static int release_binding(struct active_hold_tap *hold_tap) {
|
|||
if (hold_tap->status == STATUS_HOLD_TIMER || hold_tap->status == STATUS_HOLD_INTERRUPT) {
|
||||
binding.behavior_dev = hold_tap->config->hold_behavior_dev;
|
||||
binding.param1 = hold_tap->param_hold;
|
||||
} else if (hold_tap->status == STATUS_RETRO_TAP) {
|
||||
binding.behavior_dev = hold_tap->config->retro_tap_behavior;
|
||||
binding.param1 = hold_tap->config->retro_tap_param1;
|
||||
binding.param2 = hold_tap->config->retro_tap_param2;
|
||||
} else {
|
||||
binding.behavior_dev = hold_tap->config->tap_behavior_dev;
|
||||
binding.param1 = hold_tap->param_tap;
|
||||
|
@ -487,7 +500,11 @@ static void decide_retro_tap(struct active_hold_tap *hold_tap) {
|
|||
if (hold_tap->status == STATUS_HOLD_TIMER) {
|
||||
release_binding(hold_tap);
|
||||
LOG_DBG("%d retro tap", hold_tap->position);
|
||||
hold_tap->status = STATUS_TAP;
|
||||
if (strcmp(hold_tap->config->retro_tap_behavior, "") == 0) {
|
||||
hold_tap->status = STATUS_TAP;
|
||||
} else {
|
||||
hold_tap->status = STATUS_RETRO_TAP;
|
||||
}
|
||||
press_binding(hold_tap);
|
||||
return;
|
||||
}
|
||||
|
@ -711,6 +728,9 @@ static int behavior_hold_tap_init(const struct device *dev) {
|
|||
: DT_INST_PROP(n, require_prior_idle_ms), \
|
||||
.flavor = DT_ENUM_IDX(DT_DRV_INST(n), flavor), \
|
||||
.retro_tap = DT_INST_PROP(n, retro_tap), \
|
||||
.retro_tap_behavior = DT_INST_PROP(n, retro_tap_behavior), \
|
||||
.retro_tap_param1 = DT_INST_PROP(n, retro_tap_param1), \
|
||||
.retro_tap_param2 = DT_INST_PROP(n, retro_tap_param2), \
|
||||
.hold_trigger_on_release = DT_INST_PROP(n, hold_trigger_on_release), \
|
||||
.hold_trigger_key_positions = DT_INST_PROP(n, hold_trigger_key_positions), \
|
||||
.hold_trigger_key_positions_len = DT_INST_PROP_LEN(n, hold_trigger_key_positions), \
|
||||
|
|
|
@ -83,6 +83,32 @@ For example, if you press `&mt LEFT_SHIFT A` and then release it without pressin
|
|||
};
|
||||
```
|
||||
|
||||
To define a behavior to use instead of the tap behavior, include `retro-tap-behavior`, `retro-tap-param1`, and/or `retro-tap-param2` in your hold-tap definition.
|
||||
|
||||
- `retro-tap-behavior` refers to the label string of the desired behavior. See below for a list of these label strings for built-in behaviors.
|
||||
- `retro-tap-param1` refers to the first thing that comes after the behavior in your keymap. e.g. for `&mt LSHFT A`, LSHFT will be param1.
|
||||
- `retro-tap-param2` refers to the second thing that comes after the behavior in your keymap. e.g. for `&mt LSHFT A`, A will be param2.
|
||||
|
||||
List of built-in behaviors and their corresponding label strings:
|
||||
|
||||
- &bl - "BCKLGHT"
|
||||
- &bt - "BLUETOOTH"
|
||||
- &caps_word - "CAPS_WORD"
|
||||
- &ext_power - "EXTPOWER"
|
||||
- &gresc - "GRAVE_ESCAPE"
|
||||
- &kp - "KEY_PRESS"
|
||||
- &key_repeat - "KEY_REPEAT"
|
||||
- &none - "NONE"
|
||||
- &out - "OUTPUTS"
|
||||
- &reset - "RESET"
|
||||
- &bootloader - "BOOTLOAD"
|
||||
- &rgb_ug - "RGB_UG"
|
||||
- &sk - "STICKY_KEY"
|
||||
- &sl - "STICKY_LAYER"
|
||||
- &to - "TO_LAYER"
|
||||
- &tog - "TOGGLE_LAYER"
|
||||
- &trans - "TRANS"
|
||||
|
||||
#### Positional hold-tap and `hold-trigger-key-positions`
|
||||
|
||||
Including `hold-trigger-key-positions` in your hold-tap definition turns on the positional hold-tap feature. With positional hold-tap enabled, if you press any key **NOT** listed in `hold-trigger-key-positions` before `tapping-term-ms` expires, it will produce a tap.
|
||||
|
|
Loading…
Add table
Reference in a new issue