Welcome to the CHICKEN Scheme pasting service
sdl-event-sym confounder pasted by avery on Tue Nov 26 06:46:29 2013
(define handle-keypress (lambda (event) (cond ((= (sdl-event-sym event) 27) (print "Escape Key Was Pressed!")) ; this works! ((= (sdl-event-sym event) 103) (new-texture-string "/home/avery/scheme-skeleton/Vasilisa.png"))))) ; as does this (define loup (lambda () (call/cc (lambda (break) (define event (make-sdl-event)) ; I know, this is crap. (sdl-poll-event! event) (cond ((eq? (sdl-event-type event) SDL_QUIT) (break #f)) ((= (sdl-event-sym event) 27) (break #f)) ; sdl-event-sym stops meaning anything, and defeats me ((eq? (sdl-event-type event) SDL_KEYDOWN) (set! tex-list (cons (handle-keypress event) tex-list)))) (display-handler) (usleep 100) (loup))))) ;; If I remove the single cond line that tests the sdl-event-sym against 27 (keysym for escape), the whole thing works as I wish. Instead, I get ;Error: sdl-event-sym: cannot extract value from this type of event: 1
a solution added by avery on Tue Nov 26 06:51:02 2013
The _VERY MOMENT_ I pasted this into the bin, I realized my mistake. Not all events have a keysym (mouse and window events fer instance). I just have to check (as I do with handle-keypress) to see if the type is SDL_KEYDOWN before trying to grab the sym. I hope the ones who go after me glean wisdom from my folly.