Package sdljava.event

Provides the interface to SDL event management defined int SDL_events.h


Interface Summary
SDLEventListener Interface for handling SDLEvents.

Class Summary
MouseButtonState The current state of the mouse buttons.
MouseState The current state of the mouse.
SDLActiveEvent When the mouse leaves or enters the window area a SDL_APPMOUSEFOCUS type activation event occurs, if the mouse entered the window then gain will be 1, otherwise gain will be 0.
SDLEvent The SDL_Event is the core to all event handling in SDL, its probably the most important structure after SDL_Surface.
SDLEventManager The SDLEventManager is a thread helping us to handling SDL events.
SDLExposeEvent SDL_ExposeEvent is a member of the SDL_Event union and is used whan an event of type SDL_VIDEOEXPOSE is reported.
SDLJoyAxisEvent A SDLJoyAxisEvent event occurs whenever a user moves an axis on the joystick.
SDLJoyBallEvent A SDLJoyBallEvent event occurs when a user moves a trackball on the joystick.
SDLJoyButtonEvent A SDLJoyButtonEvent event occurs when ever a user presses or releases a button on a joystick.
SDLJoyHatEvent A SDLJoyHatEvent event occurs when ever a user moves a hat on the joystick.
SDLKey SDL key bindings.
SDLKeyboardEvent A keyboard event occurs when a key is released (type=SDK_KEYUP or state=SDL_RELEASED) and when a key is pressed (type=SDL_KEYDOWN or state=SDL_PRESSED).
SDLMod Set of possible key modifiers(mods)
SDLMouseButtonEvent When a mouse button press or release is detected then number of the button pressed (from 1 to 255, with 1 usually being the left button and 2 the right) is placed into button, the position of the mouse when this event occured is stored in the x and the y fields.
SDLMouseMotionEvent Simply put, a SDL_MOUSEMOTION type event occurs when a user moves the mouse within the application window or when SDL_WarpMouse is called.
SDLQuitEvent As can be seen, the SDL_QuitEvent structure serves no useful purpose.
SDLResizeEvent SDL_ResizeEvent is a member of the SDL_Event union and is used when an event of type SDL_VIDEORESIZE is reported.
SDLSysWMEvent Platform-dependent window manager event.
SDLUserEvent This event is unique, it is never created by SDL but only by the user.

Package sdljava.event Description

Provides the interface to SDL event management defined int SDL_events.h

Package Specification

NOTE: The following is not yet implemented:

Detailed documentation can be found here:

Event management under sdljava has been hightly optimized. NO NEW OBJECTS will ever be created by the event methods. Each time an event is returned from the SDL layer it will be the same C-level event structure (SDL_Event). When it is received on the java side after the native method invocation the SDLEvent class handles the event by placing into the appropriate static instance variable.

For instance if a keyboard event is received in waitEvent SDLEvent simply does the following:

return sdlKeyboardEvent;

The event is simply set on the already created static instance and returned to the caller.

The event handling should be quite fast and usable from java. Please note that due to the optimizations the event code (or any code within sdljava for that matter) should not be called concurrently from multiple threads.


You can use SDLEvent.waitEvent() to be passed incoming events. Also look at the example in in testsrc/sdljava/event directory.

See Also: