summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2013-06-25 19:49:27 -0400
committerDavid Thompson <dthompson2@worcester.edu>2013-06-25 19:49:27 -0400
commite8874c71b69fef1ea5a0cfc796e621cf69fedb32 (patch)
tree2fbb6ddf4759b984e334da4c2093fe99c9ba6481
parent71b22c485a866ee26a3cb74c4afca878b66055bb (diff)
Pass key modifiers and unicode value as arguments to key up/down events.
-rw-r--r--2d/game-loop.scm17
1 files changed, 13 insertions, 4 deletions
diff --git a/2d/game-loop.scm b/2d/game-loop.scm
index 92d3796..eef3d2f 100644
--- a/2d/game-loop.scm
+++ b/2d/game-loop.scm
@@ -39,8 +39,8 @@
(define render-callback (lambda () #t))
(define update-callback (lambda () #t))
-(define key-up-callback (lambda (key) #t))
-(define key-down-callback (lambda (key) #t))
+(define key-up-callback (lambda (key mod unicode) #t))
+(define key-down-callback (lambda (key mod unicode) #t))
(define (set-render-callback callback)
"Sets the render callback procedure."
@@ -73,13 +73,22 @@
"Calls the relevant callback for the event."
(case (SDL:event:type e)
((SDL_KEYDOWN)
- (key-down-callback (event-keycode e)))
+ (key-down-callback (event-keycode e)
+ (event-keymods e)
+ (SDL:event:key:keysym:unicode e)))
((SDL_KEYUP)
- (key-up-callback (event-keycode e)))))
+ (key-up-callback (event-keycode e)
+ (event-keymods e)
+ (SDL:event:key:keysym:unicode e)))))
(define (event-keycode e)
+ "Returns an integer keycode from an SDL event."
(SDL:enum->number SDL:event-keys (SDL:event:key:keysym:sym e)))
+(define (event-keymods e)
+ "Returns an integer bitmask of keymods from an SDL event"
+ (SDL:flags->number (SDL:flagstash:event-mod) (SDL:event:key:keysym:mod e)))
+
;;;
;;; Update and Render
;;;