samvel1024 / kbct

Keyboard keycode mapping utility for Linux supporting layered configuration
MIT License
272 stars 24 forks source link

Support modifiers applied to single key presses #44

Closed naalit closed 3 weeks ago

naalit commented 2 years ago

Fixes https://github.com/samvel1024/kbct/issues/13, at least for the use case described there:

- keyboards: [ "AT Translated Set 2 keyboard"]

  layers:
    - modifiers: ['rightshift']
      keymap:
        apostrophe:
          modifiers: ['rightalt']
          key: q

The modifiers listed in a keybinding are pressed until the next event, then released, so if you pressed ', then tapped a while still holding ', and finally released ', with the above configuration, it would produce:

+rightalt +q
-rightalt +a
-a
-q
filyp commented 2 years ago

I've been waiting for this feature for long, and it's critical for me. Thank you <3

This repo looks quite inactive, so if someone want to use this feature without waiting for merge, do:

git clone https://aur.archlinux.org/kbct-git.git
cd kbct-git

Then exchange PKGBUILD for this one:

pkgname="kbct-git"
_gitname=kbct
pkgver=0.1.0.r59.d996cb7
pkgrel=1
pkgdesc="Keyboard keycode mapping utility for Linux supporting layered configuration"
arch=('x86_64')
url="https://github.com/tolziplohu/kbct"
license=('None')
depends=()
makedepends=('git' 'cargo' 'rust')
provides=('kbct')
source=("git+$url" 'kbct.service' 'config.yml')
backup=('etc/kbct/config.yml')
md5sums=('SKIP' 'SKIP' 'SKIP')

pkgver() {
    cd "$_gitname"
    echo $(grep '^version =' Cargo.toml|head -n1|cut -d\" -f2).r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd "$_gitname"
  git checkout modifiers
  cargo build --release
}

package() {
  cd "$_gitname"
  install -D -m755 ./target/release/kbct "$pkgdir/usr/bin/kbct"
  install -D -m644 "$srcdir/kbct.service" "$pkgdir/etc/systemd/system/kbct.service"
}

And then run:

makepkg -si
systemctl start kbct
drjaska commented 10 months ago

@naalit why does the following config fail to parse

- keyboards: [ "AT Translated Set 2 keyboard" ]

  layers:
    - modifiers: ['rightalt']
      keymap:
        k:
          modifiers: ['leftshift']
          key: 5
thread 'main' panicked at src/main.rs:278:10:
Could not parse the configuration yaml file: Message("data did not match any variant of untagged enum KeyPressConf", Some(Pos { marker: Marker { index: 224, line: 10, col: 9 }, path: ".[0].layers[0].keymap" }))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

but the same config but with k and 5 swapped works fine?

- keyboards: [ "AT Translated Set 2 keyboard" ]

  layers:
    - modifiers: ['rightalt']
      keymap:
        5:
          modifiers: ['leftshift']
          key: k

This is an issue for me as I really wanted to map the extra characters found on the numerical keys row to alphabetical keys on a new layer.

drjaska commented 10 months ago

Apparently numbers on the right hand side of : need to be double quoted like key: "9" and without quotes key: 9 is no longer valid syntax.

drjaska commented 10 months ago

There is also an issue with config like

    - modifiers: ['capslock', 'rightalt']
      keymap:
        e:
          modifiers: ['rightalt']
          key: "8"
        r:
          modifiers: ['leftshift']
          key: "8"

which fails to send rightalt + 8 which on nordic/scandinavian keyboards should produce [ while leftshift + 8 works fine to produce (.