sdljava.event
public abstract class SDLEvent extends Object
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 $
Method Summary | |
---|---|
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.
|
static int | enableUNICODE(int mode)
Enables/Disables Unicode keyboard translation.
|
static SDLEventState | eventState(int type, SDLEventState state)
This function allows you to set the state of processing certain event types.
|
static SDLAppState | getAppState()
This function returns the current state of the application.
|
static String | getKeyName(int key)
Get the name of an SDL virtual keysym
|
static SDLMod | getModState()
Get the state of modifier keys.
|
static MouseState | getMouseState()
Retrieve the current state of the mouse
|
static MouseState | getRelativeMouseState()
Retrieve the relative current state of the mouse since the last call to getRelativeMouseState()
|
abstract int | getType()
The type of the this event
|
static int | joystickEventState(SDLEventState state)
This function is used to enable or disable joystick event processing.
|
static SDLEvent | pollEvent(boolean returnEvent)
Polls for currently pending events.
|
static SDLEvent | pollEvent()
Polls for currently pending events.
|
static SDLEvent | processEvent(SDL_Event swigEvent) |
static void | pumpEvents()
Pumps the event loop, gathering events from the input devices.
|
static void | setModState(SDLMod mod)
Describe setModState method here.
|
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 |
static SDLEvent | waitEvent()
Waits indefinitely for the next available event
|
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
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
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
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
Parameters: key a SDLKey
value
Returns: the SDL-defined name of the SDLKey key.
Returns: Returns the current state of the modifier keys (CTRL, ALT, etc.)
Returns: a SDLMouseState
value
Throws: SDLException if an error occurs
Returns: a MouseState
value
Throws: SDLException if an error occurs
Returns: The type of event
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
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
Returns: The next event if one is waiting, otherwise null
Throws: SDLException if an error occurs
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
method here.
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
Returns: The next event if one is waiting, otherwise null
Throws: SDLException if an error occurs