You are not logged in.

#1 2020-05-26 13:45:21

SalM
Member
Registered: 2020-05-26
Posts: 1

[SOLVED] X keyboard extension ignores third layer modifier

I wanted to add layer functionality to my keyboard, so after reading the wiki and the documentation referenced I decided it would be best to
separate the layers into groups:

  partial alphanumeric_keys
  xkb_symbols "lenovo.personal"{

     name[group1]="Alphabetic Layer";
     name[group2]="Number Layer";
  
     //Top Row
     key.type = "ONE_LEVEL";
     key <AB01> { symbols[group1]= [             Tab ] };
     key.type = "TWO_LEVEL";
     key <AB02> { symbols[group1]= [       semicolon,           colon ], symbols[group2]= [        asterisk,        asterisk ] };
     key <AB03> { symbols[group1]= [           comma,            less ], symbols[group2]= [               1,               1 ] };
     key <AB04> { symbols[group1]= [          period,         greater ], symbols[group2]= [               2,               2 ] };
     key <AB05> { symbols[group1]= [               p,               P ], symbols[group2]= [               3,               3 ] };
     key <AB06> { symbols[group1]= [               y,               Y ], symbols[group2]= [            plus,            plus ] };
     key <AB07> { symbols[group1]= [               f,               F ], symbols[group2]= [            less,            less ] };
     key <AB08> { symbols[group1]= [               g,               G ], symbols[group2]= [               A,               a ] };
     key <AB09> { symbols[group1]= [               c,               C ], symbols[group2]= [               B,               b ] };
     key <AB10> { symbols[group1]= [               r,               R ], symbols[group2]= [               C,               c ] };
     key <AB11> { symbols[group1]= [               l,               L ], symbols[group2]= [             bar,             bar ] };
     key <AB12> { symbols[group1]= [           slash,        question ] };
     key <AB13> { symbols[group1]= [              at,     asciicircum ] };
     key <AB14> { symbols[group1]= [       backslash,             bar ] };
  


     //Home Row
     key.type = "TWO_LEVEL";
     key <AC01> { symbols[group1]= [       BackSpace,      dead_grave ] };
     key <AC02> { symbols[group1]= [               a,               A ], symbols[group2]= [               0,               0 ] };
     key <AC03> { symbols[group1]= [               o,               O ], symbols[group2]= [               4,               4 ] };
     key <AC04> { symbols[group1]= [               e,               E ], symbols[group2]= [               5,               5 ] };
     key <AC05> { symbols[group1]= [               u,               U ], symbols[group2]= [               6,               6 ] };
     key <AC06> { symbols[group1]= [               i,               I ], symbols[group2]= [          period,          period ] };
     key <AC07> { symbols[group1]= [               d,               D ], symbols[group2]= [           equal,           equal ] };
     key <AC08> { symbols[group1]= [               h,               H ], symbols[group2]= [               D,               d ] };
     key <AC09> { symbols[group1]= [               t,               T ], symbols[group2]= [               E,               e ] };
     key <AC10> { symbols[group1]= [               n,               N ], symbols[group2]= [               F,               f ] };
     key <AC11> { symbols[group1]= [               s,               S ], symbols[group2]= [           colon,            colon ] };
     key <AC12> { symbols[group1]= [           minus,      underscore ] };
     key.type = "ONE_LEVEL";
     key <AC13> { symbols[group1]= [          Return ] };

     //Bottom Row
     key.type = "ONE_LEVEL";
     key <AD01> { symbols[group1]= [         Shift_L ] };
     key.type = "TWO_LEVEL";
     key <AD02> { symbols[group1]= [      apostrophe,        quotedbl ], symbols[group2]= [           slash,      VoidSymbol ] };
     key <AD03> { symbols[group1]= [               q,               Q ], symbols[group2]= [               7,      VoidSymbol ] };
     key <AD04> { symbols[group1]= [               j,               J ], symbols[group2]= [               8,      VoidSymbol ] };
     key <AD05> { symbols[group1]= [               k,               K ], symbols[group2]= [               9,      VoidSymbol ] };
     key <AD06> { symbols[group1]= [               x,               X ], symbols[group2]= [           minus,      VoidSymbol ] };
     key <AD07> { symbols[group1]= [               b,               B ], symbols[group2]= [         greater,      VoidSymbol ] };
     key <AD08> { symbols[group1]= [               m,               M ], symbols[group2]= [      numbersign,      VoidSymbol ] };
     key <AD09> { symbols[group1]= [               w,               W ], symbols[group2]= [       ampersand,      VoidSymbol ] };
     key <AD10> { symbols[group1]= [               v,               V ], symbols[group2]= [           comma,      VoidSymbol ] };
     key <AD11> { symbols[group1]= [               z,               Z ], symbols[group2]= [       semicolon,      VoidSymbol ] };
     key.type = "ONE_LEVEL";
     key <AD12> { symbols[group1]= [         Meta_R ],   virtualMods= Meta};
 
     // This is used to avoid the shift + delete issue
     key <FDEL> { symbols[group1]= [          Delete ] };

  };

