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

标签 linux x11

我在 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/

相关文章:

c - 为什么我的webkit在/usr/lib/mozilla/plugins目录下找不到libflashplayer.so

c++ - 在 Linux 上使用桌面作为 Canvas

linux - 使用 Netbeans 的远程 SSH/SFTP

c++ - 仅为C++文件生成标记文件(.h,.cpp,.cxx,.c)

linux - 如何在 `build-essential` 中安装 `Cygwin`?

java - java AWT 可以在没有 X11 或 wayland 的情况下工作吗?

macos - X11(xquartz)窗口堆叠

c - X11 等待并获取剪贴板文本

c - 如何将合成鼠标事件插入 X11 输入队列

c - linux内核中的时间戳错误?