How to find out the value of pressure using the stylus of a graphic tablet in Linux?

I am trying to add Synergy pressure sensitivity support on Linux. I believe that the first step should be to determine the pressure value on the server. The stylus movement occurs as a MotionNotify event when an XNextEvent is called. However, this line does not display pressure value when using the stylus:

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

To solve this problem, I guessed that I can’t “subscribe” to such info, therefore, following some examples that I found on the Internet, I tried to open the Wacom device:

   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);
   }

It really detects a Wacom device ...

   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

But so far I have not received the stylus event 105 (m_tabletMotionEvent) from XNextEvent ...

   if (xevent->type == m_tabletMotionEvent) {
           XDeviceMotionEvent* motionEvent = reinterpret_cast<XDeviceMotionEvent*>(xevent);
           LOG((CLOG_INFO "tablet event: pressure=%d", motionEvent->axis_data[2]));
           return;
   }

In other words, the above ifwill never be considered true.

, - , .

Synergy , , GIMP, ( , ).

+5

All Articles