Commits

Christian Kellermann  committed fad8358

Poll all occured events and return a list of events to world-changes

  • Participants
  • Parent commits b5785af

Comments (0)

Files changed (1)

                (translate-key-event t event))
               (else (list 'unknown event))))))
 
+(define (collect-events)
+  (let pump ((events '()))
+    (let ((event (make-sdl-event)))
+      (if (sdl-poll-event! event)
+          (pump (cons event events))
+          (reverse events)))))
+
 (define (event-handler #!optional minimum-wait)
   (lambda ()
-    (let ((event (make-sdl-event))
+    (let (
           (last (current-milliseconds)))
       (call-with-current-continuation
        (lambda (escape)
            (let* ((now (current-milliseconds))
                   (dt (min (/ 1 30) (/ (- now last)
                                        1000))))
-             (sdl-pump-events)
              ((world-changes)
-              (translate-events (if (sdl-poll-event! event) event #f) escape)
+              (map (cut translate-events <> escape)
+                   (collect-events))
               dt
               escape)
              (show!)