summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee.scm10
1 files changed, 7 insertions, 3 deletions
diff --git a/chickadee.scm b/chickadee.scm
index 2a282b4..3c0e1c9 100644
--- a/chickadee.scm
+++ b/chickadee.scm
@@ -85,6 +85,10 @@
#:width window-width
#:height window-height
#:fullscreen? window-fullscreen?)))
+ (define (invert-y y)
+ ;; SDL's origin is the top-left, but our origin is the bottom
+ ;; left so we need to invert Y coordinates that SDL gives us.
+ (- (window-height window) y))
(define (process-event event)
(cond
((quit-event? event)
@@ -107,18 +111,18 @@
(mouse-button-event-button event)
(mouse-button-event-clicks event)
(mouse-button-event-x event)
- (mouse-button-event-y event)))
+ (invert-y (mouse-button-event-y event))))
((mouse-button-up-event? event)
(run-hook mouse-release-hook
(mouse-button-event-button event)
(mouse-button-event-x event)
- (mouse-button-event-y event)))
+ (invert-y (mouse-button-event-y event))))
((mouse-motion-event? event)
(run-hook mouse-move-hook
(mouse-motion-event-x event)
(mouse-motion-event-y event)
(mouse-motion-event-x-rel event)
- (mouse-motion-event-y-rel event)
+ (- (mouse-motion-event-y-rel event))
(mouse-motion-event-buttons event)))
((and (controller-device-event? event)
(eq? (controller-device-event-action event) 'added))