gpt4 book ai didi

linux - 使用 XGetPointerMapping/XSetPointerMapping 交换鼠标按钮

转载 作者:太空宇宙 更新时间:2023-11-04 11:25:54 25 4
gpt4 key购买 nike

我在 http://linux.die.net/man/3/xgetpointermapping 找到了这两个 API .我认为它们可用于在 linux 或 mac 系统上交换鼠标按钮。我按以下方式使用它:

            Display *   curdisp;    // Current display.
char curmap[MAX_NUM];// Current mapping.
int nmap; // number of mappings.

curdisp = XOpenDisplay(NULL);

nmap = XGetPointerMapping(curdisp, curmap, MAX_NUM);
if(!nmap)
return -1;

if(curmap[0] == '1' && curmap[2] == '3') {
curmap[0] = '3';
curmap[2] = '1';
} else {
curmap[0] = '1';
curmap[2] = '3';
}

//Set the mapping.
nmap = XSetPointerMapping(curdisp, curmap, nmap);

但是调用 XSetPointerMapping 返回 0 并且对鼠标按钮没有影响。任何人都可以举一些使用 XSetPointerMapping 交换鼠标按钮的例子吗?或如何正确使用它?它会立即生效吗?

正在使用的操作系统是 Mac OS X 10.7.4。

最佳答案

按钮编号存储为无符号字符,但不存储为字符。将“1”和“3”更改为 1 和 3。

您的代码将它们映射到按钮 49 和 51,并且确实会影响使按钮 1 和 3 不可用的按钮。

关于linux - 使用 XGetPointerMapping/XSetPointerMapping 交换鼠标按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14811549/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com