diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-07-14 18:49:00 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-07-14 18:49:00 +0400 |
commit | 48eececdba17af7d85fc19480be0e34e38362e66 (patch) | |
tree | 146586c54f236aebcdad152c93f5ea9514e1f32b /source/blender/windowmanager | |
parent | 45f0bd6eb1d15aed480fc843ed1c4acc9865abc4 (diff) |
Follow up to previous commit.
* Expose is_tablet property to events to determine if event contains
tablet data.
* Expose tablet tilt for events as a 2D vector in python
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 19 |
2 files changed, 19 insertions, 3 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 4b30d4b11b9..cfa795cb3b7 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -449,7 +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); +float WM_event_tablet_data(const struct wmEvent *event, int *pen_flip, float tilt[2]); +bool WM_event_is_tablet(const struct wmEvent *event); #ifdef __cplusplus } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 15be66da9c2..9f1359dfb9b 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -3406,16 +3406,25 @@ void WM_event_ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4]) /* 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) +float WM_event_tablet_data(const wmEvent *event, int *pen_flip, float tilt[2]) { int erasor = 0; float pressure = 1; + if (tilt) + zero_v2(tilt); + 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 (wmtab->Active != EVT_TABLET_NONE) { + pressure = wmtab->Pressure; + if (tilt) { + tilt[0] = wmtab->Xtilt; + tilt[1] = wmtab->Ytilt; + } + } } if (pen_flip) @@ -3424,4 +3433,10 @@ float WM_event_tablet_data(const wmEvent *event, int *pen_flip) return pressure; } +bool WM_event_is_tablet(const struct wmEvent *event) +{ + return (event->tablet_data) ? true : false; +} + + /** \} */ |