RSS/Atom feed Twitter
Site is read-only, email is disabled

How is the pressure value from a graphics tablet read in GIMP?

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

2 of 2 messages available
Toggle history

Please log in to manage your subscriptions.

How is the pressure value from a graphics tablet read in GIMP? Nick Bolton 30 Jan 11:26
  How is the pressure value from a graphics tablet read in GIMP? Alexia Death 30 Jan 12:24
Nick Bolton
2012-01-30 11:26:06 UTC (about 13 years ago)

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,1157

But 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

Alexia Death
2012-01-30 12:24:16 UTC (about 13 years ago)

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.