diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-01-09 20:35:00 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-01-09 20:35:00 -0500 |
commit | 292aa670881cb93c0979696d33b6b0d1d5a4d065 (patch) | |
tree | 500f949233b4654f42077213106d3f3c29effc03 /2d | |
parent | 5a4c3abb3a05ec09100aab7857caeb8832948878 (diff) |
Add key press/release hooks.
* 2d/keyboard.scm (key-press-hook, key-release-hook): New hooks.
Diffstat (limited to '2d')
-rw-r--r-- | 2d/keyboard.scm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/2d/keyboard.scm b/2d/keyboard.scm index 34a2e12..ec9f1a4 100644 --- a/2d/keyboard.scm +++ b/2d/keyboard.scm @@ -26,13 +26,17 @@ #:use-module (2d game) #:use-module (2d signals) #:use-module (2d vector2) - #:export (key-last-down + #:export (key-press-hook + key-release-hook + key-last-down key-last-up key-down? key-directions key-arrows key-wasd)) +(define key-press-hook (make-hook 2)) +(define key-release-hook (make-hook 2)) (define key-last-down (make-root-signal 'none)) (define key-last-up (make-root-signal 'none)) @@ -67,9 +71,15 @@ KEY is pressed or #f otherwise." (register-event-handler 'key-down (lambda (e) + (run-hook key-press-hook + (SDL:event:key:keysym:sym e) + (SDL:event:key:keysym:unicode e)) (signal-set! key-last-down (SDL:event:key:keysym:sym e)))) (register-event-handler 'key-up (lambda (e) + (run-hook key-release-hook + (SDL:event:key:keysym:sym e) + (SDL:event:key:keysym:unicode e)) (signal-set! key-last-up (SDL:event:key:keysym:sym e)))) |