diff options
author | David Thompson <dthompson2@worcester.edu> | 2015-12-16 20:44:48 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2015-12-16 20:44:48 -0500 |
commit | f2210cb0e5cb64d43e67868c0bc20c671e72a49d (patch) | |
tree | 00d3b2df8768f56ab4b18b04d60fb7ba28c43a1f | |
parent | 2818dfb3f860935ca3a036636d43f8405159897f (diff) |
events: keyboard: Add additional predicates.
* sdl2/events.scm (keyboard-down-event?, keyboard-up-event?): New procedures.
-rw-r--r-- | sdl2/events.scm | 12 |
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) |