用XKB声明一个新的修改键


12

我正在尝试创建单手键盘布局,并希望Hyper在按某些键时用来产生特殊键。

例如,当我按Hyper_L和时B,我希望XKB产生XF86AudioRaiseVolume

相关部分来自custom_2.kbd (完整代码位于http://pastebin.com/gm8cggn3):

xkb_keycodes {
    <K_36> = 54;        // b B XF86AudioRaiseVolume
    <K_85> = 133;       // Hyper_L
};

xkb_symbols {
    key <K_36> { type = "HYPER_LEVEL", [ b, B, XF86AudioRaiseVolume ] };
    key <K_85> { type = "ONE_LEVEL", [ Hyper_L ] };
};

xkb_compatibility {
    interpret Hyper_L { action = SetMods(modifiers=Hyper); };
};


xkb_types {
type "HYPER_LEVEL" {
    modifiers= Shift+Hyper;
    map[Shift]= Level2;
    map[Hyper]= Level3;
    map[Shift+Hyper]= Level3;
};
};

对我来说似乎很好,但是当我尝试时:

~$ xkbcomp custom_2.kbd $DISPLAY
Error:            Identifier "Hyper" of type int is unknown
Error:            Key type mask field must be a modifier mask
                  Key type definition ignored
Warning:          Map entry for unused modifiers in HYPER_LEVEL
                  Using none instead of Shift
Error:            Identifier "Hyper" of type int is unknown
Error:            The key type map entry field must be a modifier mask
                  Ignoring illegal assignment in HYPER_LEVEL
Error:            Identifier "Hyper" of type int is unknown
Error:            The key type map entry field must be a modifier mask
                  Ignoring illegal assignment in HYPER_LEVEL
 -> 1

(错误代码为1)

现在我被卡住了。有谁知道如何进行这项工作?没有的解决方案Hyper可以。

编辑

通过将Superand 更改HyperMod4and Mod5,该错误消失了:

~$ xkbcomp custom_3.kbd
( no output )

~$ diff custom_{2,3}.kbd
188,190c188,190
<         interpret Super_L { action = SetMods(modifiers=Super); };
<         interpret Hyper_L { action = SetMods(modifiers=Hyper); };
<     }c;
---
>         interpret Super_L { action = SetMods(modifiers=Mod4); };
>         interpret Hyper_L { action = SetMods(modifiers=Mod5); };
>     };
204c204
<             modifiers= Shift+Hyper;
---
>             modifiers= Shift+Mod5;
206,207c206,207
<             map[Hyper]= Level3;
<             map[Shift+Hyper]= Level3;
---
>             map[Mod5]= Level3;
>             map[Shift+Mod5]= Level3;

但是,它仍然不起作用:

~$ xkbcomp custom_3.kbd $DISPLAY 
Error:            success in unknown
                  Couldn't write keyboard description to :0.0
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  135 (XKEYBOARD)
  Minor opcode of failed request:  9 (XkbSetMap)
  Value in failed request:  0x8010202
  Serial number of failed request:  12
  Current serial number in output stream:  14
 -> 1 

Answers:


9

我自己仍然与XKB有一些(我认为不相关)问题,但是我确实映射了Hyper修改器,并且我相信相关设置如下:

兼容:

virtual_modifiers Shift,Control,Meta,Super,Hyper,AltGr;

interpret Hyper_R { action = SetMods(modifiers=Mod4); };

符号:

modifier_map Mod4 { <DELE> }; // Hyper
key <DELE>  { type="UNMODIFIED", [ Hyper_R ], repeat=no  };

然后像

key <K_36> { type = "SHIFT+HYPER", [ b, B, 
                                XF86AudioRaiseVolume, XF86AudioRaiseVolume ] };

类型

virtual_modifiers Meta,AltGr,Super,Hyper,Mod5;

除非您也使用它,否则不需要那里的Mod5。但同样,在此省略Shift&Control…

type "SHIFT+HYPER" {
    modifiers= Shift+Hyper;
    map[Shift]= Level2;
    map[Hyper]= Level3;
    map[Shift+Hyper]= Level4;
};

就其价值而言,我试图重新定义几何图形和键码的麻烦远远超过其应有的麻烦,并且尽管其中许多是可笑的错误命名,但最终还是恢复了形式上的pc105键符号<AE01>。(例如<DELE>我的超级密钥)

PS。有关工作示例,请参阅https://github.com/brpocock/spacey-cadet-keyboard ...


非常感谢。仍在解决一些问题,但是效果很好!
Lennart_96
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.