[PATCH libinput 23/26] tools: only print the tablet axes we have on the tool

Peter Hutterer peter.hutterer at who-t.net
Wed Feb 25 20:31:52 PST 2015


On Wed, Feb 25, 2015 at 05:31:00PM -0800, Jason Gerecke wrote:
> 
> On 2/23/2015 10:21 PM, Peter Hutterer wrote:
> >This doesn't really have an effect, since we don't set the per-tool axes
> >correctly yet.
> >
> >Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> >---
> >  tools/event-debug.c | 106 +++++++++++++++++++++++++++-------------------------
> >  1 file changed, 56 insertions(+), 50 deletions(-)
> >
> >diff --git a/tools/event-debug.c b/tools/event-debug.c
> >index 225e12f..94a90ec 100644
> >--- a/tools/event-debug.c
> >+++ b/tools/event-debug.c
> >@@ -288,48 +288,77 @@ tablet_axis_changed_sym(struct libinput_event_tablet *t,
> >  }
> >  static void
> >-print_tablet_axis_event(struct libinput_event *ev)
> >+print_tablet_axes(struct libinput_event_tablet *t)
> >  {
> >-	struct libinput_event_tablet *t = libinput_event_get_tablet_event(ev);
> >+	struct libinput_tool *tool = libinput_event_tablet_get_tool(t);
> >  	double x, y;
> >  	double dist, pressure;
> >  	double rotation, slider;
> >-	print_event_time(libinput_event_tablet_get_time(t));
> >-
> Nitpick: Should be in a separate change or mentioned in the description.

amended locally, thanks.

Cheers,
   Peter

> >  	x = libinput_event_tablet_get_axis_value(t, LIBINPUT_TABLET_AXIS_X);
> >  	y = libinput_event_tablet_get_axis_value(t, LIBINPUT_TABLET_AXIS_Y);
> >  	printf("\t%.2f%s/%.2f%s",
> >  	       x, tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_X),
> >  	       y, tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_Y));
> >-	x = libinput_event_tablet_get_axis_value(t, LIBINPUT_TABLET_AXIS_TILT_X);
> >-	y = libinput_event_tablet_get_axis_value(t, LIBINPUT_TABLET_AXIS_TILT_Y);
> >-	printf("\ttilt: %.2f%s/%.2f%s ",
> >-	       x, tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_TILT_X),
> >-	       y, tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_TILT_Y));
> >+	if (libinput_tool_has_axis(tool, LIBINPUT_TABLET_AXIS_TILT_X) ||
> >+	    libinput_tool_has_axis(tool, LIBINPUT_TABLET_AXIS_TILT_Y)) {
> >+		x = libinput_event_tablet_get_axis_value(t,
> >+					 LIBINPUT_TABLET_AXIS_TILT_X);
> >+		y = libinput_event_tablet_get_axis_value(t,
> >+					 LIBINPUT_TABLET_AXIS_TILT_Y);
> >+		printf("\ttilt: %.2f%s/%.2f%s ",
> >+		       x, tablet_axis_changed_sym(t,
> >+					  LIBINPUT_TABLET_AXIS_TILT_X),
> >+		       y, tablet_axis_changed_sym(t,
> >+					  LIBINPUT_TABLET_AXIS_TILT_Y));
> >+	}
> >-	dist = libinput_event_tablet_get_axis_value(t, LIBINPUT_TABLET_AXIS_DISTANCE);
> >-	pressure = libinput_event_tablet_get_axis_value(t, LIBINPUT_TABLET_AXIS_PRESSURE);
> >-	if (dist)
> >-		printf("distance: %.2f%s",
> >-		       dist, tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_DISTANCE));
> >-	else
> >-		printf("pressure: %.2f%s",
> >-		       pressure, tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_PRESSURE));
> >+	if (libinput_tool_has_axis(tool, LIBINPUT_TABLET_AXIS_DISTANCE) ||
> >+	    libinput_tool_has_axis(tool, LIBINPUT_TABLET_AXIS_PRESSURE)) {
> >+		dist = libinput_event_tablet_get_axis_value(t,
> >+					LIBINPUT_TABLET_AXIS_DISTANCE);
> >+		pressure = libinput_event_tablet_get_axis_value(t,
> >+					LIBINPUT_TABLET_AXIS_PRESSURE);
> >+		if (dist) {
> >+			printf("\tdistance: %.2f%s",
> >+			       dist,
> >+			       tablet_axis_changed_sym(t,
> >+					       LIBINPUT_TABLET_AXIS_DISTANCE));
> >+		} else {
> >+			printf("\tpressure: %.2f%s",
> >+			       pressure,
> >+			       tablet_axis_changed_sym(t,
> >+					       LIBINPUT_TABLET_AXIS_PRESSURE));
> >+		}
> >+	}
> >-	rotation = libinput_event_tablet_get_axis_value(t,
> >+	if (libinput_tool_has_axis(tool, LIBINPUT_TABLET_AXIS_ROTATION_Z)) {
> >+		rotation = libinput_event_tablet_get_axis_value(t,
> >  					LIBINPUT_TABLET_AXIS_ROTATION_Z);
> >-	printf(" rotation: %.2f%s",
> >-	       rotation,
> >-	       tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_ROTATION_Z));
> >+		printf("\trotation: %.2f%s",
> >+		       rotation,
> >+		       tablet_axis_changed_sym(t,
> >+				       LIBINPUT_TABLET_AXIS_ROTATION_Z));
> >+	}
> >-	slider = libinput_event_tablet_get_axis_value(t,
> >+	if (libinput_tool_has_axis(tool, LIBINPUT_TABLET_AXIS_SLIDER)) {
> >+		slider = libinput_event_tablet_get_axis_value(t,
> >  					LIBINPUT_TABLET_AXIS_SLIDER);
> >-	printf(" slider: %.2f%s",
> >-	       slider,
> >-	       tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_SLIDER));
> >+		printf("\tslider: %.2f%s",
> >+		       slider,
> >+		       tablet_axis_changed_sym(t,
> >+				       LIBINPUT_TABLET_AXIS_SLIDER));
> >+	}
> >+}
> >+static void
> >+print_tablet_axis_event(struct libinput_event *ev)
> >+{
> >+	struct libinput_event_tablet *t = libinput_event_get_tablet_event(ev);
> >+
> >+	print_event_time(libinput_event_tablet_get_time(t));
> >+	print_tablet_axes(t);
> >  	printf("\n");
> >  }
> >@@ -350,8 +379,6 @@ print_proximity_event(struct libinput_event *ev)
> >  	enum libinput_tool_proximity_state state;
> >  	const char *tool_str,
> >  	           *state_str;
> >-	double x, y;
> >-	double dist, pressure;
> >  	switch (libinput_tool_get_type(tool)) {
> >  	case LIBINPUT_TOOL_PEN:
> >@@ -387,28 +414,7 @@ print_proximity_event(struct libinput_event *ev)
> >  	print_event_time(libinput_event_tablet_get_time(t));
> >  	if (state == LIBINPUT_TOOL_PROXIMITY_IN) {
> >-		x = libinput_event_tablet_get_axis_value(
> >-					t, LIBINPUT_TABLET_AXIS_X);
> >-		y = libinput_event_tablet_get_axis_value(
> >-					t, LIBINPUT_TABLET_AXIS_Y);
> >-		printf("\t%.2f/%.2f", x, y);
> >-
> >-		x = libinput_event_tablet_get_axis_value(
> >-					t, LIBINPUT_TABLET_AXIS_TILT_X);
> >-		y = libinput_event_tablet_get_axis_value(
> >-					t, LIBINPUT_TABLET_AXIS_TILT_Y);
> >-		printf("\ttilt: %.2f/%.2f ", x, y);
> >-
> >-		dist = libinput_event_tablet_get_axis_value(
> >-					t, LIBINPUT_TABLET_AXIS_DISTANCE);
> >-		pressure = libinput_event_tablet_get_axis_value(
> >-					t, LIBINPUT_TABLET_AXIS_PRESSURE);
> >-
> >-		if (dist)
> >-			printf("\tdistance: %.2f ", dist);
> >-		else
> >-			printf("\tpressure: %.2f ", pressure);
> >-
> >+		print_tablet_axes(t);
> >  		state_str = "proximity-in";
> >  	} else if (state == LIBINPUT_TOOL_PROXIMITY_OUT) {
> >  		state_str = "proximity-out";
> >@@ -417,7 +423,7 @@ print_proximity_event(struct libinput_event *ev)
> >  		abort();
> >  	}
> >-	printf("%s (%#x) %s",
> >+	printf("\t%s (%#x) %s",
> >  	       tool_str, libinput_tool_get_serial(tool), state_str);
> >  	printf("\taxes:");
> 
> -- 
> Jason
> ---
> Now instead of four in the eights place /
> you’ve got three, ‘Cause you added one /
> (That is to say, eight) to the two, /
> But you can’t take seven from three, /
> So you look at the sixty-fours....
> 


More information about the wayland-devel mailing list