sdljava.event

Class SDLEvent

public abstract class SDLEvent extends Object

The SDL_Event is the core to all event handling in SDL, its probably the most important structure after SDL_Surface. SDL_Event is a union of all event structures used in SDL, using it is a simple matter of knowing which union member relates to which event type.

In the case of sdljava you can simply deal with the returned SDLEvent instance. For example if you have the code SDLEvent event = SDLEvent.waitEvent() you can now do an instanceof on the returned event to determine its type, cast it to the appropriate class, then deal with the data in any way you wish. NOTE: The following is not yet implemented:

Version: $Id: SDLEvent.java,v 1.21 2005/01/30 05:15:16 ivan_ganza Exp $

Author: Ivan Z. Ganza

Field Summary
static SDLActiveEventactiveEvent
static DummyEventdummyEvent
static SDLExposeEventexposeEvent
static SDLJoyAxisEventjoyAxisEvent
static SDLJoyBallEventjoyBallEvent
static SDLJoyButtonEventjoyButtonEvent
static SDLJoyHatEventjoyHatEvent
static SDLMouseButtonEventmouseButtonEvent
static SDLMouseMotionEventmouseMotionEvent
static SDLQuitEventquitEvent
static SDLResizeEventresizeEvent
static SDLKeyboardEventsdlKeyboardEvent
static SDL_EventswigEvent
static SDLSysWMEventsysWMEvent
static intSDL_ACTIVEEVENT
static intSDL_ACTIVEEVENTMASK
static intSDL_ADDEVENT
static intSDL_APPACTIVE
static intSDL_APPINPUTFOCUS
static intSDL_APPMOUSEFOCUS
static intSDL_BUTTON_LEFT
static intSDL_BUTTON_MIDDLE
static intSDL_BUTTON_RIGHT
static intSDL_BUTTON_WHEELDOWN
static intSDL_BUTTON_WHEELUP
static intSDL_DEFAULT_REPEAT_DELAY
static intSDL_DEFAULT_REPEAT_INTERVAL
static intSDL_DISABLE
static intSDL_ENABLE
static intSDL_GETEVENT
static intSDL_IGNORE
static intSDL_JOYAXISMOTION
static intSDL_JOYAXISMOTIONMASK
static intSDL_JOYBALLMOTION
static intSDL_JOYBALLMOTIONMASK
static intSDL_JOYBUTTONDOWN
static intSDL_JOYBUTTONDOWNMASK
static intSDL_JOYBUTTONUP
static intSDL_JOYBUTTONUPMASK
static intSDL_JOYEVENTMASK
static intSDL_JOYHATMOTION
static intSDL_JOYHATMOTIONMASK
static intSDL_KEYDOWN
static intSDL_KEYDOWNMASK
static intSDL_KEYUP
static intSDL_KEYUPMASK
static intSDL_MOUSEBUTTONDOWN
static intSDL_MOUSEBUTTONDOWNMASK
static intSDL_MOUSEBUTTONUP
static intSDL_MOUSEBUTTONUPMASK
static intSDL_MOUSEEVENTMASK
static intSDL_MOUSEMOTION
static intSDL_MOUSEMOTIONMASK
static intSDL_NOEVENT
static intSDL_PEEKEVENT
static intSDL_PRESSED
static intSDL_QUERY
static intSDL_QUIT
static intSDL_QUITMASK
static intSDL_RELEASED
static intSDL_SYSWMEVENT
static intSDL_SYSWMEVENTMASK
static intSDL_USEREVENT
static intSDL_VIDEOEXPOSE
static intSDL_VIDEOEXPOSEMASK
static intSDL_VIDEORESIZE
static intSDL_VIDEORESIZEMASK
static SDLUserEventuserEvent
Method Summary
static voidenableKeyRepeat(int delay, int interval)
Enables or disables the keyboard repeat rate. delay specifies how long the key must be pressed before it begins repeating, it then repeats at the speed specified by interval.
static intenableUNICODE(int mode)
Enables/Disables Unicode keyboard translation.
static SDLEventStateeventState(int type, SDLEventState state)
This function allows you to set the state of processing certain event types.
static SDLAppStategetAppState()
This function returns the current state of the application.
static StringgetKeyName(int key)
Get the name of an SDL virtual keysym
static SDLModgetModState()
Get the state of modifier keys.
static MouseStategetMouseState()
Retrieve the current state of the mouse
static MouseStategetRelativeMouseState()
Retrieve the relative current state of the mouse since the last call to getRelativeMouseState()
abstract intgetType()
The type of the this event
static intjoystickEventState(SDLEventState state)
This function is used to enable or disable joystick event processing.
static SDLEventpollEvent(boolean returnEvent)
Polls for currently pending events.
static SDLEventpollEvent()
Polls for currently pending events.
static SDLEventprocessEvent(SDL_Event swigEvent)
static voidpumpEvents()
Pumps the event loop, gathering events from the input devices.
static voidsetModState(SDLMod mod)
Describe setModState method here.
static SDLEventwaitEvent(boolean returnEvent)
Waits indefinitely for the next available event

