diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 25 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 19 | ||||
-rw-r--r-- | source/blenderplayer/bad_level_call_stubs/stubs.c | 3 |
5 files changed, 46 insertions, 6 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index b336ba77704..5133f51a6fd 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -715,7 +715,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) float pressure; /* see if tablet affects event */ - pressure = WM_event_tablet_data(event, &stroke->pen_flip); + pressure = WM_event_tablet_data(event, &stroke->pen_flip, NULL); paint_stroke_add_sample(p, stroke, event->mval[0], event->mval[1], pressure); paint_stroke_sample_average(stroke, &sample_average); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 21df596dec2..996d2d2882d 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -568,7 +568,19 @@ static int rna_Event_unicode_length(PointerRNA *ptr) static float rna_Event_pressure_get(PointerRNA *ptr) { wmEvent *event = ptr->data; - return WM_event_tablet_data(event, NULL); + return WM_event_tablet_data(event, NULL, NULL); +} + +static int rna_Event_is_tablet_get(PointerRNA *ptr) +{ + wmEvent *event = ptr->data; + return WM_event_is_tablet(event); +} + +static void rna_Event_tilt_get(PointerRNA *ptr, float *values) +{ + wmEvent *event = ptr->data; + WM_event_tablet_data(event, NULL, values); } static PointerRNA rna_PopupMenu_layout_get(PointerRNA *ptr) @@ -1619,6 +1631,17 @@ static void rna_def_event(BlenderRNA *brna) RNA_def_property_float_funcs(prop, "rna_Event_pressure_get", NULL, NULL); RNA_def_property_ui_text(prop, "Tablet Pressure", "The pressure of the tablet or 1.0 if no tablet present"); + prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_XYZ_LENGTH); + RNA_def_property_array(prop, 2); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_float_funcs(prop, "rna_Event_tilt_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Tablet Tilt", "The pressure of the tablet or zeroes if no tablet present"); + + prop = RNA_def_property(srna, "is_tablet", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Event_is_tablet_get", NULL); + RNA_def_property_ui_text(prop, "Tablet Pressure", "The pressure of the tablet or 1.0 if no tablet present"); + /* modifiers */ prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "shift", 1); 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; +} + + /** \} */ diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 92afe58689d..7d16b9fe34b 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -301,7 +301,8 @@ void ED_armature_transform(struct bArmature *arm, float mat[4][4]) RET_NONE struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op) RET_NULL struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *win, int event_type, double timestep) RET_NULL void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer) RET_NONE -float WM_event_tablet_data(const struct wmEvent *event, int *pen_flip) RET_ZERO +float WM_event_tablet_data(const struct wmEvent *event, int *pen_flip, float tilt[2]) RET_ZERO +bool WM_event_is_tablet(const struct wmEvent *event) RET_ZERO void ED_armature_edit_bone_remove(struct bArmature *arm, struct EditBone *exBone) RET_NONE void object_test_constraints(struct Object *owner) RET_NONE void ED_armature_ebone_to_mat4(struct EditBone *ebone, float mat[4][4]) RET_NONE |