From dc684d52e380c47d40336005a1ebbc842f3a6276 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 6 Dec 2014 11:16:57 -0500 Subject: input: mouse: Invert y-axis. * sly/input/mouse.scm (mouse-position): Invert y-axis. --- sly/input/mouse.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sly/input/mouse.scm b/sly/input/mouse.scm index 22c6d8c..8081f64 100644 --- a/sly/input/mouse.scm +++ b/sly/input/mouse.scm @@ -23,6 +23,7 @@ (define-module (sly input mouse) #:use-module ((sdl sdl) #:prefix SDL:) + #:use-module (sly window) #:use-module (sly event) #:use-module (sly signal) #:use-module (sly math vector) @@ -48,7 +49,10 @@ (define-signal mouse-position (hook->signal mouse-move-hook (vector2 0 0) - vector2)) + ;; Sly uses the bottom-left as the origin, so invert + ;; the y-axis for convenience. + (lambda (x y) + (vector2 x (- (signal-ref window-height) y))))) (define-signal mouse-x (signal-map vx mouse-position)) (define-signal mouse-y (signal-map vy mouse-position)) -- cgit v1.2.3