如何从Linux中的图形输入板手写笔读取压力值?

Nic*_*ton 5 c++ linux x11 wacom

我正在尝试在Linux上为Synergy添加压力敏感性支持.我认为第一步应该是检测服务器端的压力值.当调用XNextEvent时,手写笔移动作为MotionNotify事件进入.但是,当使用触控笔时,此线不输出压力值:

   case MotionNotify:
           XDeviceMotionEvent* motionEvent = reinterpret_cast<XDeviceMotionEvent*>(xevent);
           LOG((CLOG_INFO "tablet event: pressure=%d", motionEvent->axis_data[2]));
Run Code Online (Sandbox Code Playgroud)

为了解决这个问题,我猜测我可能没有"订阅"这样的信息,所以按照我在网上找到的一些例子,我试图打开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);
   }
Run Code Online (Sandbox Code Playgroud)

这确实检测到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
Run Code Online (Sandbox Code Playgroud)

但到目前为止,我从未收到过来自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;
   }
Run Code Online (Sandbox Code Playgroud)

换句话说,以上if永远不会评估为真.

我希望有人可以帮助我,我一直试图解决它几周.

下一个挑战是伪造Synergy客户端上的压力级别,以便像GIMP这样的程序将接收它(我甚至不知道从哪里开始).