Skip to content

Commit

Permalink
Switch trackign ID after tool switch
Browse files Browse the repository at this point in the history
The MT code uses tracking ID to pick a new colour for the current touch, so
just store the current BTN_TOOL_* value in the tracking ID. This gives us a
new colour when the tool changes, but keeps the colour if the tool merely
goes out of proximity.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
whot committed Dec 17, 2012
1 parent 382135c commit 9ff50b5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tools/mtview.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,22 @@ static void set_screen_size_mtdev(struct windata *w,
}
}

static void handle_key_event(struct input_event *ev, struct touch_info *touch_info)
{
int slot;

if (touch_info->has_mt)
return;

slot = touch_info->current_slot;

/* Switch of tool is new tracking ID, so we get a new-coloured
circle. Exception is BTN_TOUCH, since that just indicates current
tool touched surface */
if (ev->code >= BTN_DIGI && ev->code < BTN_WHEEL && ev->code != BTN_TOUCH)
touch_info->touches[slot].data[ABS_MT_TRACKING_ID] = ev->code;
}

static void handle_abs_event(struct input_event *ev, struct touch_info *touch_info)
{
int slot;
Expand Down Expand Up @@ -334,6 +350,9 @@ static int handle_event(struct input_event *ev, struct touch_info *touch_info)

if (ev->type == EV_ABS)
handle_abs_event(ev, touch_info);
if (ev->type == EV_KEY)
handle_key_event(ev, touch_info);

return 0;
}

Expand Down

0 comments on commit 9ff50b5

Please sign in to comment.