我正在尝试在 Linux 上为 Synergy 添加压力敏感性支持。我相信第一步应该是检测服务器端的压力值。当调用 XNextEvent 时,触控笔移动作为 MotionNotify 事件出现。但是,使用触控笔时,此行不会输出压力值:
case MotionNotify:
XDeviceMotionEvent* motionEvent = reinterpret_cast<XDeviceMotionEvent*>(xevent);
LOG((CLOG_INFO "tablet event: pressure=%d", motionEvent->axis_data[2]));
为了解决这个问题,我猜我可能没有“订阅”此类信息,所以按照我在网上找到的一些示例,我尝试打开 Wacom 设备:
void
CXWindowsScreen::openWacom()
{
// init tablet (e.g. wacom)
int deviceCount;
XDeviceInfo* deviceInfo = XListInputDevices(m_display, &deviceCount);
for (int i = 0; i < deviceCount; ++i) {
if (CString(deviceInfo[i].name).find("stylus") != CString::npos) {
LOG((CLOG_INFO "tablet device: name='%s', id=%d",
deviceInfo[i].name, deviceInfo[i].id));
XDevice* tabletStylusDevice = XOpenDevice(m_display, deviceInfo[i].id);
if (tabletStylusDevice == NULL) {
LOG((CLOG_ERR "failed to open tablet device"));
return;
}
XEventClass eventClass;
DeviceMotionNotify(tabletStylusDevice, m_tabletMotionEvent, eventClass);
XSelectExtensionEvent(m_display, m_window, &eventClass, 1);
LOG((CLOG_INFO "tablet motion event=%d class=%d",
m_tabletMotionEvent, eventClass));
}
}
XFreeDeviceList(deviceInfo);
}
这确实检测到了 Wacom 设备...
2012-01-30T11:15:59 INFO: tablet device: name='Wacom Intuos4 6x9 stylus', id=8
/home/nick/Projects/synergy/1.4/src/lib/platform/CXWindowsScreen.cpp,1144
2012-01-30T11:15:59 INFO: tablet motion event=105 class=2153
/home/nick/Projects/synergy/1.4/src/lib/platform/CXWindowsScreen.cpp,1157
但到目前为止我还没有收到来自 XNextEvent 的触控笔事件 105 (m_tabletMotionEvent)...
if (xevent->type == m_tabletMotionEvent) {
XDeviceMotionEvent* motionEvent = reinterpret_cast<XDeviceMotionEvent*>(xevent);
LOG((CLOG_INFO "tablet event: pressure=%d", motionEvent->axis_data[2]));
return;
}
换句话说,上述if
内容永远不会评估为真。
我希望有人可以帮助我解决这个问题,我已经尝试解决了好几个星期。
下一个挑战将是在 Synergy 客户端上伪造压力级别,以便像 GIMP 这样的程序会收到它(我什至不知道从哪里开始)。