How do I add unicode letters on a layer (think emoji layers for English users) using Chrysalis (on Atreus)

I got my Atreus quite a while ago, but haven’t gotten around to using much. I’m considering using it as my daily driver going ahead. I’ve managed to configure it to the way I prefer (Dvorak with few key changes) using Chrysalis.

I’d love to be able to use some layers to add support for another language/script I use fairly often.

What I’m hoping for :

  • I wouldn’t have to switch/add keyboard layout in the OS for the other language that I’d like to type in
  • Simply plugin to the computer, switch to the layer and start typing.

Examples of some letters I’d like to exist (say on layer 3) - ( क ख त्र क्ष फ ण … ) One can also imagine a layer dedicated to typing out emojis !

I can’t seem to find a straightforward way to do this in Chrysalis, or perhaps I’m not properly familiar with it yet I bet this is something that’s already been done by somebody in the community.

How do I go about adding this layer ? I’d appreciate any pointers.

@jesse any pointers to where I can start looking/reading up more into this ?

The very short version is that the USB Keyboard specification just isn’t set up for this. Currently typing unicode characters is a platform-specific hack or something that requires special drivers on the host side. The hid-io project (HID-IO · GitHub) aims to change that, but isn’t production ready yet. When it is, we hope to support it.

3 Likes

oh alright ! I was really hoping that this was do-able. Thanks for the project links.

I want to do a very similar thing: somehow use free layers, #3 and #4, for APL and BQN language glyphs (like, ×÷⋆√⁼˙‿⌽↕8≠≤≢𝔽○𝔾…). I’m on a mac.

I don’t really understand Chrsyalis, or how keyboards/key codes/keylayout files/unicode works.

Would something like, use Chrysalis to assign a “Custom key code” to, say layer #3 “A” key, and then use Ukelele (or, maybe it has to be done by hand) to create a new keyboard keylayout file that maps that key code to the unicode char I want, like ⟜, or whatever.

Your Brest bet could be the «unicode» plugin, or if you nées characters chat are already part on the keyboard layout used by your os you could fond the light custom code from Chrysalis…
(Excuse me for the fuzziness of this answer, but I’m not un front of a computer)

Thanks @Rom1deTroyes. I’ll look into it. Are there hold-my-hand instructions for the unicode plugin?

More generally, is there a good introduction/tutorial to keyboards/usb protocol/scan codes/os keyboard layout maps (Mac/Linux)/Chrysalis/Kaleidoscope/Atreus that would help me become self-sufficient?

For example, this Mac keylayout file is available from the BQN project. I’m pretty sure the file is intended for a standard/normal keyboard. I don’t know enough to adapt it to my Atreus. Specifically, I want to add these characters to unused layers. At least, I think I do. I don’t even know enough to know if this is the right approach, or if I’m asking the right questions. :grimacing:

The “custom key code” in Chrysalis is not, alas, something that gets sent to the host operating system, so this strategy won’t work. Fundamentally, what you need to do is first determine what input sequence will result in the character(s) you want, then use the available tools/code in Kaleidoscope to emulate that from a single keystroke (probably using either Macros or Unicode plugins).

Ok. I’m starting to catch on.

I finally got the Arduino IDE and the Kaleidoscope project/sketch/firmware, and started a little hacking.

I got the unicode plugin working on my Mac … sort of.

It works for regular apps, as far as I can tell, but not in the Terminal. The problem seems to be that, in the Terminal, I opt for “Use Option as Meta key” because I use it constantly for things like emacs and readline-style editing. On the Mac, the “Unicode Hex Input” works by holding the option key while you type the unicode hex code point number. This is what the Kaleidoscope unicode plugin automates for you.

Ahhhhhhhhhhhh … so close!

If I don’t opt for “Use Option as Meta key” in the Terminal, when I use the Alt/Option/Meta key, I get the Apple-defined special characters like Alt-f gives ƒ, and Alt-b gives ∫, when what I really want is move forward/backward one word. Even if I was able to “fix” this behavior with a custom Mac keylayout file, I still could not use Alt/Option as Meta and, at the same time, be able to use the Mac “Unicode Hex Input”.

I cannot see how to get the behavior I want. That is, I want to have a couple of layers full of keys that type unicode characters that will work everywhere, especially in the terminal, and will not conflict with the Meta key.

It seems like there are just not enough scan codes and modifiers to cover all the characters you might want. I seems like a solution would be to find dozens of not-used scan codes/modifiers to send from the keyboard, and then map them to the unicode character on the OS side with a keylayout file.

Any ideas?

Getting unicode characters to work everywhere on Mac OS, with the same input sequences, is effectively impossible, alas (not all apps use the Cocoa input system, and Apple seems almost hostile to using a Compose key). For your specific problem with the Terminal app, for just a few keys (e.g. option+b & option+f), you could have it translate those into a sequence that actually sends escape, then the target key (first toggling off option, then restoring it again once the sequence has finished).

Many Linux apps (incl. GTK+ and QT) allow to hold ctrl+shift, then tap u plus the hex code, then release to get unicode. According to this website, windows allows the same with holding Alt, then tapping + on the numpad plus the hexcode of the char, then release. Yes, it does require a registry key change, but that seems to be acceptable for me.

Now, if I now could somehow send one sequence under Linux and another under Windows…

Chrysalis can’t do that yet. Dropping down to firmware, the Unicode plugin might be of help. It’s not perfect, but it gets you pretty far along the way.