summaryrefslogtreecommitdiff
path: root/sdl2/events.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-12-16 20:44:48 -0500
committerDavid Thompson <dthompson2@worcester.edu>2015-12-16 20:44:48 -0500
commitf2210cb0e5cb64d43e67868c0bc20c671e72a49d (patch)
tree00d3b2df8768f56ab4b18b04d60fb7ba28c43a1f /sdl2/events.scm
parent2818dfb3f860935ca3a036636d43f8405159897f (diff)
events: keyboard: Add additional predicates.
* sdl2/events.scm (keyboard-down-event?, keyboard-up-event?): New procedures.
Diffstat (limited to 'sdl2/events.scm')
-rw-r--r--sdl2/events.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/sdl2/events.scm b/sdl2/events.scm
index 1d40a38..edb9306 100644
--- a/sdl2/events.scm
+++ b/sdl2/events.scm
@@ -42,6 +42,8 @@
make-keyboard-event
keyboard-event?
+ keyboard-down-event?
+ keyboard-up-event?
keyboard-event-timestamp
keyboard-event-window-id
keyboard-event-pressed?
@@ -133,6 +135,16 @@
(scancode keyboard-event-scancode)
(modifiers keyboard-event-modifiers))
+(define (keyboard-down-event? e)
+ "Return #t if E is a key press event."
+ (and (keyboard-event? e)
+ (keyboard-event-pressed? e)))
+
+(define (keyboard-up-event? e)
+ "Return #t if E is a key release event."
+ (and (keyboard-event? e)
+ (not (keyboard-event-pressed? e))))
+
(define keycode-map
(alist->hash-table
`((,ffi:SDLK_UNKNOWN . unknown)