]> git.mdlowis.com Git - proto/labwc.git/commitdiff
input: add rotate transformation for tablet coordinates
authorJens Peters <jp7677@gmail.com>
Fri, 29 Dec 2023 21:38:05 +0000 (22:38 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 29 Dec 2023 22:32:41 +0000 (22:32 +0000)
Co-authored-by: Consolatis <35009135+Consolatis@users.noreply.github.com>
src/input/tablet.c

index 14ee95660c4ef0214d73adbae52558afd235aff7..1cbe1cdefa7ee3da44decf03963ed061b217a465 100644 (file)
 #include "input/cursor.h"
 #include "input/tablet.h"
 
+static void
+adjust_for_rotation(enum rotation rotation, double *x, double *y)
+{
+       double tmp;
+       switch (rotation) {
+       case LAB_ROTATE_NONE:
+               break;
+       case LAB_ROTATE_90:
+               tmp = *x;
+               *x = 1.0 - *y;
+               *y = tmp;
+               break;
+       case LAB_ROTATE_180:
+               *x = 1.0 - *x;
+               *y = 1.0 - *y;
+               break;
+       case LAB_ROTATE_270:
+               tmp = *x;
+               *x = *y;
+               *y = 1.0 - tmp;
+               break;
+       }
+}
+
 static void
 handle_axis(struct wl_listener *listener, void *data)
 {
@@ -26,6 +50,7 @@ handle_axis(struct wl_listener *listener, void *data)
 
                double x = tablet->x;
                double y = tablet->y;
+               adjust_for_rotation(rc.tablet.rotation, &x, &y);
                cursor_emulate_move_absolute(tablet->seat, &ev->tablet->base, x, y, ev->time_msec);
        }
        // Ignore other events