.TH "SDLmm::Event" 3 "16 Jul 2001" "SDLmm" \" -*- nroff -*- .ad l .nh .SH NAME SDLmm::Event \- The general \fBEvent\fP class. .SH SYNOPSIS .br .PP \fC#include \fP .PP .SS "Public Methods" .in +1c .ti -1c .RI "bool \fBPoll\fP (bool fetch=true)" .br .RI "\fIPolls for currently pending events.\fP" .ti -1c .RI "bool \fBWait\fP (bool fetch=true)" .br .RI "\fIWaits indefinitely for the next available event.\fP" .ti -1c .RI "bool \fBPush\fP ()" .br .RI "\fIPush this event onto the event queue.\fP" .in -1c .SS "Static Public Methods" .PP .RI "\fBEvent Methods\fP" .br .in +1c .in +1c .ti -1c .RI "void \fBPumpEvents\fP ()" .br .RI "\fIPumps the event loop, gathering events from the input devices.\fP" .ti -1c .RI "void \fBSetEventFilter\fP (SDL_EventFilter filter)" .br .RI "\fISets up a filter to process all events before they are posted to the event queue.\fP" .ti -1c .RI "SDL_EventFilter \fBGetEventFilter\fP ()" .br .RI "\fIRetrieves a pointer to the event filter.\fP" .ti -1c .RI "Uint8 \fBEventState\fP (Uint8 type, int state)" .br .RI "\fISet the state of processing for certain events.\fP" .ti -1c .RI "void \fBHandleEvents\fP (\fBEventHandler\fP &handler)" .br .RI "\fIHandle all queued events using the specified \fBEventHandler\fP.\fP" .in -1c .in -1c .PP .RI "\fBKeyboard Methods\fP" .br .in +1c .in +1c .ti -1c .RI "Uint8* \fBGetKeyState\fP (int &numkeys)" .br .RI "\fIGet a snapshot of the current keyboard state.\fP" .ti -1c .RI "Uint8* \fBGetKeyState\fP ()" .br .RI "\fIGet a snapshot of the current keyboard state.\fP" .ti -1c .RI "SDLMod \fBGetModState\fP ()" .br .RI "\fIGet the state of modifier keys.\fP" .ti -1c .RI "void \fBSetModState\fP (SDLMod modstate)" .br .RI "\fISet the current key modifier state.\fP" .ti -1c .RI "char* \fBGetKeyName\fP (SDLKey key)" .br .RI "\fIGet the name of an SDL virtual key symbol.\fP" .ti -1c .RI "bool \fBEnableUNICODE\fP (bool enable=true)" .br .RI "\fIEnable UNICODE keyboard translation.\fP" .ti -1c .RI "bool \fBDisableUNICODE\fP ()" .br .RI "\fIDisable UNICODE translation.\fP" .ti -1c .RI "bool \fBQueryUNICODE\fP ()" .br .RI "\fIQuery the current UNICODE translation mode.\fP" .ti -1c .RI "bool \fBEnableKeyRepeat\fP (int delay=SDL_DEFAULT_REPEAT_DELAY, int interval=SDL_DEFAULT_REPEAT_DELAY)" .br .RI "\fISet keyboard repeat rate.\fP" .in -1c .in -1c .PP .RI "\fBMouse Methods\fP" .br .in +1c .in +1c .ti -1c .RI "Uint8 \fBGetMouseState\fP (int *x=0, int *y=0)" .br .RI "\fIRetrieve the current state of the mouse.\fP" .ti -1c .RI "Uint8 \fBGetRelativeMouseState\fP (int *x, int *y)" .br .RI "\fIRetrieve the current state of the mouse.\fP" .in -1c .in -1c .PP .RI "\fBOther Methods\fP" .br .in +1c .in +1c .ti -1c .RI "Uint8 \fBGetAppState\fP ()" .br .RI "\fIGet the state of the application.\fP" .ti -1c .RI "int \fBJoystickEventState\fP (int state)" .br .RI "\fIEnable / disable joystick event polling.\fP" .in -1c .in -1c .SS "Public Attributes" .in +1c .ti -1c .RI "SDL_Event \fBme\fP" .br .RI "\fIThe event structure.\fP" .in -1c .SH "DETAILED DESCRIPTION" .PP The general \fBEvent\fP class. .PP The \fBEvent\fP class is the core to all event handling is \fBSDLmm\fP. It's probably the most important class after \fBSurface\fP. The \fBEvent\fP class can be used to store any type of event. .PP .SH "MEMBER FUNCTION DOCUMENTATION" .PP .SS "bool SDLmm::Event::DisableUNICODE ()\fC [inline, static]\fP" .PP Disable UNICODE translation. .PP \fBReturns: \fP .in +1c true if UNICODE translation was previously enabled, false otherwise. .PP \fBSee also: \fP .in +1c \fBEnableUNICODE\fP, \fBQueryUNICODE\fP .SS "bool SDLmm::Event::EnableKeyRepeat (int delay = SDL_DEFAULT_REPEAT_DELAY, int interval = SDL_DEFAULT_REPEAT_DELAY)\fC [static]\fP" .PP Set keyboard repeat rate. .PP Enables or disables the keyboard repeat rate. \fIdelay\fP specifies how long the key must be pressed before it begins repeating. It then repeats at the speed specified by \fIinterval\fP. Both \fIdelay\fP and \fIinterval\fP are expressed in milliseconds. .PP Setting delay to 0 disables key repeating completely. If called without parameters, the default values uses are SDL_DEFAULT_REPEAT_DELAY and SDL_DEFAULT_REPEAT_INTERVAL. .PP \fBReturns: \fP .in +1c true on success, false on failure. .PP \fBParameters: \fP .in +1c .TP \fB\fIdelay\fP\fP delay before key repeating starts in ms. .TP \fB\fIinterval\fP\fP delay between repeats in ms. .SS "bool SDLmm::Event::EnableUNICODE (bool enable = true)\fC [inline, static]\fP" .PP Enable UNICODE keyboard translation. .PP If you wish to translate a keysym to it's printable representation, you need to enable UNICODE translation using this function and then look in the unicode member of the SDL_keysym structure. This value will be zero for keysyms that do not have a printable representation. UNICODE translation is disabled by default as the conversion can cause a slight overhead. .PP \fBParameters: \fP .in +1c .TP \fB\fIenable\fP\fP if false, disable UNICODE translation (SDL compatibility) .PP \fBReturns: \fP .in +1c true if UNICODE translation was previously enabled, false otherwise. .PP \fBSee also: \fP .in +1c \fBDisableUNICODE\fP, \fBQueryUNICODE\fP .SS "Uint8 SDLmm::Event::EventState (Uint8 type, int state)\fC [static]\fP" .PP Set the state of processing for certain events. .PP This function allows you to set the state of processing certain event types. .PP If \fIstate\fP is set to SDL_IGNORE, that event type will be automatically dropped from the event queue and will not be filtered. .PP If \fIstate\fP is set to SDL_ENABLE, that event type will be processed normally. .PP If \fIstate\fP is set to SDL_QUERY, \fBEventState\fP() will return the current processing state of the specified event type. .PP A list of event types can be found in the SDL_Event section in the SDL documentation. .PP \fBParameters: \fP .in +1c .TP \fB\fItype\fP\fP the event type .TP \fB\fIstate\fP\fP the state as documented above. .PP \fBReturns: \fP .in +1c the current processing state for the specified event \fItype\fP .SS "Uint8 SDLmm::Event::GetAppState ()\fC [static]\fP" .PP Get the state of the application. .PP This function returns the current state of the application. The value returned is a bitwise combination of: .PP .TP \fBSDL_APPMOUSEFOCUS\fP - the application has mouse focus. .TP \fBSDL_APPINPUTFOCUS\fP - the application has keyboard focus .TP \fBSDL_APPACTIVE\fP - the application is visible .PP \fBReturns: \fP .in +1c The current state of the application. .SS "SDL_EventFilter SDLmm::Event::GetEventFilter ()\fC [static]\fP" .PP Retrieves a pointer to the event filter. .PP This function retrieves a pointer to the event filter that was previously set using \fBSetEventFilter\fP(). An SDL_EventFilter function is defined as: .PP .nf typedef int (*SDL_EventFilter)(const SDL_Event *event); .fi .PP \fBReturns: \fP .in +1c Returns a pointer to the event filter or 0 if no filter has been set. .PP \fBSee also: \fP .in +1c \fBSetEventFilter\fP() .SS "char * SDLmm::Event::GetKeyName (SDLKey key)\fC [static]\fP" .PP Get the name of an SDL virtual key symbol. .PP \fBReturns: \fP .in +1c the SDL defined name of the \fIkey\fP. .PP \fBParameters: \fP .in +1c .TP \fB\fIkey\fP\fP the SDLkey key symbol .SS "Uint8 * SDLmm::Event::GetKeyState ()\fC [static]\fP" .PP Get a snapshot of the current keyboard state. .PP Same as the \fBGetKeyState\fP(int &numkeys) method, used when you don't care how many keys were returned (i.e you want to check the state of a key that is known to exist). .PP \fBExample:\fP .in +1c .PP .nf Uint8 *keystate; keystate = Event::GetKeyState(); if (keystate[SDLK_RETURN]) cout << 'Return Key Pressed.\n'; .fi .PP \fBSee also: \fP .in +1c \fBGetModState\fP() .SS "Uint8 * SDLmm::Event::GetKeyState (int & numkeys)\fC [static]\fP" .PP Get a snapshot of the current keyboard state. .PP Gets a snapshot of the current keyboard state. The current state is returned as a pointer to an array. The size of this array is stored in \fInumkeys\fP. The array is indexed by the SDLK_* symbols. A value of 1 means the key is pressed and a value of 0 means its not. .PP \fBNote: \fP .in +1c Use \fBPumpEvents\fP() to update the state array. .PP \fBSee also: \fP .in +1c \fBPumpEvents\fP() .PP \fBParameters: \fP .in +1c .TP \fB\fInumkeys\fP\fP a reference to an integer used to store the size of the returned array. .SS "SDLMod SDLmm::Event::GetModState ()\fC [static]\fP" .PP Get the state of modifier keys. .PP Returns the current of the modifier keys (CTRL, ALT, etc.). .PP \fBReturns: \fP .in +1c The return value can be an OR'd combination of the SDLMod enum or one of the convenience defines: .TP KMOD_NONE .TP KMOD_LSHIFT .TP KMOD_RSHIFT .TP KMOD_LCTRL .TP KMOD_RCTRL .TP KMOD_LALT .TP KMOD_RALT .TP KMOD_LMETA .TP KMOD_RMETA .TP KMOD_NUM .TP KMOD_CAPS .TP KMOD_MODE .TP KMOD_CTRL (KMOD_LCTRL | KMOD_RCTRL) .TP KMOD_SHIFT (KMOD_LSHIFT | KMOD_RSHIFT) .TP KMOD_ALT (KMOD_LALT | KMOD_RALT) .TP KMOD_META (KMOD_LMETA | KMOD_RMETA) .PP \fBSee also: \fP .in +1c \fBSetModState\fP(), \fBGetModState\fP() .SS "Uint8 SDLmm::Event::GetMouseState (int * x = 0, int * y = 0)\fC [static]\fP" .PP Retrieve the current state of the mouse. .PP The current button state is returned as a button bitmask, which can be tested using the SDL_BUTTON(X) macros, and \fIx\fP and \fIy\fP are set to the current mouse cursor position. You can pass zero for either \fIx\fP or \fIy\fP. .PP \fBReturns: \fP .in +1c the button bitmask. .PP \fBParameters: \fP .in +1c .TP \fB\fIx, y\fP\fP pointers to integers where the current mouse coordinates will be stored. .SS "Uint8 SDLmm::Event::GetRelativeMouseState (int * x, int * y)\fC [static]\fP" .PP Retrieve the current state of the mouse. .PP The current button state is returned as a button bitmask, which can be tested using the SDL_BUTTON(X) macros, and \fIx\fP and \fIy\fP are set to the change in the mouse position since the last call to SDL_GetRelativeMouseState or since event initialization. You can pass zero for either \fIx\fP or \fIy\fP. .PP \fBReturns: \fP .in +1c the button bitmask. .PP \fBParameters: \fP .in +1c .TP \fB\fIx, y\fP\fP pointers to integers for mouse coordinates or relative change. .SS "void SDLmm::Event::HandleEvents (\fBEventHandler\fP & handler)\fC [static]\fP" .PP Handle all queued events using the specified \fBEventHandler\fP. .PP This function polls for active events and calls the event callback methods. To actually handle any events, you need to create a derivate of the \fBEventHandler\fP class reimplementing the callbacks for the events you're interested in. See the \fBEventHandler\fP documentation for more details. .PP \fBParameters: \fP .in +1c .TP \fB\fIhandler\fP\fP the \fBEventHandler\fP which should handle the events. .PP \fBSee also: \fP .in +1c \fBEventHandler\fP .SS "int SDLmm::Event::JoystickEventState (int state)\fC [static]\fP" .PP Enable / disable joystick event polling. .PP .SS "bool SDLmm::Event::Poll (bool fetch = true)" .PP Polls for currently pending events. .PP If there are any pending events, it will by default be removed from the queue and stored in this class instance. .PP \fBParameters: \fP .in +1c .TP \fB\fIfetch\fP\fP if false, only poll for pending events but don't fetch it. .PP \fBReturns: \fP .in +1c true if any events were pending. .PP \fBSee also: \fP .in +1c \fBEventHandler\fP, \fBHandleEvents\fP(), \fBWait\fP() .SS "void SDLmm::Event::PumpEvents ()\fC [static]\fP" .PP Pumps the event loop, gathering events from the input devices. .PP \fBPumpEvents\fP() gathers all the pending input information from devices and places it on the event queue. Without calls to \fBPumpEvents\fP() no events would ever be placed on the queue. Often the calls to \fBPumpEvents\fP() is hidden from the user since Poll and Wait implicitly call Pump. However, if you are not polling or waiting for events (e.g. your filtering them), then you must call Pump to force an event queue update. .PP \fBNote: \fP .in +1c You can only call this function in the thread that set the video mode. .SS "bool SDLmm::Event::Push ()" .PP Push this event onto the event queue. .PP The event queue can actually be used as a two way communication channel. Not only can events be read from the queue, but the user can also push their own events onto it. .PP \fBNote: \fP .in +1c Pushing device input events onto the queue doesn't modify the state of the device within SDL. .PP \fBWarning: \fP .in +1c Make sure to initialize the \fBEvent\fP before pushing it! .PP \fBReturns: \fP .in +1c true on success, falese if the \fBEvent\fP couldn't be pushed. .SS "bool SDLmm::Event::QueryUNICODE ()\fC [inline, static]\fP" .PP Query the current UNICODE translation mode. .PP This function checks whether UNICODE translation is enabled or disabled. .PP \fBReturns: \fP .in +1c true if UNICODE translation is enabled, false otherwise. .PP \fBSee also: \fP .in +1c \fBEnableUNICODE\fP, \fBDisableUNICODE\fP .SS "void SDLmm::Event::SetEventFilter (SDL_EventFilter filter)\fC [static]\fP" .PP Sets up a filter to process all events before they are posted to the event queue. .PP This function sets up a filter to process all events before they are posted to the event queue. This is a very powerful and flexible feature. The filter is prototyped as: .PP .nf typedef int (*SDL_EventFilter)(const SDL_Event *event); .fi .PP If the filter returns 1, then the event will be added to the internal queue. If it returns 0, then the event will be dropped from the queue. This allows selective filtering of dynamically. .PP There is one caveat when dealing with the SDL_QUITEVENT event type. The event filter is only called when the window manager desires to close the application window. If the event filter returns 1, then the window will be closed, otherwise the window will remain open if possible. If the quit event is generated by an interrupt signal, it will bypass the internal queue and be delivered to the application at the next event poll. .PP \fBNote: \fP .in +1c Events pushed onto the queue with \fBPush\fP() or Peep() do not get passed through the event filter. .PP \fBWarning: \fP .in +1c Be careful! The event filter function may run in a different thread so be careful what you do within it. .PP \fBSee also: \fP .in +1c \fBGetEventFilter\fP() .SS "void SDLmm::Event::SetModState (SDLMod modstate)\fC [static]\fP" .PP Set the current key modifier state. .PP The inverse of \fBGetModState\fP(), \fBSetModState\fP() allows you to impose modifier key states on your application. .PP Simply pass your desired modifier states into \fImodstate\fP. This value my be a logical OR'd combination of the symbols documented in \fBGetModState\fP(). .PP \fBParameters: \fP .in +1c .TP \fB\fImodstate\fP\fP the new key modifier state. .PP \fBSee also: \fP .in +1c \fBGetModState\fP() .SS "bool SDLmm::Event::Wait (bool fetch = true)" .PP Waits indefinitely for the next available event. .PP This function will wait for an event to become available. It will not return until an event is queued. .PP \fBParameters: \fP .in +1c .TP \fB\fIfetch\fP\fP if false, don't fetch and dequeue the event once it becomes available. .PP \fBReturns: \fP .in +1c true when an event became available and false if something went wrong. .PP \fBSee also: \fP .in +1c \fBEventHandler\fP, \fBHandleEvents\fP(), \fBPoll\fP() .SH "MEMBER DATA DOCUMENTATION" .PP .SS "SDL_Event SDLmm::Event::me" .PP The event structure. .PP If you use the event polling method, this is where the result is stored. You should consider using the more elegant \fBEventHandler\fP method instead however. .PP \fBSee also: \fP .in +1c \fBEventHandler\fP, \fBHandleEvents\fP(), \fBPoll\fP(), \fBWait\fP() .SH "AUTHOR" .PP Generated automatically by Doxygen for SDLmm from the source code.