mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
input: add rotate transformation for tablet coordinates
Co-authored-by: Consolatis <35009135+Consolatis@users.noreply.github.com>
This commit is contained in:
parent
23ecc32562
commit
e61e4c4e75
1 changed files with 25 additions and 0 deletions
|
|
@ -11,6 +11,30 @@
|
|||
#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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue