Add mouse query procedures.
authorDavid Thompson <dthompson2@worcester.edu>
Fri, 14 Dec 2018 02:37:13 +0000 (21:37 -0500)
committerDavid Thompson <dthompson2@worcester.edu>
Fri, 14 Dec 2018 02:37:13 +0000 (21:37 -0500)
* chickadee.scm (mouse-x, mouse-y, mouse-button-pressed?,
mouse-button-released?): New procedures.

chickadee.scm

index 73aeae9..9e230a3 100644 (file)
@@ -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)
   #: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)
   "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)