配置和测试X输入设备的两个主要实用程序是xinput和xset。
这两种属性之间的主要区别(据我所知)是,xinput允许对(可能依赖于设备)属性进行更细粒度的控制。另一方面,有时通过xset提供的设置是一个很好的起点。
我想做的是从xset给出的设置开始,并通过xinput应用一些微调。
问题是,通过xset获得的配置似乎没有由xinput注册,xset手册页面也没有给出它生成的设置的确切细节。
例如,假设我想改变触控板的速度。从xinput --list中我知道相关的设备id是15,所以我可以使用xinput --list-props 15列出所有的触摸屏属性。现在我可以使用xinput --set-prop 15 276 1.5将一些属性,例如常量减速(在本例中为ID 276)更改为值1.5。
然而,xset mouse 5 5也给了我一个很好的速度设置。我想了解使用这个命令配置了哪些确切的配置,但是在xinput --list-props 15之后运行xset mouse 5 5并不会注册任何差异。我怎样才能得到这些信息?
发布于 2018-03-09 18:59:01
不是一个完整的答案,但是我通过查看源代码就知道了一些细节。
我在xset.c文件中查看了D1的源代码,它来自于包x11-xserver-utils。apt-get source x11-xserver-utils在我的系统上下载的文件(Ubuntu16.04)中的代码与找到这里的代码大致相同,因此我将使用该页面上的代码作为参考。
在L 475-502(编辑:在更新的参考文献L 450-475中)看到mouse选项时会发生什么:
/* Set pointer (mouse) settings: Acceleration and Threshold. */
else if (strcmp(arg, "m") == 0 || strcmp(arg, "mouse") == 0) {
acc_num = SERVER_DEFAULT; /* restore server defaults */
acc_denom = SERVER_DEFAULT;
threshold = SERVER_DEFAULT;
if (i >= argc){
set_mouse(dpy, acc_num, acc_denom, threshold);
break;
}
arg = argv[i];
if (strcmp(arg, "default") == 0) {
i++;
}
else if (*arg >= '0' && *arg <= '9') {
acc_denom = 1;
sscanf(arg, "%d/%d", &acc_num, &acc_denom);
i++;
if (i >= argc) {
set_mouse(dpy, acc_num, acc_denom, threshold);
break;
}
arg = argv[i];
if (*arg >= '0' && *arg <= '9') {
threshold = atoi(arg); /* Set threshold as user specified. */
i++;
}
}
set_mouse(dpy, acc_num, acc_denom, threshold);
}其中SERVER_DEFAULT设置为-1。这只是读取参数并调用set_mouse。特别要注意的是,如果不提供额外的参数(命令称为xset mouse),则默认值为xset mouse -1/-1 -1。另外,acc_num和threshold必须介于0到9之间,否则将使用默认值-1,而acc_denom的默认值为1。
函数set_mouse同样只是一堆非法输入值的检查:
set_mouse(Display *dpy, int acc_num, int acc_denom, int threshold)
{
int do_accel = True, do_threshold = True;
if (acc_num == DONT_CHANGE) /* what an incredible crock... */
do_accel = False;
if (threshold == DONT_CHANGE)
do_threshold = False;
if (acc_num < 0) /* shouldn't happen */
acc_num = SERVER_DEFAULT;
if (acc_denom <= 0) /* prevent divide by zero */
acc_denom = SERVER_DEFAULT;
if (threshold < 0) threshold = SERVER_DEFAULT;
XChangePointerControl(dpy, do_accel, do_threshold, acc_num,
acc_denom, threshold);
return;
}球现在传递给XChangePointerControl。然而,这个函数在这个包中没有定义。通过搜索所包含的依赖项,我找到了libx11包,其中包含文件ChPntCont.c (源代码这里),它定义了这个函数:
int
XChangePointerControl(
register Display *dpy,
Bool do_acc,
Bool do_thresh,
int acc_numerator,
int acc_denominator,
int threshold)
{
register xChangePointerControlReq *req;
LockDisplay(dpy);
GetReq(ChangePointerControl, req);
req->doAccel = do_acc;
req->doThresh = do_thresh;
req->accelNum = acc_numerator;
req->accelDenum = acc_denominator;
req->threshold = threshold;
UnlockDisplay(dpy);
SyncHandle();
return 1;
}除了这一点之外,我并没有真正理解太多。GetReq是由libx11包中的文件Xlibint.h中的一个宏定义的,我们在几个不同的函数之间来回跳过。最后,我们可能从上面的函数中获得了足够的信息,因为输入值似乎是直接作为类似名称的触摸屏设备属性的新值来输入的。
以上至少告诉我们一些关于xset的默认值和可接受值的内容。
但是,我没有弄明白为什么xinput list-props的输出在属性被xset更改后没有更新。
https://unix.stackexchange.com/questions/428351
复制相似问题