Changes the names to reflect the functionality, not the use case. Also
defines one in terms of the other so that we aren't repeating ourselves.

Signed-off-by: Jason Gerecke <killert...@gmail.com>
Acked-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 src/evdev-tablet.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 4f1bc76..b924800 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -104,7 +104,7 @@ tablet_update_tool(struct tablet_dispatch *tablet,
 }
 
 static inline double
-normalize_pressure_or_dist(const struct input_absinfo * absinfo) {
+normalize_single_ended(const struct input_absinfo * absinfo) {
        double range = absinfo->maximum - absinfo->minimum;
        double value = (absinfo->value - absinfo->minimum) / range;
 
@@ -112,12 +112,9 @@ normalize_pressure_or_dist(const struct input_absinfo * 
absinfo) {
 }
 
 static inline double
-normalize_tilt(const struct input_absinfo * absinfo) {
-       double range = absinfo->maximum - absinfo->minimum;
-       double value = (absinfo->value - absinfo->minimum) / range;
-
-       /* Map to the (-1, 1) range */
-       return (value * 2) - 1;
+normalize_double_ended(const struct input_absinfo * absinfo) {
+       /* Map from (0, 1) to the (-1, 1) range */
+       return (normalize_single_ended(absinfo) * 2) - 1;
 }
 
 static void
@@ -146,11 +143,11 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet,
                        break;
                case LIBINPUT_TABLET_AXIS_DISTANCE:
                case LIBINPUT_TABLET_AXIS_PRESSURE:
-                       tablet->axes[a] = normalize_pressure_or_dist(absinfo);
+                       tablet->axes[a] = normalize_single_ended(absinfo);
                        break;
                case LIBINPUT_TABLET_AXIS_TILT_X:
                case LIBINPUT_TABLET_AXIS_TILT_Y:
-                       tablet->axes[a] = normalize_tilt(absinfo);
+                       tablet->axes[a] = normalize_double_ended(absinfo);
                        break;
                default:
                        log_bug_libinput(device->base.seat->libinput,
-- 
2.1.3

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to