The layouts have worked just as I intended. However, sxhkd ignores the groups and directly interacts with the keycode that the keysym is tied to.
For example: if I map super + 5 to focus on desktop 5; sxhkd will shift desktop focus if I hit super + <AC03>.

So I decided to change the keymap file hoping that by making the layers actual layers instead of groups sxhkd would properly again.
I followed these steps on the wiki https://wiki.archlinux.org/index.php/X_ … ion#Level3 and modified my keymap file:

  xkb_types "complete" {
    virtual_modifiers Alt,Meta,Super;

    type "ONE_LEVEL" {
        modifiers= none;
        level_name[Level1]= "Any";
    };
  
    type "TWO_LEVEL" {
        modifiers= Shift;
        map[Shift]= Level2;
        level_name[Level1]= "Base";
        level_name[Level2]= "Shift";
    };
  
    type "ALPHABETIC" {
        modifiers= Shift+Lock;
        map[Shift]= Level2;
        map[Lock]= Level2;
        level_name[Level1]= "Base";
        level_name[Level2]= "Caps";
    };
     
    type "THREE_LEVEL" {
        modifiers= Shift+Mod3;
        map[Shift]= Level2;
        map[Mod3]= Level3;
        map[Shift+Mod3]= Level3;
        level_name[Level1]= "Base";
        level_name[Level2]= "Shift";
        level_name[Level3]= "Num";
    };
  };

  xkb_compatibility "complete" {

    virtual_modifiers Alt,Meta,Super;

    interpret.useModMapMods= AnyLevel;
    interpret.repeat= False;
    interpret.locking= False;

    interpret Shift_L+AnyOf(all) {
       action= LatchMods(modifiers= Shift, clearLocks, latchToLock);
    };
    
    interpret Shift_L+AnyOfOrNone(all) {
        action= LatchMods(modifiers= Shift, clearLocks, latchToLock);
    };
    
    interpret Meta_R+AnyOf(all) {
        action= LatchMods(modifiers= Mod3, clearLocks, latchToLock);
    };
    
    interpret Meta_R+AnyOfOrNone(all) {
        action= LatchMods(modifiers= Mod3, clearLocks, latchToLock);
    };

    // Do this to fix the shift + delete issue
    interpret dead_grave{
        repeat= True;
        action= RedirectKey(keycode= <FDEL>, clearmodifiers= Shift);
    };
  };

  partial alphanumeric_keys
  xkb_symbols "lenovo.personal"{

    name[group1]= "Custom";
 
    // Top Row
    key.type = "ONE_LEVEL";
    key <AB01> { [             Tab ] };
    key.type = "THREE_LEVEL";
    key <AB02> { [       semicolon,           colon,        asterisk ] };
    key <AB03> { [           comma,            less,               1 ] };
    key <AB04> { [          period,         greater,               2 ] };
    key <AB05> { [               p,               P,               3 ] };
    key <AB06> { [               y,               Y,            plus ] };
    key <AB07> { [               f,               F,            less ] };
    key <AB08> { [               g,               G,               A ] };
    key <AB09> { [               c,               C,               B ] };
    key <AB10> { [               r,               R,               C ] };
    key <AB11> { [               l,               L,             bar ] };
    key.type = "TWO_LEVEL";
    key <AB12> { [           slash,        question ] };
    key <AB13> { [              at,     asciicircum ] };
    key <AB14> { [       backslash,             bar ] };
  

    // Home Row
    key.type = "TWO_LEVEL";
    key <AC01> { [       BackSpace,      dead_grave ] };
    key.type = "THREE_LEVEL";
    key <AC02> { [               a,               A,               0 ] };
    key <AC03> { [               o,               O,               4 ] };
    key <AC04> { [               e,               E,               5 ] };
    key <AC05> { [               u,               U,               6 ] };
    key <AC06> { [               i,               I,          period ] };
    key <AC07> { [               d,               D,           equal ] };
    key <AC08> { [               h,               H,               D ] };
    key <AC09> { [               t,               T,               E ] };
    key <AC10> { [               n,               N,               F ] };
    key <AC11> { [               s,               S,           colon ] };
    key.type = "TWO_LEVEL";
    key <AC12> { [           minus,      underscore ] };
    key.type = "ONE_LEVEL";
    key <AC13> { [          Return ] };
  
    // Bottom Row
    key.type = "ONE_LEVEL";
    key <AD01> { [         Shift_L ] };
    key.type = "THREE_LEVEL";
    key <AD02> { [      apostrophe,        quotedbl,           slash ] };
    key <AD03> { [               q,               Q,               7 ] };
    key <AD04> { [               j,               J,               8 ] };
    key <AD05> { [               k,               K,               9 ] };
    key <AD06> { [               x,               X,           minus ] };
    key <AD07> { [               b,               B,         greater ] };
    key <AD08> { [               m,               M,      numbersign ] };
    key <AD09> { [               w,               W,       ampersand ] };
    key <AD10> { [               v,               V,           comma ] };
    key <AD11> { [               z,               Z,       semicolon ] };
    key.type = "ONE_LEVEL";
    key <AD12> { [         Meta_R ],   virtualMods= Meta};
    
    // This is used to avoid the shift + delete issue
    key.type = "ONE_LEVEL";
    key <FDEL> { [          Delete ] };
  };

