summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-12-06 11:16:57 -0500
committerDavid Thompson <dthompson2@worcester.edu>2014-12-06 13:20:49 -0500
commitdc684d52e380c47d40336005a1ebbc842f3a6276 (patch)
tree1cb78cedbd4c404a98863cb8d12d303dc864b44f
parent11dba13e4d36d57f0eea0524f52b9b4616049ed2 (diff)
input: mouse: Invert y-axis.
* sly/input/mouse.scm (mouse-position): Invert y-axis.
-rw-r--r--sly/input/mouse.scm6
1 files changed, 5 insertions, 1 deletions
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))