ScummVM API documentation
SdlEventSource Class Reference

#include <sdl-events.h>

Inheritance diagram for SdlEventSource:
Common::EventSource OPEventSource PS3SdlEventSource PSP2EventSource RISCOSSdlEventSource SamsungTVSdlEventSource SwitchEventSource

Public Member Functions

void setGraphicsManager (SdlGraphicsManager *gMan)
 
virtual bool pollEvent (Common::Event &event)
 
void fakeWarpMouse (const int x, const int y)
 
bool isJoystickConnected () const
 
void setEngineRunning (bool value)
 
- Public Member Functions inherited from Common::EventSource
virtual bool allowMapping () const
 

Protected Member Functions

void loadGameControllerMappingFile ()
 
void openJoystick (int joystickIndex)
 
void closeJoystick ()
 
virtual void preprocessEvents (SDL_Event *event)
 
virtual bool dispatchSDLEvent (SDL_Event &ev, Common::Event &event)
 
virtual bool processMouseEvent (Common::Event &event, int x, int y, int relx=0, int rely=0)
 
virtual bool remapKey (SDL_Event &ev, Common::Event &event)
 
virtual int mapKey (SDL_Keycode key, SDL_Keymod mod, Uint16 unicode)
 
virtual void SDLModToOSystemKeyFlags (SDL_Keymod mod, Common::Event &event)
 
Common::KeyCode SDLToOSystemKeycode (const SDL_Keycode key)
 
bool handleResizeEvent (Common::Event &event, int w, int h)
 
uint32 obtainUnicode (const SDL_Keysym keySym)
 
SDL_Keycode obtainKeycode (const SDL_Keysym keySym)
 
Event Handlers

Handlers for specific SDL events, called by SdlEventSource::dispatchSDLEvent(). This way, if a managers inherits fromt this SDL events manager, it can change the behavior of only a single event, without having to override all of SdlEventSource::dispatchSDLEvent().

virtual bool handleKeyDown (SDL_Event &ev, Common::Event &event)
 
virtual bool handleKeyUp (SDL_Event &ev, Common::Event &event)
 
virtual bool handleMouseMotion (SDL_Event &ev, Common::Event &event)
 
virtual bool handleMouseButtonDown (SDL_Event &ev, Common::Event &event)
 
virtual bool handleMouseButtonUp (SDL_Event &ev, Common::Event &event)
 
virtual bool handleSysWMEvent (SDL_Event &ev, Common::Event &event)
 
virtual int mapSDLJoystickButtonToOSystem (Uint8 sdlButton)
 
virtual bool handleJoyButtonDown (SDL_Event &ev, Common::Event &event)
 
virtual bool handleJoyButtonUp (SDL_Event &ev, Common::Event &event)
 
virtual bool handleJoyAxisMotion (SDL_Event &ev, Common::Event &event)
 
virtual bool handleJoyHatMotion (SDL_Event &ev, Common::Event &event)
 

Protected Attributes

bool _scrollLock
 
bool _engineRunning
 
int _mouseX
 
int _mouseY
 
SDL_Joystick * _joystick
 
int _lastScreenID
 
SdlGraphicsManager_graphicsManager
 
bool _queuedFakeMouseMove
 
Common::Event _fakeMouseMove
 
uint8 _lastHatPosition
 

Detailed Description

The SDL event source.

Member Function Documentation

◆ pollEvent()

virtual bool SdlEventSource::pollEvent ( Common::Event event)
virtual

Gets and processes SDL events.

Implements Common::EventSource.

Reimplemented in SwitchEventSource.

◆ fakeWarpMouse()

void SdlEventSource::fakeWarpMouse ( const int  x,
const int  y 
)

Emulates a mouse movement that would normally be caused by a mouse warp of the system mouse.

◆ isJoystickConnected()

bool SdlEventSource::isJoystickConnected ( ) const

Returns whether a joystick is currently connected

