1

I got this fancy new USB keyboard with n-key rollover for the holidays. The one thing that has been bugging me is that I can no longer get to the virtual keyboards from X11/Xorg with this keyboard. With both old and new keyboards plugged in at the same time, I can tell that I can still use the old keyboard to switch to the terminal just fine. Also, I can use xev to verify that the XF86Switch_VT_1 keysym is being generated. (see below). From what I've read elsewhere, the problem comes from the fact that the keyboard has to pretend it is multiple keyboards on USB because the USB standard only allows 6-key rollover per keyboard.

Is there any known workarounds to get this to work?

KeyRelease event, serial 40, synthetic NO, window 0x5000001,
    root 0x29e, subw 0x0, time 5626057, (675,-26), root:(679,936),
    state 0xc, keycode 67 (keysym 0x1008fe01, XF86Switch_VT_1), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False
  • 1
    what keyboard model? – quixotic Jan 1 '18 at 6:24
  • And if that keysym is being generated, as you have verified, what makes you think that it is not and that the keyboard is at fault? – JdeBP Jan 1 '18 at 7:22
  • @quixotic KUL ES-87 – Jacob Brown Jan 1 '18 at 14:29
  • @JdeBP Both the old keyboard and new keyboard generate the keysym as seen by the xev command. But for whatever reason, Xorg only seems to switch to the Linux console terminal when all three of the keys that make up the keysym come from the same keyboard. Since the n-key rollover keyboard acts like some of the keys come from different keyboards, then Xorg isn't letting me switch to a Linux terminal from my new keyboard. This is the problem that I'm trying to find a workaround for. – Jacob Brown Jan 1 '18 at 14:32
  • if that's the case evtest should be able to verify and determine which input devices are producing which keysyms. – quixotic Jan 1 '18 at 15:33
0

I have DELL Laptop with same problem

Try this:

Ctrl + alt + [n] + F1

  • It's not a problem of requiring an additional key. As you can see, the XF86Switch_VT_1 keysym is being generated from the new keyboard. For whatever reason, Xorg is ignoring it because it thinks the keys are coming from multiple keyboards because the n-key roller must act as multiple keyboards since USB only supports 6-key rollover per keyboard. – Jacob Brown Jan 1 '18 at 14:35
0

XKB workaround

Since your F# keys are coming across on a different logical device than the Ctrl+Alt keys, altering your XKB layout to generate those keysyms on some of your regular keys might be a reasonable workaround. Test keys with evdev to make sure they're on the same input; the example below assumes the number keys will be. Caveats to consider:

  • xkbcomp will not work under Wayland, and GNOME-based desktop environments may reset keyboard settings, so use a basic window manager for testing. If this solution works, it can be rewritten as an XKB option or layout variant, placed into the system XKB database, and configured by whatever means your DE provides.

  • You may be able to use ckbcomp to generate a console keymap with these changes, or you may find the console's Ctrl+F2 functions properly so modifications are unneeded. Or you may need to get friendly with loadkeys.

  • Some applications may already define hotkeys such as Ctrl+Alt+2; I don't know how they might interact with this layout.

Given all these factors, this is definitely an ugly hack. Fixing the issue at a lower layer (eg, by evdev merging the two inputs into one before acting on them) would be preferable.


First, generate a basic keymap, with setxkbmap -print; then we'll edit this file and add overrides to it, and finally load the altered keymap with xkbcomp [file] $DISPLAY:

$ setxkbmap -print > mykeymap.xkb
xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)" };
    xkb_types     { include "complete"  };
    xkb_compat    { include "complete"  };
    xkb_symbols   { include "pc+us(altgr-intl)+inet(evdev)" };
    xkb_geometry  { include "pc(pc105)" };
};

Generate a full keymap with xkbcomp to find the original symbols in your layout. Don't worry too much if symbols are a little different in your layout; as long as they are four-level or fewer this should work.

$ xkbcomp $DISPLAY - > origkeymap.xkb
#         (from)  (to)

// the # keys on a typical PC keyboard are AE01,AE02,...,AE09,AE10
// in the xkb_symbols section you'll find these:
    key <AE01> {
        type= "FOUR_LEVEL",
        symbols[Group1]= [ 1, exclam, onesuperior, exclamdown ]
    };

Now edit mykeymap.xkb and place the overrides we need into it:

// Attempting to place XF86Switch_VT_N keysyms on 1-0.
//
// starting point: setxkbmap -layout us -variant altgr-intl -option '' -print
// load this file: xkbcomp mykeymap.xkb $DISPLAY
xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)" };
    xkb_types     { include "complete"      };
    xkb_compat    { include "complete"      };
    xkb_symbols   { 
        include "pc"
        include "us(altgr-intl)"
        include "inet(evdev)"

        // redefine numeric keys
        key <AE01> {
            type= "CTRL+ALT",
            symbols[Group1]= [ 1, exclam, onesuperior, exclamdown, XF86Switch_VT_1 ]
        };
        key <AE02> {
            type= "CTRL+ALT",
            symbols[Group1]= [ 2, at, twosuperior, dead_doubleacute, XF86Switch_VT_2 ]
        };
        key <AE03> {
            type= "CTRL+ALT",
            symbols[Group1]= [ 3, numbersign, threesuperior, dead_macron, XF86Switch_VT_3 ]
        };
        key <AE04> {
            type= "CTRL+ALT",
            symbols[Group1]= [ 4, dollar, currency, sterling, XF86Switch_VT_4 ]
        };
        key <AE05> {
            type= "CTRL+ALT",
            symbols[Group1]= [ 5, percent, EuroSign, dead_cedilla, XF86Switch_VT_5 ]
        };
        key <AE06> {
            type= "CTRL+ALT",
            symbols[Group1]= [ 6, asciicircum, dead_circumflex, onequarter, XF86Switch_VT_6 ]
        };
        key <AE07> {
            type= "CTRL+ALT",
            symbols[Group1]= [ 7, ampersand, dead_horn, onehalf, XF86Switch_VT_7 ]
        };
        key <AE08> {
            type= "CTRL+ALT",
            symbols[Group1]= [ 8, asterisk, dead_ogonek, threequarters, XF86Switch_VT_8 ]
        };
        key <AE09> {
            type= "CTRL+ALT",
            symbols[Group1]= [ 9, parenleft, leftsinglequotemark, dead_breve, XF86Switch_VT_9 ]
        };
        key <AE10> {
            type= "CTRL+ALT",
            symbols[Group1]= [ 0, parenright, rightsinglequotemark, dead_abovering, XF86Switch_VT_10 ]
        };

    };
    xkb_geometry  { include "pc(pc105)"     };
};

Now you can load this file and test the keys:

# load keymap for all keyboards
$ xkbcomp mykeymap.xkb $DISPLAY

# load only on device id=# (see `xinput -list`)
$ xkbcomp -i # mykeymap.xkb $DISPLAY

This won't change the console keymap, so switching back may require that other keyboard.

If testing shows that these keys work, and aren't trampling other uses of those key combinations, you can make this permanent by your favorite XKB modification method.

  • this is truly ugly and should be considered a temporary workaround at most, or just a cautionary tale of when not to fix it with XKB. a kernel mod/evdev/libinput level solution would be much better. – quixotic Jan 2 '18 at 1:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.