After doing that and compiling the code using xkbcomp and not getting issues, I pushed the code into my server using:

xkbcomp myMapFile.xkb $DISPLAY

and this error got printed out:

X Error of failed request: BadAtom (invalid Atom parameter)
 Major opcode of failed request: 135 (Xkeyboard)
 Minor opcode of failed request: 18 (XkbSetNames)
 Atom id in failed request: 0x31304b46
 Serial number of failed request: 30
 Current serial number in output stream: 32

I thought it might be because of my compatibility_map, so I tried:

    interpret Meta_R+AnyOf(all) {
         virtualModifier= Meta;
         action= LatchMods(modifiers=modMapMods, clearLocks, latchToLock);
    };
    
    interpret Meta_R+AnyOfOrNone(all) {
        action= LatchMods(modifiers= Meta, clearLocks, latchToLock);
    };

-----------------------------------------------------------------------------------------------------------------

    interpret Meta_R+AnyOf(all) {
        virtualModifier= Meta;
        action= LatchMods(modifiers= Meta, clearLocks, latchToLock);
    };
    
    interpret Meta_R+AnyOfOrNone(all) {
        action= LatchMods(modifiers= Meta, clearLocks, latchToLock);
    };

-----------------------------------------------------------------------------------------------------------------

    interpret Meta_R+AnyOf(all) {
        action= LatchMods(modifiers= Mod3, clearLocks, latchToLock);
    };
    
    interpret Meta_R+AnyOfOrNone(all) {
        action= LatchMods(modifiers= Mod3, clearLocks, latchToLock);
    };

And none of them made a difference. So I tried modifying my types_map:

    type "THREE_LEVEL" {
        modifiers= Shift+Meta;
        map[Shift]= Level2;
        map[Meta]= Level3;
        map[Shift+Meta]= Level3;
        level_name[Level1]= "Base";
        level_name[Level2]= "Shift";
        level_name[Level3]= "Num";
    };

-----------------------------------------------------------------------------------------------------------------

    type "THREE_LEVEL" {
        modifiers= Shift+Mod3;
        map[Shift]= Level2;
        map[Mod3]= Level3;
        map[Shift+Mod3]= Level3;
        level_name[Level1]= "Base";
        level_name[Level2]= "Shift";
        level_name[Level3]= "Num";
    };

The only difference this made was that both the Serial number of failed request & Current serial number in output stream
have been reduced by 2. So I just searched the Xkb Library Specification for keywords used in the error message I received
and I didn't find anything mentioning the error. I honestly didn't want to spend the next couple of weeks trying to understand the
documentation to language I don't understand just to get my keyboard working again. So if someone can please help me with
trying to fix my keymap, I would be very grateful.

UPDATE:
I managed to get the third/number layer working after modifying my types and compatibility maps:

  xkb_types "complete" {

     virtual_modifiers Alt,Meta,Super;
     
     type "THREE_LEVEL" {
         modifiers= Shift+Mod3;
         map[Shift]= Level2;
         map[Mod3]= Level3;
         map[Shift+Mod3]= Level3;
         level_name[Level1]= "Base";
         level_name[Level2]= "Shift";
         level_name[Level3]= "Num";
     };
  };

-----------------------------------------------------------------------------------------------------------------
  xkb_compatibility "complete" {

     virtual_modifiers Alt,Meta,Super;

     interpret.useModMapMods= AnyLevel;
     interpret.repeat= False;
     interpret.locking= False;
    
     interpret Meta_R+AnyOf(all) {
         virtualModifier= Meta;
         action= LatchMods(modifiers= modMapMods, clearLocks, latchToLock);
     };
    
     interpret Meta_R+AnyOfOrNone(all) {
         action= LatchMods(modifiers= Meta, clearLocks, latchToLock);
     };
    
  };

However the error code still shows up whenever it I try to push in the server, but since the keymap works I'll mark
this topic as solved.

Also, since I did this to make sxhkd work with multiple layers, If you want to access the third layer layer you
will need have the keybinding be the modifier that accesses the third layer + the first layer symbol.
For example:

# If you want to bind super + 0

# This doesn't work
super + 0
    # command here

# This works
super + mod3 + a
    # command here

If anyone can tell me where to post this tip instead of having it at the bottom of an obscure topic; It will be very appreciated.

Last edited by SalM (2020-05-27 05:59:19)

Offline

Board footer

Powered by FluxBB