diff options
author | David Thompson <dthompson2@worcester.edu> | 2015-12-21 11:40:38 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2015-12-21 11:40:38 -0500 |
commit | 3bac7c76c894fd39721c16d5005dbc7d23fda8d6 (patch) | |
tree | eea460deb6431953cd5b949a2c0b1b41441b3723 /sdl2/events.scm | |
parent | 3c0cdecfbc1cfe11415271ee08210307ef42ecf8 (diff) |
events: Add quit event.
* sdl2/events.scm (<quit-event>): New record type.
(make-quit-event, quit-event?, quit-event-timestamp, parse-quit-event):
New procedures.
(poll-event): Add support for SDL_QUIT events.
Diffstat (limited to 'sdl2/events.scm')
-rw-r--r-- | sdl2/events.scm | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sdl2/events.scm b/sdl2/events.scm index e32c8ef..282fc34 100644 --- a/sdl2/events.scm +++ b/sdl2/events.scm @@ -33,7 +33,11 @@ #:use-module (system foreign) #:use-module ((sdl2 bindings) #:prefix ffi:) #:use-module (sdl2) - #:export (make-window-event + #:export (make-quit-event + quit-event? + quit-event-timestamp + + make-window-event window-event? window-event-timestamp window-event-window-id @@ -102,6 +106,21 @@ ;;; +;;; Quit +;;; + +(define-record-type <quit-event> + (make-quit-event timestamp) + quit-event? + (timestamp quit-event-timestamp)) + +(define (parse-quit-event ptr) + (match (parse-c-struct ptr (list uint32 uint32)) + ((_ timestamp) + (make-quit-event timestamp)))) + + +;;; ;;; Window ;;; @@ -881,6 +900,8 @@ (and (= result 1) (let ((type (sdl-event-type e))) (cond + ((= type ffi:SDL_QUIT) + (parse-quit-event ptr)) ((= type ffi:SDL_WINDOWEVENT) (parse-window-event ptr)) ((or (= type ffi:SDL_KEYDOWN) |