aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-10-04 22:01:54 +0200
committeremersion <contact@emersion.fr>2017-10-04 22:01:54 +0200
commit3b226ba81a4fd5217dcc2004d30a82e97fddbf17 (patch)
treec862f9eb850c7bf8b9c924957f602810a75cfcd2
parent09a6d863cf9b6e7fba459ede2b9769e78535b11a (diff)
rootston: rotation by steps
-rw-r--r--rootston/cursor.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/rootston/cursor.c b/rootston/cursor.c
index c26ca43a..aad6751e 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -1,3 +1,4 @@
+#define _XOPEN_SOURCE 500
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
@@ -114,6 +115,8 @@ void cursor_update_position(struct roots_input *input, uint32_t time) {
int vx = input->cursor->x - ox,
vy = input->cursor->y - oy;
float angle = atan2(vx*uy - vy*ux, vx*ux + vy*uy);
+ int steps = 12;
+ angle = round(angle/M_PI*steps) / (steps/M_PI);
view->rotation = input->view_rotation + angle;
}
break;