◆ setEngineRunning()

void SdlEventSource::setEngineRunning ( bool  value)

Sets whether a game is currently running

◆ loadGameControllerMappingFile()

void SdlEventSource::loadGameControllerMappingFile ( )
protected

Search for a game controller db file and load it.

◆ openJoystick()

void SdlEventSource::openJoystick ( int  joystickIndex)
protected

Open the SDL joystick with the specified index

After this function completes successfully, SDL sends events for the device.

If the joystick is also a SDL game controller, open it as a controller so an extended button mapping can be used.

◆ closeJoystick()

void SdlEventSource::closeJoystick ( )
protected

Close the currently open joystick if any

◆ preprocessEvents()

virtual void SdlEventSource::preprocessEvents ( SDL_Event *  event)
inlineprotectedvirtual

Pre process an event before it is dispatched.

Reimplemented in PSP2EventSource, and PS3SdlEventSource.

◆ dispatchSDLEvent()

virtual bool SdlEventSource::dispatchSDLEvent ( SDL_Event &  ev,
Common::Event event 
)
protectedvirtual

Dispatchs SDL events for each handler.

◆ processMouseEvent()

virtual bool SdlEventSource::processMouseEvent ( Common::Event event,
int  x,
int  y,
int  relx = 0,
int  rely = 0 
)
protectedvirtual

Assigns the mouse coords to the mouse event. Furthermore notify the graphics manager about the position change. The parameters relx and rely for relative mouse movement

◆ remapKey()

virtual bool SdlEventSource::remapKey ( SDL_Event &  ev,
Common::Event event 
)
protectedvirtual

Remaps key events. This allows platforms to configure their custom keys.

Reimplemented in OPEventSource, and SamsungTVSdlEventSource.

◆ mapKey()

virtual int SdlEventSource::mapKey ( SDL_Keycode  key,
SDL_Keymod  mod,
Uint16  unicode 
)
protectedvirtual

Maps the ASCII value of key

◆ SDLModToOSystemKeyFlags()

virtual void SdlEventSource::SDLModToOSystemKeyFlags ( SDL_Keymod  mod,
Common::Event event 
)
protectedvirtual

Configures the key modifiers flags status

◆ SDLToOSystemKeycode()

Common::KeyCode SdlEventSource::SDLToOSystemKeycode ( const SDL_Keycode  key)
protected

Translates SDL key codes to OSystem key codes

◆ handleResizeEvent()

bool SdlEventSource::handleResizeEvent ( Common::Event event,
int  w,
int  h 
)
protected

Notify graphics manager of a resize request.

◆ obtainUnicode()

uint32 SdlEventSource::obtainUnicode ( const SDL_Keysym  keySym)
protected

Extracts unicode information for the specific key sym. May only be used for key down events.

◆ obtainKeycode()

SDL_Keycode SdlEventSource::obtainKeycode ( const SDL_Keysym  keySym)
protected

Extracts the keycode for the specified key sym.

Member Data Documentation

◆ _scrollLock

bool SdlEventSource::_scrollLock
protected

Scroll lock state - since SDL doesn't track it

◆ _joystick

SDL_Joystick* SdlEventSource::_joystick
protected

Joystick

◆ _lastScreenID

int SdlEventSource::_lastScreenID
protected

Last screen id for checking if it was modified

◆ _graphicsManager

SdlGraphicsManager* SdlEventSource::_graphicsManager
protected

The associated graphics manager.

◆ _queuedFakeMouseMove

bool SdlEventSource::_queuedFakeMouseMove
protected

Whether _fakeMouseMove contains an event we need to send.

◆ _fakeMouseMove

Common::Event SdlEventSource::_fakeMouseMove
protected

A fake mouse motion event sent when the graphics manager is told to warp the mouse but the system mouse is unable to be warped (e.g. because the window is not focused).


The documentation for this class was generated from the following file: