Skip to content

Commit

Permalink
log,doc: more defsrc warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jtroo committed Sep 7, 2024
1 parent 697e6f8 commit 92d1478
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
12 changes: 8 additions & 4 deletions docs/config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,16 @@ This might be useful
if you are only mapping a few keys in defsrc
instead of most of the keys on your keyboard.

Without this, some actions like `+rpt+`, `+tap-hold-release+`, `+one-shot+`,
will not work correctly for subsequent key presses that are not in defsrc.
By default, keys excluded from `defsrc` will not work in various scenarios.
Some examples of when a not-in-defsrc key is pressed:

- antecedent `+tap-hold-press+` activations will not trigger an early hold
- antecedent `+one-shot+` activations will not be released
- `fork|switch` logic will not be able to see the key

This option is disabled by default.
The reason this is not enabled by default is
because some keys may not work correctly if they are intercepted.
The reason this is not enabled by default
is because some keys may not work correctly if they are intercepted.
For example, see <<windows-only-windows-altgr>>.

.Example:
Expand Down
9 changes: 8 additions & 1 deletion parser/src/cfg/defcfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,17 @@ pub fn parse_defcfg(expr: &[SExpr]) -> Result<CfgOptions> {
let mut seen_keys = HashSet::default();
let mut cfg = CfgOptions::default();
let mut exprs = check_first_expr(expr.iter(), "defcfg")?;
let mut is_process_unmapped_keys_defined = false;
// Read k-v pairs from the configuration
loop {
let key = match exprs.next() {
Some(k) => k,
None => return Ok(cfg),
None => {
if !is_process_unmapped_keys_defined {
log::warn!("The item process-unmapped-keys is not defined in defcfg. Consider whether process-unmapped-keys should be yes vs. no.");
}
return Ok(cfg);
}
};
let val = match exprs.next() {
Some(v) => v,
Expand Down Expand Up @@ -603,6 +609,7 @@ pub fn parse_defcfg(expr: &[SExpr]) -> Result<CfgOptions> {
}

"process-unmapped-keys" => {
is_process_unmapped_keys_defined = true;
cfg.process_unmapped_keys = parse_defcfg_val_bool(val, label)?
}
"block-unmapped-keys" => {
Expand Down
5 changes: 4 additions & 1 deletion parser/src/cfg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,10 @@ pub fn parse_cfg_raw_string(
.find(gen_first_atom_filter("defcfg"))
.map(|cfg| parse_defcfg(cfg))
.transpose()?
.unwrap_or_default();
.unwrap_or_else(|| {
log::warn!("No defcfg is defined. Consider whether the process-unmapped-keys defcfg option should be yes vs. no. Adding defcfg with process-unmapped-keys defined will remove this warning.");
Default::default()
});
if let Some(spanned) = spanned_root_exprs
.iter()
.filter(gen_first_atom_filter_spanned("defcfg"))
Expand Down

0 comments on commit 92d1478

Please sign in to comment.