diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-01-10 18:54:17 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-01-21 14:22:24 +0300 |
commit | ca4e8b423e81f2a72cd5409d1c2c0450e12afc78 (patch) | |
tree | f6bcd8f872cb0e9845ef1efc7973ee62ca7d5713 /source/blender/windowmanager/intern/wm_event_query.c | |
parent | f10d190240a135f4e26058eb49a787f9178ceb71 (diff) |
Cleanup: simplify wmEvent tablet data storage and naming
Removing meaningless distinction between NULL pointer and EVT_TABLET_NONE,
and initialize pressure and tilt to 1.0 and 0.0 respectively when no tablet
is used.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_event_query.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_query.c | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c index 86d92a473ff..3cec185fd36 100644 --- a/source/blender/windowmanager/intern/wm_event_query.c +++ b/source/blender/windowmanager/intern/wm_event_query.c @@ -101,13 +101,13 @@ void WM_event_print(const wmEvent *event) } #endif /* WITH_INPUT_NDOF */ - if (event->tablet_data) { - const wmTabletData *wmtab = event->tablet_data; + if (event->tablet.active != EVT_TABLET_NONE) { + const wmTabletData *wmtab = &event->tablet; printf(" tablet: active: %d, pressure %.4f, tilt: (%.4f %.4f)\n", - wmtab->Active, - wmtab->Pressure, - wmtab->Xtilt, - wmtab->Ytilt); + wmtab->active, + wmtab->pressure, + wmtab->x_tilt, + wmtab->y_tilt); } } else { @@ -392,36 +392,21 @@ float wm_pressure_curve(float pressure) * to 1 if the eraser tool is being used, 0 otherwise */ 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) { - const wmTabletData *wmtab = event->tablet_data; - - erasor = (wmtab->Active == EVT_TABLET_ERASER); - if (wmtab->Active != EVT_TABLET_NONE) { - pressure = wmtab->Pressure; - if (tilt) { - tilt[0] = wmtab->Xtilt; - tilt[1] = wmtab->Ytilt; - } - } + tilt[0] = event->tablet.x_tilt; + tilt[1] = event->tablet.y_tilt; } if (pen_flip) { - (*pen_flip) = erasor; + (*pen_flip) = (event->tablet.active == EVT_TABLET_ERASER); } - return pressure; + return event->tablet.pressure; } bool WM_event_is_tablet(const struct wmEvent *event) { - return (event->tablet_data) ? true : false; + return (event->tablet.active != EVT_TABLET_NONE); } /** \} */ |