input: add rotate transformation for tablet coordinates

Co-authored-by: Consolatis <35009135+Consolatis@users.noreply.github.com>
This commit is contained in:
Jens Peters 2023-12-29 22:38:05 +01:00 committed by Johan Malm
parent 23ecc32562
commit e61e4c4e75

View file

@ -11,6 +11,30 @@
#include "input/cursor.h" #include "input/cursor.h"
#include "input/tablet.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 static void
handle_axis(struct wl_listener *listener, void *data) 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 x = tablet->x;
double y = tablet->y; 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); cursor_emulate_move_absolute(tablet->seat, &ev->tablet->base, x, y, ev->time_msec);
} }
// Ignore other events // Ignore other events