Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

International characters in deflayer #797

Open
fleutot opened this issue Jan 15, 2024 · 7 comments
Open

International characters in deflayer #797

fleutot opened this issue Jan 15, 2024 · 7 comments

Comments

@fleutot
Copy link

fleutot commented Jan 15, 2024

I am trying to implement svorak in a layer, but I cannot find how to output å, ä, and ö.

Putting the characters themselves in the deflayer results in:

kmonad.exe: .\experimental.kbd: withFile: invalid argument (cannot decode byte sequence starting from 229)

I tried aring, that fails as well. How do I output these characters?

On current master, on Windows.

@haferburg
Copy link

Search for 'umlaut' here in the issues.

@fleutot
Copy link
Author

fleutot commented Jan 15, 2024

I've found a couple of issues with "umlaut", and tried to reproduce that weird one with only one shift working on 'ö', with this:

(defcfg

  ;; Windows
  input  (low-level-hook)
  output (send-event-sink 500 20)

  fallthrough true
)

(defsrc          lsft ; rsft)
(deflayer level1 lsft ö rsft)

I get this:

kmonad.exe: .\oe.kbd: withFile: invalid argument (cannot decode byte sequence starting from 246)

The 'ö' in that user's layer seems fine? Why can't I do it?

Then I also found this, which suggests to let kmonad only work with US keys and symbols, then let the OS interpret the keycodes as other characters. Is that the established way? Does it imply that : must be on Shift+;?

@slotThe
Copy link
Member

slotThe commented Jan 15, 2024

Then I also found this, which suggests to let kmonad only work with US keys and symbols, then let the OS interpret the keycodes as other characters. Is that the established way?

Yes, Unicode symbols are largely dependent on the environment.

Does it imply that : must be on Shift+;?

Yes. Unlike for ;, there is no actual keycode for :.

@fleutot
Copy link
Author

fleutot commented Jan 16, 2024

Alright, I suppose I got confused because of my earlier uses of xkbcomp, thank you. These look like characters, but are actually shorthands for keycodes.

But I still get strange behavior for these characters. Here is my new test config:

(defcfg
  ;; Linux
  ;; input  (device-file "/dev/input/by-path/platform-i8042-serio-0-event-kbd")
  ;; output (uinput-sink "KMonad output")

  ;; Windows
  input  (low-level-hook)
  output (send-event-sink 500 20)

  ;; MacOS
  ;; input  (iokit-name "my-keyboard-product-string")
  ;; output (kext)

  fallthrough true
)


(defsrc
  grv  1    2    3    4    5    6    7    8    9    0    -    =    bspc
  tab  q    w    e    r    t    y    u    i    o    p    [    ]    \
  caps a    s    d    f    g    h    j    k    l    ;    '    ret
  lsft z    x    c    v    b    n    m    ,    .    /    rsft
  lctl lmet lalt          spc           ralt
)


(deflayer svorak
  grv  1    2    3     4      5         6    7    8    9    0    -    =    bspc
  tab  [    '    ;     p      y         f    g    c    r    l    ,    +    ]
  caps a    o    e     u      i         d    h    t    n    s    -    ret
  lsft .    q    j     k      x         b    m    w    v    z    rsft
  lctl lmet lalt             spc           ralt
)

The traditional qwerty Swedish layout has å, ä, ö at these locations (right side of alphas):
image

So I am thinking:

  • Å is normally at location for US [
  • I want to move that to left pinky, one up (physical key Q)
  • I put [ there, and kmonad is going to replace keycode Q it gets, to keycode [
  • my Windows Swedish layout then replaces [ with Å

Did I get that right?

Most of the keys work as defined in the layer above, but:

  • left-pinky-one-up gives grave backtick (dead key, as normal in Swedish)
  • the one on the right of that (left ring finger one up, keycode apostrophe) gives an ä, as it should
  • the one on the right of that (left long finger one up, keycode semicolon) gives a umlaut, instead of ö (also dead key)
  • keycode ; (right pinky home row) gives ö instead of s. Incidentally, that is the character for that key in the Swedish qwerty layout.
  • keycode = gives ,

With Windows keyboard in US, the svorak layer works as expected.

With the Swedish layout in Windows, the emitted characters get wrong (or if it's keycodes, at that point I'm not sure). What am I doing wrong? What can I do to pinpoint where things get mixed up?


I don't know if that is relevant, but I randomly get error messages upon starting kmonad. I need about eight attempts (killing with Ctrl+c in between) before starting works:

PS C:\Users\gostervall\keyboard_configs> kmonad .\svorak.kbd
Encountered error in KeySource: Cannot translate from windows keycode: 1380015954
PS C:\Users\gostervall\keyboard_configs> kmonad .\svorak.kbd
Encountered error in KeySource: Cannot translate from windows keycode: 1734112114
PS C:\Users\gostervall\keyboard_configs> kmonad .\svorak.kbd
Encountered error in KeySource: Cannot translate from windows keycode: 1414415684
PS C:\Users\gostervall\keyboard_configs> kmonad .\svorak.kbd
Encountered error in KeySink: Cannot translate to windows keycode: Missing254
Encountered error in <emitter_proc>: Cannot translate to windows keycode: Missing254
PS C:\Users\gostervall\keyboard_configs> kmonad .\svorak.kbd    # this one worked

@fleutot
Copy link
Author

fleutot commented Jan 24, 2024

I've just tried the above in Ubuntu, since I suspected Windows. But now I think it's me still misunderstanding.

Without kmonad running, setxkbmap -layout se gives me the standard Swedish layout.

Not changing the Swedish mapping in X, I start xmonad with the "svorak" config below:

(defcfg
  input  (device-file "/dev/input/by-id/usb-05f3_0007-event-kbd")
  ;; /dev/input/by-path/platform-i8042-serio-0-event-kbd") ; Builtin laptop keyboard
  output (uinput-sink "KMonad output")

  fallthrough true
)

(defsrc
  grv  1    2    3    4    5    6    7    8    9    0    -    =    bspc
  tab  q    w    e    r    t    y    u    i    o    p    [    ]    \
  caps a    s    d    f    g    h    j    k    l    ;    '    ret
  lsft z    x    c    v    b    n    m    ,    .    /    rsft
  lctl lmet lalt          spc           ralt 
)

(deflayer svorak
  grv  1    2    3     4      5    6    7    8    9    0    -    =    bspc
  tab  [    '    ;     p      y    f    g    c    r    l    /    =    \
  caps a    o    e    u    i    d    h    t    n    s    -    ret
  lsft ;    q    j     k      x    b    m    w    v    z    rsft
  lctl lmet lalt             spc           ralt
)

My expectation:

  • physical key q makes kmonad send keycode [
  • X translates keycode [ to symbol å (as it usually does in usual Swedish qwerty)

What happens:

  • The symbol output is [. The X keymapping seems to be bypassed.

Can you see where I am wrong?

@slotThe
Copy link
Member

slotThe commented Jan 24, 2024

Did you re-execute setxkbmap -layout se after starting kmonad? Another keyboard is created, so all of the environment specific settings have to be set again. The output option conveniently has an additional argument for this:

(defcfgoutput (uinput-sink
          "KMonad output"
          "sleep 0.2s; setxkbmap -layout se"))

@fleutot
Copy link
Author

fleutot commented Jan 24, 2024

That was it, thanks a lot!

I now realize that the issues above are separate, although they sure first seemed related. It's solved for Linux/Xorg. Still in the dark for Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants