summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
;;;