根据密钥所在的设备映射密钥? (Linux)

发布于 2024-09-27 08:34:53 字数 1477 浏览 8 评论 0原文

我拥有一个 Razer Naga 鼠标,本质上它有一个侧面有一个小数字键盘。我想将这些键重新映射到不同的未使用的键或 bash 命令。我可以通过使用 xev 获取键码(例如鼠标上的“1”是键码 87)来轻松完成此操作,然后我可以使用 xmodmap 将键码绑定到不同的键。

然而,我键盘上的小键盘也会继承这一点,因为键码是相同的,但我注意到“串行”是不同的。

例如,这是当按下鼠标小键盘上的“1”按钮时 xev 的输出。

KeyPress event, serial 34, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2179878, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes: 
XmbLookupString gives 0 bytes: 
XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2179966, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes: 
XFilterEvent returns: False

这是在键盘数字键盘上按“1”时的输出

KeyPress event, serial 35, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2180261, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes: 
XmbLookupString gives 0 bytes: 
XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2180341, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes: 
XFilterEvent returns: False

我是否可以根据此映射鼠标上的按键?

I own a Razer Naga Mouse, essentaly it has a small numpad on the side of it. I want to remap these keys to different unused keys or to bash commands. I can do this easily by using xev to grab the keycode (for instance the "1" on the mouse is keycode 87) and then I can use xmodmap to bind the keycode to a different key.

However the numpad on my keyboard will also inherit this as the keycode is the same, what I noticed though is that the "serial" is different.

For instance here is the output from xev when pressing the "1" button on my mouse numpad.

KeyPress event, serial 34, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2179878, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes: 
XmbLookupString gives 0 bytes: 
XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2179966, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes: 
XFilterEvent returns: False

and here is the output when pressing "1" on my keyboards numpad

KeyPress event, serial 35, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2180261, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes: 
XmbLookupString gives 0 bytes: 
XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2180341, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes: 
XFilterEvent returns: False

Is there anyway I could map the keys on my mouse based on this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜宝宝 2024-10-04 08:34:54

尝试使用 setxkbmap,而不是 xmodmapxkbcompxkbcomp 命令允许您指定输入设备 ID(使用 -i 选项)。

要获取设备 ID 列表,请运行 xinput --list。 (FWIW,我的 Razer Salmosa 明确标记为“Razer Razer Salmosa”。)

以下是我如何将 USB 键盘 (ID 16) 转换为使用德语键映射,同时将笔记本电脑键盘保留在美国映射上:

setxkbmap de -print | xkbcomp - -i 16 $DISPLAY

我真的不知道知道如何设置 xkb 映射,但我发现一个 看起来相当不错的教程

Instead of xmodmap, try using setxkbmap and xkbcomp. The xkbcomp command lets you specify an input device ID (using the -i option).

To get a list of device IDs run xinput --list. (FWIW, my Razer Salmosa was clearly labeled as "Razer Razer Salmosa".)

Here's how I converted my USB keyboard (ID 16) to use the German key mapping, while keeping my laptop keyboard on a US mapping:

setxkbmap de -print | xkbcomp - -i 16 $DISPLAY

I don't really know how to set up xkb mappings, but I found a tutorial that looks pretty good.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文