Custom record printers for user events
It would be nice if it were possible to register custom record printers for user events, so that you can make a more informative printer than
#<sdl2:event foo code: 123>. For example:
(sdl2:register-events! '(collision)) (define (collision-entity1 ev) (pointer->address (sdl2:user-event-data1-raw ev))) (define (collision-entity2 ev) (pointer->address (sdl2:user-event-data2-raw ev))) ;;; Proposed new feature: (sdl2:register-event-printer! 'collision (lambda (ev out) (fprintf out "#<collision entity1: ~S entity2: ~S>" (collision-entity1 ev) (collision-entity2 ev))))
This would add the given lambda to an internal hash table or alist. Then the printer for sdl2:user-event would check to see if there is a printer registered for its event symbol. If so, it would call that lambda instead of the default output.