If returnEvent is true the next event is removed from the queue and returned (if one exists)

Otherwise the method simply returns once the next event is available

static SDLEventwaitEvent()
Waits indefinitely for the next available event

Field Detail

activeEvent

static SDLActiveEvent activeEvent

dummyEvent

static DummyEvent dummyEvent

exposeEvent

static SDLExposeEvent exposeEvent

joyAxisEvent

static SDLJoyAxisEvent joyAxisEvent

joyBallEvent

static SDLJoyBallEvent joyBallEvent

joyButtonEvent

static SDLJoyButtonEvent joyButtonEvent

joyHatEvent

static SDLJoyHatEvent joyHatEvent

mouseButtonEvent

static SDLMouseButtonEvent mouseButtonEvent

mouseMotionEvent

static SDLMouseMotionEvent mouseMotionEvent

quitEvent

static SDLQuitEvent quitEvent

resizeEvent

static SDLResizeEvent resizeEvent

sdlKeyboardEvent

static SDLKeyboardEvent sdlKeyboardEvent

swigEvent

static SDL_Event swigEvent

sysWMEvent

static SDLSysWMEvent sysWMEvent

SDL_ACTIVEEVENT

public static final int SDL_ACTIVEEVENT

SDL_ACTIVEEVENTMASK

public static final int SDL_ACTIVEEVENTMASK

SDL_ADDEVENT

public static final int SDL_ADDEVENT

SDL_APPACTIVE

public static final int SDL_APPACTIVE

SDL_APPINPUTFOCUS

public static final int SDL_APPINPUTFOCUS

SDL_APPMOUSEFOCUS

public static final int SDL_APPMOUSEFOCUS

SDL_BUTTON_LEFT

public static final int SDL_BUTTON_LEFT

SDL_BUTTON_MIDDLE

public static final int SDL_BUTTON_MIDDLE

SDL_BUTTON_RIGHT

public static final int SDL_BUTTON_RIGHT

SDL_BUTTON_WHEELDOWN

public static final int SDL_BUTTON_WHEELDOWN

SDL_BUTTON_WHEELUP

public static final int SDL_BUTTON_WHEELUP

SDL_DEFAULT_REPEAT_DELAY

public static final int SDL_DEFAULT_REPEAT_DELAY

SDL_DEFAULT_REPEAT_INTERVAL

public static final int SDL_DEFAULT_REPEAT_INTERVAL

SDL_DISABLE

public static final int SDL_DISABLE

SDL_ENABLE

public static final int SDL_ENABLE

SDL_GETEVENT

public static final int SDL_GETEVENT

SDL_IGNORE

public static final int SDL_IGNORE

SDL_JOYAXISMOTION

public static final int SDL_JOYAXISMOTION

SDL_JOYAXISMOTIONMASK

public static final int SDL_JOYAXISMOTIONMASK

SDL_JOYBALLMOTION

public static final int SDL_JOYBALLMOTION

SDL_JOYBALLMOTIONMASK

public static final int SDL_JOYBALLMOTIONMASK

SDL_JOYBUTTONDOWN

public static final int SDL_JOYBUTTONDOWN

SDL_JOYBUTTONDOWNMASK

public static final int SDL_JOYBUTTONDOWNMASK

SDL_JOYBUTTONUP

public static final int SDL_JOYBUTTONUP

SDL_JOYBUTTONUPMASK

public static final int SDL_JOYBUTTONUPMASK

SDL_JOYEVENTMASK

public static final int SDL_JOYEVENTMASK

SDL_JOYHATMOTION

public static final int SDL_JOYHATMOTION

SDL_JOYHATMOTIONMASK

public static final int SDL_JOYHATMOTIONMASK

SDL_KEYDOWN

public static final int SDL_KEYDOWN

SDL_KEYDOWNMASK

public static final int SDL_KEYDOWNMASK

SDL_KEYUP

public static final int SDL_KEYUP

SDL_KEYUPMASK

public static final int SDL_KEYUPMASK

SDL_MOUSEBUTTONDOWN

public static final int SDL_MOUSEBUTTONDOWN

SDL_MOUSEBUTTONDOWNMASK

public static final int SDL_MOUSEBUTTONDOWNMASK

SDL_MOUSEBUTTONUP

public static final int SDL_MOUSEBUTTONUP

SDL_MOUSEBUTTONUPMASK

public static final int SDL_MOUSEBUTTONUPMASK

SDL_MOUSEEVENTMASK

public static final int SDL_MOUSEEVENTMASK

SDL_MOUSEMOTION

public static final int SDL_MOUSEMOTION

SDL_MOUSEMOTIONMASK

public static final int SDL_MOUSEMOTIONMASK

SDL_NOEVENT

public static final int SDL_NOEVENT

SDL_PEEKEVENT

public static final int SDL_PEEKEVENT

SDL_PRESSED

public static final int SDL_PRESSED

SDL_QUERY

public static final int SDL_QUERY

SDL_QUIT

public static final int SDL_QUIT

SDL_QUITMASK

public static final int SDL_QUITMASK

SDL_RELEASED

public static final int SDL_RELEASED

SDL_SYSWMEVENT

public static final int SDL_SYSWMEVENT

SDL_SYSWMEVENTMASK

public static final int SDL_SYSWMEVENTMASK

SDL_USEREVENT

public static final int SDL_USEREVENT

SDL_VIDEOEXPOSE

public static final int SDL_VIDEOEXPOSE

SDL_VIDEOEXPOSEMASK

public static final int SDL_VIDEOEXPOSEMASK

SDL_VIDEORESIZE

public static final int SDL_VIDEORESIZE

SDL_VIDEORESIZEMASK

public static final int SDL_VIDEORESIZEMASK

userEvent

static SDLUserEvent userEvent

Method Detail

enableKeyRepeat

public static void enableKeyRepeat(int delay, int interval)
Enables or disables the keyboard repeat rate. delay specifies how long the key must be pressed before it begins repeating, it then repeats at the speed specified by interval. Both delay and interval are expressed in milliseconds.

Setting delay to 0 disables key repeating completely. Good default values are SDL_DEFAULT_REPEAT_DELAY and SDL_DEFAULT_REPEAT_INTERVAL

Parameters: delay an int value interval an int value

Returns: a boolean value

Throws: SDLException if an error occurs

enableUNICODE

public static int enableUNICODE(int mode)
Enables/Disables Unicode keyboard translation.

To obtain the character codes corresponding to received keyboard events, Unicode translation must first be turned on using this function. The translation incurs a slight overhead for each keyboard event and is therefore disabled by default. For each subsequently received key down event, the unicode member of the SDL_keysym structure will then contain the corresponding character code, or zero for keysyms that do not correspond to any character code.

A value of 1 for enable enables Unicode translation; 0 disables it, and -1 leaves it unchanged (useful for querying the current translation mode).

Note that only key press events will be translated, not release events.

Parameters: enable a boolean value

Returns: The previous translation mode

Throws: SDLException if an error occurs

eventState

