diff options
author | David Thompson <dthompson2@worcester.edu> | 2018-12-13 21:37:13 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2018-12-13 21:37:13 -0500 |
commit | f822c3137a906f6bfe83243656c229bb085f98b4 (patch) | |
tree | 0d922e83089afba13cd286ae5eb23e607beffa65 | |
parent | 607e537eaa8614ff9338d7aece5044d98c421584 (diff) |
Add mouse query procedures.
* chickadee.scm (mouse-x, mouse-y, mouse-button-pressed?,
mouse-button-released?): New procedures.
-rw-r--r-- | chickadee.scm | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/chickadee.scm b/chickadee.scm index 73aeae9..9e230a3 100644 --- a/chickadee.scm +++ b/chickadee.scm @@ -25,8 +25,9 @@ #:use-module (sdl2) #:use-module (sdl2 events) #:use-module (sdl2 input game-controller) - #:use-module ((sdl2 input keyboard) #:prefix sdl2:) #:use-module (sdl2 input joystick) + #:use-module ((sdl2 input keyboard) #:prefix sdl2:) + #:use-module ((sdl2 input mouse) #:prefix sdl2:) #:use-module (sdl2 input text) #:use-module (sdl2 mixer) #:use-module (sdl2 video) @@ -37,7 +38,11 @@ #:use-module (chickadee render gl) #:use-module (chickadee render gpu) #:use-module (chickadee render viewport) - #:export (key-pressed? + #:export (mouse-x + mouse-y + mouse-button-pressed? + mouse-button-released? + key-pressed? key-released? current-window run-game) @@ -51,6 +56,22 @@ "Return #t if KEY is not currently being pressed." (sdl2:key-released? key)) +(define (mouse-x) + "Return the current X coordinate of the mouse cursor." + (sdl2:mouse-x)) + +(define (mouse-y) + "Return the current Y coordinate of the mouse cursor." + (sdl2:mouse-y)) + +(define (mouse-button-pressed? button) + "Return #t if BUTTON is currently being pressed." + (sdl2:mouse-button-pressed? button)) + +(define (mouse-button-released? button) + "Return #t if BUTTON is not currently being pressed." + (sdl2:mouse-button-released? button)) + (define *controllers* (make-hash-table)) (define (lookup-controller joystick-id) |