How is the pressure value from a graphics tablet read in GIMP?
Forums ► For GIMP developers (read-only) ► How is the pressure value from a graphics tablet read in GIMP?
-
Nick Bolton
(4 months ago)
- Alexia Death (4 months ago)
Sent: 2012-01-30 11:26:06 UTC (4 months ago)
From: Nick Bolton
How is the pressure value from a graphics tablet read in GIMP?
Hello,
I'm working on another FOSS project, Synergy. I was hoping that
someone could share some knowledge with me.Does anyone know how GIMP retrieves the stylus pressure value from a
Wacom tablet?I am trying to add pressure sensitivity support to Synergy on Linux. I
believe the first step should be to detect the pressure value on the
server side. The stylus movement comes in as a MotionNotify event when
XNextEvent is called. However, this line does not output a pressure
value when the stylus is used:case MotionNotify:
XDeviceMotionEvent* motionEvent =
reinterpret_cast(xevent);
LOG((CLOG_INFO "tablet event: pressure=%d", motionEvent->axis_data[2]));To solve this, I guessed that I might not be "subscribed" to such
info, so following some examples I found on the web, I have attempted
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);
}This does indeed detect 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,1157But I have so far never received the stylus event 105
(m_tabletMotionEvent) from XNextEvent...if (xevent->type == m_tabletMotionEvent) {
XDeviceMotionEvent* motionEvent =
reinterpret_cast(xevent);
LOG((CLOG_INFO "tablet event: pressure=%d", motionEvent->axis_data[2]));
return;
}In other words, the above `if` never evaluates to true.
I hope someone can help me with this, I've been trying to solve it for weeks.
The next challenge will be to fake the pressure level on the Synergy
client so that GIMP will receive it (and I'm not even sure where to
start with that).Cheers,
Nick
Sent: 2012-01-30 12:24:16 UTC (4 months ago)
From: Alexia Death
How is the pressure value from a graphics tablet read in GIMP?
On Mon, Jan 30, 2012 at 1:26 PM, Nick Bolton wrote:
> Does anyone know how GIMP retrieves the stylus pressure value from a
> Wacom tablet?
GIMP lets GTK handle such things, as GTK is better suited to handle
such things. You will probably find andswers to your questions there,
in GTK+ GDK component X11 input module. If you are using a toolkit,
its probably better to see what it offers. If not,
http://git.gnome.org/browse/gtk+/tree/gdk/x11/gdkinput-x11.c?h=gtk-2-24
may help. Lowlevel X API is one thing I am not inimately familiar
with, but I do know this - To get extra information tablet provides,
you need to query for Extended events, not the regular ones.--Alexia





819 @ Twitter