Custom keyboard mangled in latest version

Asked by Antonios Hadjigeorgalis on 2016-09-03

I created a custom keyboard that looks like my TypeMatrix keyboard. I don't use the software frequently. However, when I opened onboard after upgrading to 16.04 the custom keyboard now has the letters jumbled in the wrong location. When I first created the keyboard it worked as expected.

Question information

Language:
English Edit question
Status:
Solved
For:
Onboard Edit question
Assignee:
No assignee Edit question
Solved by:
marmuta
Solved:
2016-09-05
Last query:
2016-09-05
Last reply:
2016-09-04

And here is a link to an image of what the keyboard is showing up as.
https://dl.dropboxusercontent.com/u/33784145/images/onboard.png
The shift, return, delete, space, tab, backspace keys are correctly located.

marmuta (marmuta) said : #3

Keys defined with the "keycode" attribute adapt to the active key map and group (aka input source). If you created the TM-dvorak while having en active and then later switched your system to a different key map, then Onboard's keys would change accordingly.

With system key map 'en' the keys seem to match the ids in the svg file, so I suppose this is how you meant to create them. What is your current xkb configuration?
setxkbmap -query

Yes, you are correct. When I created the keyboard my text entry setting was set to English (US) and the jumbled keyboard showed up when launching Onboard with the setting English (Dvorak).

Where can I find the most complete documentation on creating layouts? I notice that the all-keys layout includes different id codes than what I used in my custom layout. The all-keys also changes correctly when I change text entry setting from English(US) to English(Dvorak).

One additional bit of information:
The Typematrix keyboard I am using has the ability to send either QWERTY or DVORAK key codes with a hardware switch on the keyboard. I am using it in the mode of sending regular QWERTY key codes and having the Ubuntu text entry settings do the translation. In other words, the way I am currently set up it should appear to the operating system as a standard US keyboard.

setxkbmap -query => when set to English (US)
rules: evdev
model: pc105
layout: us
options: terminate:ctrl_alt_bksp

setxkbmap -query => when set to English (Dvorak)
rules: evdev
model: pc105
layout: us,us
variant: dvorak,
options: terminate:ctrl_alt_bksp

Best marmuta (marmuta) said : #5

There is some information in the help of Onboard >=1.2, but IIRC it's far from complete. The best advice I have is to ask here and/or look at existing layouts and source code (LayoutLoaderSVG.py).

I think you should switch your system to the us qwerty keymap and then assign keycodes to your Onboard layout for qwerty. Those will largely be the same keycodes as are defined in Onboard's default layouts. I wouldn't even keep dvorak in the name of the layout, it's just TM.onboard for example.

When done, switch your system to us(dvorak) and check what's left to be done. If any keys are wrong, add exceptions for those (hopefully few) keys only. For example:

    <key group="alphanumeric" id="h" keycode="43" sticky="false"/>
    <key group="alphanumeric" id="h" keycode="34" sticky="false" layout="us(dvorak)"/>

That would assign keycode 34 only when the us(dvorak) keymap is active. Small.onboard and Phone.onboard use these exceptions quite a bit for Cyrillic support, just search for "layout" if you need more examples.

If you do this, both, TM in Onboard and your physical Typematrix (set to QWERTY) should behave the same and you are free to choose between us and us(dvorak) by software (keymap). Most other languages keymaps and dvorak variants will more or less work as well, although some will require further exceptions.

There are other, more rigid ways to specify what keys should type, i.e. replace "keycode" with "keysym" or "char" (Unicode character). Those won't change with keymaps, but to me that's more a disadvantage. Also handling modifiers (SHIFT,...) becomes tricky. I recommend the above approach with keycodes.

marmuta (marmuta) said : #6

BTW, are you interested in having this layout added to the Onboard project? It would appear in the Contributions section in Preferences->Layout. You keep copyright, and your Name and email would appear in the about dialog for the layout (optional, only if you want that). Would you be OK with licensing it under GPLv3?

Thank you for the additional information. I would be happy to contribute and license under GPLv3. It may take me a while to get it all working, I'm in the middle of several projects at the moment.

On my machine onboard only displays the keyboard. If I click the keys with the cursor in a text field no letters are typed on screen and the keys turn purple for 1 second, then the delete key only turns purple, then all other keys, then the delete key again.

Thanks marmuta, that solved my question.