diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 22 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 10 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 20 | ||||
-rw-r--r-- | source/blenderplayer/bad_level_call_stubs/stubs.c | 1 |
5 files changed, 34 insertions, 21 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index e87f8ca6827..b336ba77704 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -135,26 +135,6 @@ static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata } } -/* if this is a tablet event, return tablet pressure and set *pen_flip - * to 1 if the eraser tool is being used, 0 otherwise */ -static float 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; -} - static bool paint_tool_require_location(Brush *brush, PaintMode mode) { switch (mode) { @@ -735,7 +715,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) float pressure; /* see if tablet affects event */ - pressure = event_tablet_data(event, &stroke->pen_flip); + pressure = WM_event_tablet_data(event, &stroke->pen_flip); 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 23b6d1e41ae..21df596dec2 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -565,6 +565,12 @@ 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); +} + static PointerRNA rna_PopupMenu_layout_get(PointerRNA *ptr) { struct uiPopupMenu *pup = ptr->data; @@ -1608,6 +1614,10 @@ static void rna_def_event(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Mouse Previous Y Position", "The window relative vertical location of the mouse"); + prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + 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"); /* modifiers */ prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE); 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; +} + /** \} */ diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 72f411b4231..92afe58689d 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -301,6 +301,7 @@ 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 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 |