Fix #25581: No pressure sensitivity in sculpt mode

Tablet mode (stylus/eraser) wasn't properly set when pen was already hovering over
tablet surface when opening blender (i.e. in cases when blender was opened using
stylus tap).

Issue resolved by setting tablet mode when handling tablet's motion event too.
This commit is contained in:
Sergey Sharybin 2012-01-18 11:25:30 +00:00
parent 9ba8f57d58
commit 242a800d34

@ -422,6 +422,15 @@ processEvents(
return anyProcessed;
}
/* set currently using tablet mode (stylus or eraser) depending on device ID */
static void setTabletMode(GHOST_WindowX11 * window, XID deviceid)
{
if(deviceid == window->GetXTablet().StylusID)
window->GetXTablet().CommonData.Active= GHOST_kTabletModeStylus;
else if(deviceid == window->GetXTablet().EraserID)
window->GetXTablet().CommonData.Active= GHOST_kTabletModeEraser;
}
void
GHOST_SystemX11::processEvent(XEvent *xe)
{
@ -824,6 +833,12 @@ GHOST_SystemX11::processEvent(XEvent *xe)
if(xe->type == window->GetXTablet().MotionEvent)
{
XDeviceMotionEvent* data = (XDeviceMotionEvent*)xe;
/* stroke might begin without leading ProxyIn event,
* this happens when window is opened when stylus is already hovering
* around tablet surface */
setTabletMode(window, data->deviceid);
window->GetXTablet().CommonData.Pressure=
data->axis_data[2]/((float)window->GetXTablet().PressureLevels);
@ -837,10 +852,8 @@ GHOST_SystemX11::processEvent(XEvent *xe)
else if(xe->type == window->GetXTablet().ProxInEvent)
{
XProximityNotifyEvent* data = (XProximityNotifyEvent*)xe;
if(data->deviceid == window->GetXTablet().StylusID)
window->GetXTablet().CommonData.Active= GHOST_kTabletModeStylus;
else if(data->deviceid == window->GetXTablet().EraserID)
window->GetXTablet().CommonData.Active= GHOST_kTabletModeEraser;
setTabletMode(window, data->deviceid);
}
else if(xe->type == window->GetXTablet().ProxOutEvent)
window->GetXTablet().CommonData.Active= GHOST_kTabletModeNone;