Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2014-07-14 17:59:35 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-07-14 18:06:53 +0400
commit45f0bd6eb1d15aed480fc843ed1c4acc9865abc4 (patch)
treec28344a369d83cef2977de319064a3f425bc8195 /source/blender/windowmanager
parent8554fa2fad63c20ff0c23894ad0b41087d149a32 (diff)
Feature request:
Expose pressure from event system to python. This will return the tablet pressure, if a tablet is present, or 1.0 if not.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_api.h2
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c20
2 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index c9d83a02c27..4b30d4b11b9 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -449,6 +449,8 @@ void WM_event_ndof_rotate_get(const struct wmNDOFMotionData *ndof, float
float WM_event_ndof_to_axis_angle(const struct wmNDOFMotionData *ndof, float axis[3]);
void WM_event_ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4]);
+float WM_event_tablet_data(const struct wmEvent *event, int *pen_flip);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 03f682abc95..15be66da9c2 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -3404,4 +3404,24 @@ void WM_event_ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4])
axis_angle_to_quat(q, axis, angle);
}
+/* if this is a tablet event, return tablet pressure and set *pen_flip
+ * to 1 if the eraser tool is being used, 0 otherwise */
+float WM_event_tablet_data(const wmEvent *event, int *pen_flip)
+{
+ int erasor = 0;
+ float pressure = 1;
+
+ if (event->tablet_data) {
+ wmTabletData *wmtab = event->tablet_data;
+
+ erasor = (wmtab->Active == EVT_TABLET_ERASER);
+ pressure = (wmtab->Active != EVT_TABLET_NONE) ? wmtab->Pressure : 1;
+ }
+
+ if (pen_flip)
+ (*pen_flip) = erasor;
+
+ return pressure;
+}
+
/** \} */