refactor(behaviors): global-quick-tap -> require-prior-idle
Renaming global-quick-tap-ms to require-prior-idle.
This commit is contained in:
parent
49c393e8f8
commit
b85ffa4b6c
39 changed files with 41 additions and 41 deletions
|
@ -22,7 +22,7 @@ properties:
|
|||
type: int
|
||||
global-quick-tap: # deprecated
|
||||
type: boolean
|
||||
global-quick-tap-ms:
|
||||
require-prior-idle-ms:
|
||||
type: int
|
||||
default: -1
|
||||
flavor:
|
||||
|
|
|
@ -18,7 +18,7 @@ child-binding:
|
|||
timeout-ms:
|
||||
type: int
|
||||
default: 50
|
||||
global-quick-tap-ms:
|
||||
require-prior-idle-ms:
|
||||
type: int
|
||||
default: -1
|
||||
slow-release:
|
||||
|
|
|
@ -57,7 +57,7 @@ struct behavior_hold_tap_config {
|
|||
char *hold_behavior_dev;
|
||||
char *tap_behavior_dev;
|
||||
int quick_tap_ms;
|
||||
int global_quick_tap_ms;
|
||||
int require_prior_idle_ms;
|
||||
enum flavor flavor;
|
||||
bool retro_tap;
|
||||
bool hold_trigger_on_release;
|
||||
|
@ -114,7 +114,7 @@ static void store_last_hold_tapped(struct active_hold_tap *hold_tap) {
|
|||
}
|
||||
|
||||
static bool is_quick_tap(struct active_hold_tap *hold_tap) {
|
||||
if ((last_tapped.timestamp + hold_tap->config->global_quick_tap_ms) > hold_tap->timestamp) {
|
||||
if ((last_tapped.timestamp + hold_tap->config->require_prior_idle_ms) > hold_tap->timestamp) {
|
||||
return true;
|
||||
} else {
|
||||
return (last_tapped.position == hold_tap->position) &&
|
||||
|
@ -706,9 +706,9 @@ static int behavior_hold_tap_init(const struct device *dev) {
|
|||
.hold_behavior_dev = DT_PROP(DT_INST_PHANDLE_BY_IDX(n, bindings, 0), label), \
|
||||
.tap_behavior_dev = DT_PROP(DT_INST_PHANDLE_BY_IDX(n, bindings, 1), label), \
|
||||
.quick_tap_ms = DT_INST_PROP(n, quick_tap_ms), \
|
||||
.global_quick_tap_ms = DT_INST_PROP(n, global_quick_tap) \
|
||||
? DT_INST_PROP(n, quick_tap_ms) \
|
||||
: DT_INST_PROP(n, global_quick_tap_ms), \
|
||||
.require_prior_idle_ms = DT_INST_PROP(n, global_quick_tap) \
|
||||
? DT_INST_PROP(n, quick_tap_ms) \
|
||||
: 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), \
|
||||
.hold_trigger_on_release = DT_INST_PROP(n, hold_trigger_on_release), \
|
||||
|
|
|
@ -31,7 +31,7 @@ struct combo_cfg {
|
|||
int32_t key_position_len;
|
||||
struct zmk_behavior_binding behavior;
|
||||
int32_t timeout_ms;
|
||||
int32_t global_quick_tap_ms;
|
||||
int32_t require_prior_idle_ms;
|
||||
// if slow release is set, the combo releases when the last key is released.
|
||||
// otherwise, the combo releases when the first key is released.
|
||||
bool slow_release;
|
||||
|
@ -136,7 +136,7 @@ static bool combo_active_on_layer(struct combo_cfg *combo, uint8_t layer) {
|
|||
}
|
||||
|
||||
static bool is_quick_tap(struct combo_cfg *combo, int64_t timestamp) {
|
||||
return (last_tapped_timestamp + combo->global_quick_tap_ms) > timestamp;
|
||||
return (last_tapped_timestamp + combo->require_prior_idle_ms) > timestamp;
|
||||
}
|
||||
|
||||
static int setup_candidates_for_first_keypress(int32_t position, int64_t timestamp) {
|
||||
|
@ -523,7 +523,7 @@ ZMK_SUBSCRIPTION(combo, zmk_keycode_state_changed);
|
|||
#define COMBO_INST(n) \
|
||||
static struct combo_cfg combo_config_##n = { \
|
||||
.timeout_ms = DT_PROP(n, timeout_ms), \
|
||||
.global_quick_tap_ms = DT_PROP(n, global_quick_tap_ms), \
|
||||
.require_prior_idle_ms = DT_PROP(n, require_prior_idle_ms), \
|
||||
.key_positions = DT_PROP(n, key_positions), \
|
||||
.key_position_len = DT_PROP_LEN(n, key_positions), \
|
||||
.behavior = ZMK_KEYMAP_EXTRACT_BINDING(0, n), \
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
timeout-ms = <50>;
|
||||
key-positions = <0 1>;
|
||||
bindings = <&kp X>;
|
||||
global-quick-tap-ms = <100>;
|
||||
require-prior-idle-ms = <100>;
|
||||
};
|
||||
|
||||
combo_two {
|
|
@ -11,7 +11,7 @@
|
|||
flavor = "balanced";
|
||||
tapping-term-ms = <300>;
|
||||
quick-tap-ms = <300>;
|
||||
global-quick-tap-ms = <100>;
|
||||
require-prior-idle-ms = <100>;
|
||||
bindings = <&kp>, <&kp>;
|
||||
};
|
||||
};
|
|
@ -11,7 +11,7 @@
|
|||
flavor = "hold-preferred";
|
||||
tapping-term-ms = <300>;
|
||||
quick-tap-ms = <300>;
|
||||
global-quick-tap-ms = <100>;
|
||||
require-prior-idle-ms = <100>;
|
||||
bindings = <&kp>, <&kp>;
|
||||
};
|
||||
};
|
|
@ -11,7 +11,7 @@
|
|||
flavor = "tap-preferred";
|
||||
tapping-term-ms = <300>;
|
||||
quick-tap-ms = <300>;
|
||||
global-quick-tap-ms = <100>;
|
||||
require-prior-idle-ms = <100>;
|
||||
bindings = <&kp>, <&kp>;
|
||||
};
|
||||
};
|
|
@ -11,7 +11,7 @@
|
|||
flavor = "tap-unless-interrupted";
|
||||
tapping-term-ms = <300>;
|
||||
quick-tap-ms = <300>;
|
||||
global-quick-tap-ms = <100>;
|
||||
require-prior-idle-ms = <100>;
|
||||
bindings = <&kp>, <&kp>;
|
||||
};
|
||||
};
|
|
@ -49,11 +49,11 @@ Defines how long a key must be pressed to trigger Hold behavior.
|
|||
|
||||
If you press a tapped hold-tap again within `quick-tap-ms` milliseconds of the first press, it will always trigger the tap behavior. This is useful for things like a backspace, where a quick tap+hold holds backspace pressed. Set this to a negative value to disable. The default is -1 (disabled).
|
||||
|
||||
#### `global-quick-tap-ms`
|
||||
#### `require-prior-idle-ms`
|
||||
|
||||
`global-quick-tap-ms` is like `quick-tap-ms` however it will apply for _any_ non-modifier key pressed before it. This effectively disables the hold-tap when typing quickly, which can be quite useful for homerow mods. It can also have the effect of removing the input delay when typing quickly.
|
||||
`require-prior-idle-ms` is like `quick-tap-ms` however it will apply for _any_ non-modifier key pressed before it. This effectively disables the hold-tap when typing quickly, which can be quite useful for homerow mods. It can also have the effect of removing the input delay when typing quickly.
|
||||
|
||||
For example, the following hold-tap configuration enables `global-quick-tap-ms` with a 125 millisecond term, alongside a regular `quick-tap-ms` with a 200 millisecond term.
|
||||
For example, the following hold-tap configuration enables `require-prior-idle-ms` with a 125 millisecond term, alongside `quick-tap-ms` with a 200 millisecond term.
|
||||
|
||||
```
|
||||
gqt: global-quick-tap {
|
||||
|
@ -63,14 +63,14 @@ gqt: global-quick-tap {
|
|||
flavor = "tap-preferred";
|
||||
tapping-term-ms = <200>;
|
||||
quick-tap-ms = <200>;
|
||||
global-quick-tap-ms = <125>;
|
||||
require-prior-idle-ms = <125>;
|
||||
bindings = <&kp>, <&kp>;
|
||||
};
|
||||
```
|
||||
|
||||
If you press `&kp A` and then `&gqt LEFT_SHIFT B` **within** 125 ms, then `ab` will be output. Importantly, `b` will be output immediately since it was within the `quick-tap-ms`. This quick-tap behavior will work for any key press, whether it is within a behavior like hold-tap, or a simple `&kp`. This means the `&gqt LEFT_SHIFT B` binding will only have its underlying hold-tap behavior if it is pressed 125 ms **after** a key press.
|
||||
If you press `&kp A` and then `&gqt LEFT_SHIFT B` **within** 125 ms, then `ab` will be output. Importantly, `b` will be output immediately since it was within the `require-prior-idle-ms`. This "quick-tap" behavior will work for any key press, whether it is within a behavior like hold-tap, or a simple `&kp`. This means the `&gqt LEFT_SHIFT B` binding will only have its underlying hold-tap behavior if it is pressed 125 ms **after** a key press.
|
||||
|
||||
Note that the greater the value of `quick-tap-ms` is, the harder it will be to invoke the hold behavior, making this feature less applicable for use-cases like capitalizing letters while typing normally. However, if the hold behavior isn't used during fast typing, then it can be an effective way to mitigate misfires.
|
||||
Note that the greater the value of `require-prior-idle-ms` is, the harder it will be to invoke the hold behavior, making this feature less applicable for use-cases like capitalizing letters while typing normally. However, if the hold behavior isn't used during fast typing, then it can be an effective way to mitigate misfires.
|
||||
|
||||
#### `retro-tap`
|
||||
|
||||
|
|
|
@ -58,17 +58,17 @@ Definition file: [zmk/app/dts/bindings/behaviors/zmk,behavior-hold-tap.yaml](htt
|
|||
|
||||
Applies to: `compatible = "zmk,behavior-hold-tap"`
|
||||
|
||||
| Property | Type | Description | Default |
|
||||
| ---------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------ | ------------------ |
|
||||
| `label` | string | Unique label for the node | |
|
||||
| `#binding-cells` | int | Must be `<2>` | |
|
||||
| `bindings` | phandle array | A list of two behaviors (without parameters): one for hold and one for tap | |
|
||||
| `flavor` | string | Adjusts how the behavior chooses between hold and tap | `"hold-preferred"` |
|
||||
| `tapping-term-ms` | int | How long in milliseconds the key must be held to trigger a hold | |
|
||||
| `quick-tap-ms` | int | Tap twice within this period (in milliseconds) to trigger a tap, even when held | -1 (disabled) |
|
||||
| `global-quick-tap-ms` | int | Triggers a tap immediately if any non-modifier key was pressed within `global-quick-tap-ms` of the hold-tap. | -1 (disabled) |
|
||||
| `retro-tap` | bool | Triggers the tap behavior on release if no other key was pressed during a hold | false |
|
||||
| `hold-trigger-key-positions` | array | If set, pressing the hold-tap and then any key position _not_ in the list triggers a tap. | |
|
||||
| Property | Type | Description | Default |
|
||||
| ---------------------------- | ------------- | -------------------------------------------------------------------------------------------------------------- | ------------------ |
|
||||
| `label` | string | Unique label for the node | |
|
||||
| `#binding-cells` | int | Must be `<2>` | |
|
||||
| `bindings` | phandle array | A list of two behaviors (without parameters): one for hold and one for tap | |
|
||||
| `flavor` | string | Adjusts how the behavior chooses between hold and tap | `"hold-preferred"` |
|
||||
| `tapping-term-ms` | int | How long in milliseconds the key must be held to trigger a hold | |
|
||||
| `quick-tap-ms` | int | Tap twice within this period (in milliseconds) to trigger a tap, even when held | -1 (disabled) |
|
||||
| `require-prior-idle-ms` | int | Triggers a tap immediately if any non-modifier key was pressed within `require-prior-idle-ms` of the hold-tap. | -1 (disabled) |
|
||||
| `retro-tap` | bool | Triggers the tap behavior on release if no other key was pressed during a hold | false |
|
||||
| `hold-trigger-key-positions` | array | If set, pressing the hold-tap and then any key position _not_ in the list triggers a tap. | |
|
||||
|
||||
The `flavor` property may be one of:
|
||||
|
||||
|
|
|
@ -31,13 +31,13 @@ The `zmk,combos` node itself has no properties. It should have one child node pe
|
|||
|
||||
Each child node can have the following properties:
|
||||
|
||||
| Property | Type | Description | Default |
|
||||
| --------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
|
||||
| `bindings` | phandle-array | A [behavior](../features/keymaps.md#behaviors) to run when the combo is triggered | |
|
||||
| `key-positions` | array | A list of key position indices for the keys which should trigger the combo | |
|
||||
| `timeout-ms` | int | All the keys in `key-positions` must be pressed within this time in milliseconds to trigger the combo | 50 |
|
||||
| `global-quick-tap-ms` | int | If any non-modifier key is pressed within `global-quick-tap-ms` before a key in the combo, the key will not be considered for the combo | -1 (disabled) |
|
||||
| `slow-release` | bool | Releases the combo when all keys are released instead of when any key is released | false |
|
||||
| `layers` | array | A list of layers on which the combo may be triggered. `-1` allows all layers. | `<-1>` |
|
||||
| Property | Type | Description | Default |
|
||||
| ----------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
|
||||
| `bindings` | phandle-array | A [behavior](../features/keymaps.md#behaviors) to run when the combo is triggered | |
|
||||
| `key-positions` | array | A list of key position indices for the keys which should trigger the combo | |
|
||||
| `timeout-ms` | int | All the keys in `key-positions` must be pressed within this time in milliseconds to trigger the combo | 50 |
|
||||
| `require-prior-idle-ms` | int | If any non-modifier key is pressed within `require-prior-idle-ms` before a key in the combo, the key will not be considered for the combo | -1 (disabled) |
|
||||
| `slow-release` | bool | Releases the combo when all keys are released instead of when any key is released | false |
|
||||
| `layers` | array | A list of layers on which the combo may be triggered. `-1` allows all layers. | `<-1>` |
|
||||
|
||||
The `key-positions` array must not be longer than the `CONFIG_ZMK_COMBO_MAX_KEYS_PER_COMBO` setting, which defaults to 4. If you want a combo that triggers when pressing 5 keys, then you must change the setting to 5.
|
||||
|
|
|
@ -30,7 +30,7 @@ Combos configured in your `.keymap` file, but are separate from the `keymap` nod
|
|||
- `layers = <0 1...>` will allow limiting a combo to specific layers. This is an _optional_ parameter, when omitted it defaults to global scope.
|
||||
- `bindings` is the behavior that is activated when the behavior is pressed.
|
||||
- (advanced) you can specify `slow-release` if you want the combo binding to be released when all key-positions are released. The default is to release the combo as soon as any of the keys in the combo is released.
|
||||
- (advanced) you can specify a `global-quick-tap-ms` value much like for [hold-taps](behaviors/hold-tap.md#global-quick-tap-ms). If any non-modifier key is pressed within `global-quick-tap-ms` before a key in the combo, the combo will not trigger.
|
||||
- (advanced) you can specify a `require-prior-idle-ms` value much like for [hold-taps](behaviors/hold-tap.md#require-prior-idle-ms). If any non-modifier key is pressed within `require-prior-idle-ms` before a key in the combo, the combo will not trigger.
|
||||
|
||||
:::info
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue