From f2210cb0e5cb64d43e67868c0bc20c671e72a49d Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 16 Dec 2015 20:44:48 -0500 Subject: events: keyboard: Add additional predicates. * sdl2/events.scm (keyboard-down-event?, keyboard-up-event?): New procedures. --- sdl2/events.scm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'sdl2') 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) -- cgit v1.2.3