From b3dbfb42b698f3d94ec38606f85c78d3d01a5f38 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 1 Jan 2017 15:08:44 -0500 Subject: events: Add predicates for different controller device events. * sdl2/events.scm (controller-added-event?, controller-removed-event?, controller-remapped-event?): New procedures. --- sdl2/events.scm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'sdl2') diff --git a/sdl2/events.scm b/sdl2/events.scm index 56bf233..2c303c7 100644 --- a/sdl2/events.scm +++ b/sdl2/events.scm @@ -155,6 +155,9 @@ make-controller-device-event controller-device-event? + controller-added-event? + controller-removed-event? + controller-remapped-event? controller-device-event-timestamp controller-device-event-which controller-device-event-action @@ -1205,6 +1208,24 @@ (which controller-device-event-which) (action controller-device-event-action)) +(define (controller-added-event? event) + "Return #t if EVENT is a game controller device event with the +'added' action." + (and (controller-device-event? event) + (eq? (controller-device-event-action event) 'added))) + +(define (controller-removed-event? event) + "Return #t if EVENT is a game controller device event with the +'removed' action." + (and (controller-device-event? event) + (eq? (controller-device-event-action event) 'removed))) + +(define (controller-remapped-event? event) + "Return #t if EVENT is a game controller device event with the +'remapped' action." + (and (controller-device-event? event) + (eq? (controller-device-event-action event) 'remapped))) + (define (parse-controller-device-event ptr) (define types (list uint32 ; type -- cgit v1.2.3