public static SDLEventState eventState(int type, SDLEventState state)
This function allows you to set the state of processing certain event types.

If state is set to SDL_IGNORE, that event type will be automatically dropped from the event queue and will not be filtered.

If state is set to SDL_ENABLE, that event type will be processed normally.

If state is set to SDL_QUERY, SDL_EventState will return the current processing state of the specified event type.

A list of event types can be found in the SDL_Event section.

Parameters: type a SDLEventType value state a SDLEventState value

Returns: a SDLEventState value

Throws: SDLException if an error occurs

getAppState

public static SDLAppState getAppState()
This function returns the current state of the application.

The value returned is a bitwise combination of:

SDL_APPMOUSEFOCUS The application has mouse focus.

SDL_APPINPUTFOCUS The application has keyboard focus

SDL_APPACTIVE The application is visible

Returns: an int value

Throws: SDLException if an error occurs

getKeyName

public static String getKeyName(int key)
Get the name of an SDL virtual keysym

Parameters: key a SDLKey value

Returns: the SDL-defined name of the SDLKey key.

getModState

public static SDLMod getModState()
Get the state of modifier keys.

Returns: Returns the current state of the modifier keys (CTRL, ALT, etc.)

getMouseState

public static MouseState getMouseState()
Retrieve the current state of the mouse

Returns: a SDLMouseState value

Throws: SDLException if an error occurs

getRelativeMouseState

public static MouseState getRelativeMouseState()
Retrieve the relative current state of the mouse since the last call to getRelativeMouseState()

Returns: a MouseState value

Throws: SDLException if an error occurs

getType

public abstract int getType()
The type of the this event

Returns: The type of event

joystickEventState

public static int joystickEventState(SDLEventState state)
This function is used to enable or disable joystick event processing. With joystick event processing disabled you will have to update joystick states with SDL_JoystickUpdate and read the joystick information manually. state is either SDL_QUERY, SDL_ENABLE or SDL_IGNORE.

Note: Joystick event handling is preferred

Parameters: state a SDLEventState value

Returns: If state is SDL_QUERY then the current state is returned, otherwise the new processing state is returned.

Throws: SDLException if an error occurs

pollEvent

public static SDLEvent pollEvent(boolean returnEvent)
Polls for currently pending events.

If returnEvent is true the next event is removed from the queue and returned (if one exists)

Parameters: returnEvent specifies if the event should be returned

Returns: If returnEvent is true: The next event if one is waiting, otherwise null

If returnEvent is false: non-null SDLEvent instance if an event is available, otherwise null

Throws: SDLException if an error occurs

pollEvent

public static SDLEvent pollEvent()
Polls for currently pending events.

Returns: The next event if one is waiting, otherwise null

Throws: SDLException if an error occurs

processEvent

static final SDLEvent processEvent(SDL_Event swigEvent)

pumpEvents

public static void pumpEvents()
Pumps the event loop, gathering events from the input devices.

SDL_PumpEvents gathers all the pending input information from devices and places it on the event queue. Without calls to SDL_PumpEvents no events would ever be placed on the queue. Often the need for calls to SDL_PumpEvents is hidden from the user since SDL_PollEvent and SDL_WaitEvent implicitly call SDL_PumpEvents. However, if you are not polling or waiting for events (e.g. you are filtering them), then you must call SDL_PumpEvents to force an event queue update.

Note: You can only call this function in the thread that set the video mode.

Throws: SDLException if an error occurs

setModState

public static void setModState(SDLMod mod)
Describe setModState method here.

waitEvent

public static SDLEvent waitEvent(boolean returnEvent)
Waits indefinitely for the next available event

If returnEvent is true the next event is removed from the queue and returned (if one exists)

Otherwise the method simply returns once the next event is available

Parameters: returnEvent specifies if the event should be returned

Returns: The next event if one is waiting and returnEvent is true, otherwise null

Throws: SDLException if an error occurs

waitEvent

public static SDLEvent waitEvent()
Waits indefinitely for the next available event

Returns: The next event if one is waiting, otherwise null

Throws: SDLException if an error occurs