Fix T40621: Tablet in walk mode fails

Add support for walk mode /w absolute pointing devices.
This commit is contained in:
Campbell Barton 2015-06-01 19:57:38 +10:00
parent 07a6d4ed75
commit c8711b6f6f
Notes: blender-bot 2023-06-21 19:23:24 +02:00
Referenced by issue #82288, Wintab walk navigation erratic (regression)
Referenced by issue #40621, Unstable viewport navigation using walk Mode and a Wacom Tablet
3 changed files with 62 additions and 6 deletions

View File

@ -26,8 +26,6 @@
/* defines VIEW3D_OT_navigate - walk modal operator */
//#define NDOF_WALK_DEBUG
//#define NDOF_WALK_DRAW_TOOMUCH /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
@ -58,6 +56,11 @@
#include "view3d_intern.h" /* own include */
//#define NDOF_WALK_DEBUG
//#define NDOF_WALK_DRAW_TOOMUCH /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */
#define USE_TABLET_SUPPORT
/* prototypes */
static float getVelocityZeroTime(const float gravity, const float velocity);
@ -276,6 +279,14 @@ typedef struct WalkInfo {
/* mouse reverse */
bool is_reversed;
#ifdef USE_TABLET_SUPPORT
/* check if we had a cursor event before */
bool is_cursor_first;
/* tablet devices (we can't relocate the cursor) */
bool is_cursor_absolute;
#endif
/* gravity system */
eWalkGravityState gravity_state;
float gravity;
@ -519,6 +530,12 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
walk->is_reversed = ((U.walk_navigation.flag & USER_WALK_MOUSE_REVERSE) != 0);
#ifdef USE_TABLET_SUPPORT
walk->is_cursor_first = true;
walk->is_cursor_absolute = false;
#endif
walk->active_directions = 0;
#ifdef NDOF_WALK_DRAW_TOOMUCH
@ -586,10 +603,16 @@ static int walkEnd(bContext *C, WalkInfo *walk)
/* restore the cursor */
WM_cursor_modal_restore(win);
/* center the mouse */
WM_cursor_warp(win,
walk->ar->winrct.xmin + walk->center_mval[0],
walk->ar->winrct.ymin + walk->center_mval[1]);
#ifdef USE_TABLET_SUPPORT
if (walk->is_cursor_absolute == false)
#endif
{
/* center the mouse */
WM_cursor_warp(
win,
walk->ar->winrct.xmin + walk->center_mval[0],
walk->ar->winrct.ymin + walk->center_mval[1]);
}
if (walk->state == WALK_CONFIRM) {
MEM_freeN(walk);
@ -617,6 +640,27 @@ static void walkEvent(bContext *C, wmOperator *UNUSED(op), WalkInfo *walk, const
}
else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
#ifdef USE_TABLET_SUPPORT
if (walk->is_cursor_first) {
/* wait until we get the 'warp' event */
if ((walk->center_mval[0] == event->mval[0]) &&
(walk->center_mval[1] == event->mval[1]))
{
walk->is_cursor_first = false;
}
return;
}
if ((walk->is_cursor_absolute == false) && WM_event_is_absolute(event)) {
walk->is_cursor_absolute = true;
copy_v2_v2_int(walk->prev_mval, event->mval);
copy_v2_v2_int(walk->center_mval, event->mval);
/* without this we can't turn 180d */
CLAMP_MIN(walk->mouse_speed, 4.0f);
}
#endif /* USE_TABLET_SUPPORT */
walk->moffset[0] += event->mval[0] - walk->prev_mval[0];
walk->moffset[1] += event->mval[1] - walk->prev_mval[1];
@ -627,6 +671,12 @@ static void walkEvent(bContext *C, wmOperator *UNUSED(op), WalkInfo *walk, const
{
walk->redraw = true;
#ifdef USE_TABLET_SUPPORT
if (walk->is_cursor_absolute) {
/* pass */
}
else
#endif
if (wm_event_is_last_mousemove(event)) {
wmWindow *win = CTX_wm_window(C);

View File

@ -179,6 +179,7 @@ struct wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase
/* mouse */
void WM_event_add_mousemove(struct bContext *C);
bool WM_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
bool WM_event_is_absolute(const struct wmEvent *event);
/* notifiers */
void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference);

View File

@ -618,6 +618,11 @@ void WM_report_banner_show(const bContext *C)
wm_reports->reporttimer->customdata = rti;
}
bool WM_event_is_absolute(const wmEvent *event)
{
return (event->tablet_data != NULL);
}
static void wm_add_reports(const bContext *C, ReportList *reports)
{
/* if the caller owns them, handle this */