Confusion with composing international characters

Hallo!

I’m attempting a fork of @algernon’s Hungarian language pack. So far, with some success, but then again, my successful modifications have all been trivial. It’s 3AM, so I decided to throw in the towel and ask for help!

I’ve gotten ä, ö, and ü (and their capitalized variants) to work properly, but the ß eludes me. While typing each key in the following keymap snippet

R(DEU_AU),   R(DEU_OU),   R(DEU_UU),   R(DEU_SSch),

I get the following output:

äöüs

It’s odd that the ones requiring three keystrokes work, whereas the one requiring only two does not. Frustrating. Hoping it’s very straightforward and only a mystery because I’m completely inexperienced in C++. My Java background only got me so far.

Here’s my eventHandlerHook method at the current revision. Below is the whole snippet:

German::eventHandlerHook
German::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) {
  if (mapped_key.raw < GERMAN_FIRST || mapped_key.raw > GERMAN_LAST)
    return mapped_key;

  if (!keyToggledOn(key_state))
    return Key_NoKey;

  bool need_shift = Keyboard.isModifierActive(Key_LeftShift.keyCode) ||
                    ::OneShot.isModifierActive(Key_LeftShift);

  tap_key(Key_RightAlt.keyCode);

  GermanSymbol symbol = (GermanSymbol)(mapped_key.raw - GERMAN_FIRST);
  Key accent;
  uint8_t kc = 0;

  accent.flags = KEY_FLAGS;
  accent.keyCode = Key_Quote.raw;

  switch (symbol) {
  case AU:
    kc = Key_A.keyCode;
	accent.flags |= SHIFT_HELD;
    break;
  case OU:
    kc = Key_O.keyCode;
    accent.flags |= SHIFT_HELD;
    break;
  case UU:
    kc = Key_U.keyCode;
    accent.flags |= SHIFT_HELD;
    break;
  case SS:
    kc = Key_S.keyCode;
	break;
  }

  if (accent.flags & SHIFT_HELD)
    Keyboard.press(Key_LeftShift.keyCode);
  else
    Keyboard.release(Key_LeftShift.keyCode);
  Keyboard.sendReport();

  tap_key(accent.keyCode);

  if (need_shift)
    Keyboard.press(Key_LeftShift.keyCode);
  else
    Keyboard.release(Key_LeftShift.keyCode);

  tap_key(kc);

  return Key_NoKey;
}

I greatly appreciate any insights!

You’ll need to change accent.keyCode in the DEU_SSch branch to Key_S.keyCode, I think. A quick test suggests that to input ß, you need to input AltGr s s. Without changing accent.keyCode, AltGr ' s would be sent. Mind you, that should end up as ś, not s, but perhaps there’s something else going on too.

Nevertheless, I’d give it a try, and set accent.keyCode too.

Hope this helps!

1 Like

Thanks! I’ve learned a lot from this exercise. TL;DR: my “compose” key behaves like a modifier (needs to be held down). Solutions: 1) modify the plugin to hold the AltGr key rather than tap it, 2) make custom OS-side keyboard layout. Portability is broken.


I see that your suggestion AltGr s s is mentioned as an example at this Wikipedia page, but on my OS-side layout it’s just AltGr s. I can confirm that RALT(Key_S) in the keymap produces ß as expected.

I’ve learned that there are two ways to “compose”:

  1. Hold AltGr
  2. Tap the accent key
  3. Tap the base key
  4. Release AltGr

And:

  1. Tap AltGr
  2. Tap the accent key
  3. Tap the base key

This is the part where I start getting angry.

TAP TAP TAP worked for ä, ö, and ü but not for ß. Output: äöüs
HOLD TAP TAP RELEASE worked for ß but not for ä, ö, and ü. Output: `a`o`uß

In my anger I considered that one possible solution was to eliminate the German language from the face of the earth. Happily for the Germans on the brink of being language-less, I caved in and created my own layout with MSKLC (it seems to still work on Windows 10). It’s identical to the US layout, but with a few more definitions on the AltGr and Shift+AltGr.

Really, the worst part of all this is that even though it works perfectly for me, I can no longer expect my plugin to be useful to others. I was hoping to contribute this plugin to the community, but unless someone can tell me how to make it universally useful again, I’ll just have to bundle it into my .ino file.