lispgames/cl-sdl2 — pull request #21 by nightfly19 (2014-05-19 12:55:23+00:00)
Title: Enable registering and handling of user defined event types

Makes it easy for new user-defined event types to be created and utilized and for lisp data to be associated with these new event types.

Implements two public functions:
* *register-user-event-type* Which provides an easy way to create new event types
* *push-user-event* Which provides an easy way to push these new events (and their associated data) onto the message queue

The attached user-data is accessed inside the event-handler via a new :user-data meta parameter.

Example usage:
```common-lisp
(sdl2:with-init (:everything)
(sdl2:with-window (win :flags '(:shown :opengl))
(sdl2:register-user-event-type :example-event-type)
(sdl2:push-user-event :example-event-type "hello")
(sdl2:with-event-loop (:method :poll)
(:example-event-type
(:user-data data)
(format t "data ~a accessible here~%" data))))
```

User-data storage implemented using a hashtable sdl2::*user-events* indexed with integer keys which are stored in the code field of the SDL_UserEvent view of the SDL_Event data structure. The keys are generated using SDL_AtomicIncRef. After an event has been handled its entry in the *user-events* table is removed.