ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

sdl-events.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef BACKEND_EVENTS_SDL_H
00024 #define BACKEND_EVENTS_SDL_H
00025 
00026 #include "backends/platform/sdl/sdl-sys.h"
00027 #include "backends/graphics/sdl/sdl-graphics.h"
00028 
00029 #include "common/events.h"
00030 
00031 // Type names which changed between SDL 1.2 and SDL 2.
00032 #if !SDL_VERSION_ATLEAST(2, 0, 0)
00033 typedef SDLKey     SDL_Keycode;
00034 typedef SDLMod     SDL_Keymod;
00035 typedef SDL_keysym SDL_Keysym;
00036 #endif
00037 
00041 class SdlEventSource : public Common::EventSource {
00042 public:
00043     SdlEventSource();
00044     virtual ~SdlEventSource();
00045 
00046     void setGraphicsManager(SdlGraphicsManager *gMan) { _graphicsManager = gMan; }
00047 
00051     virtual bool pollEvent(Common::Event &event);
00052 
00057     void fakeWarpMouse(const int x, const int y);
00058 
00060     bool isJoystickConnected() const;
00061 
00063     void setEngineRunning(bool value);
00064 
00065 protected:
00067     bool _scrollLock;
00068 
00069     bool _engineRunning;
00070 
00071     int _mouseX;
00072     int _mouseY;
00073 
00075     SDL_Joystick *_joystick;
00076 
00077 #if SDL_VERSION_ATLEAST(2, 0, 0)
00078 
00079     SDL_GameController *_controller;
00080 #endif
00081 
00083     int _lastScreenID;
00084 
00088     SdlGraphicsManager *_graphicsManager;
00089 
00093     void loadGameControllerMappingFile();
00094 
00103     void openJoystick(int joystickIndex);
00104 
00108     void closeJoystick();
00109 
00113     virtual void preprocessEvents(SDL_Event *event) {}
00114 
00118     virtual bool dispatchSDLEvent(SDL_Event &ev, Common::Event &event);
00119 
00120 
00128 
00129     virtual bool handleKeyDown(SDL_Event &ev, Common::Event &event);
00130     virtual bool handleKeyUp(SDL_Event &ev, Common::Event &event);
00131     virtual bool handleMouseMotion(SDL_Event &ev, Common::Event &event);
00132     virtual bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event);
00133     virtual bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event);
00134     virtual bool handleSysWMEvent(SDL_Event &ev, Common::Event &event);
00135     virtual int mapSDLJoystickButtonToOSystem(Uint8 sdlButton);
00136     virtual bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);
00137     virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
00138     virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event);
00139     virtual bool handleJoyHatMotion(SDL_Event &ev, Common::Event &event);
00140 
00141 #if SDL_VERSION_ATLEAST(2, 0, 0)
00142     virtual bool handleJoystickAdded(const SDL_JoyDeviceEvent &device, Common::Event &event);
00143     virtual bool handleJoystickRemoved(const SDL_JoyDeviceEvent &device, Common::Event &event);
00144     virtual int mapSDLControllerButtonToOSystem(Uint8 sdlButton);
00145     virtual bool handleControllerButton(const SDL_Event &ev, Common::Event &event, bool buttonUp);
00146     virtual bool handleControllerAxisMotion(const SDL_Event &ev, Common::Event &event);
00147 #endif
00148 
00150 
00157     virtual bool processMouseEvent(Common::Event &event, int x, int y, int relx = 0, int rely = 0);
00158 
00163     virtual bool remapKey(SDL_Event &ev, Common::Event &event);
00164 
00168     virtual int mapKey(SDL_Keycode key, SDL_Keymod mod, Uint16 unicode);
00169 
00173     virtual void SDLModToOSystemKeyFlags(SDL_Keymod mod, Common::Event &event);
00174 
00178     Common::KeyCode SDLToOSystemKeycode(const SDL_Keycode key);
00179 
00183     bool handleResizeEvent(Common::Event &event, int w, int h);
00184 
00189     uint32 obtainUnicode(const SDL_Keysym keySym);
00190 
00194     SDL_Keycode obtainKeycode(const SDL_Keysym keySym);
00195 
00199     bool _queuedFakeMouseMove;
00200 
00206     Common::Event _fakeMouseMove;
00207 
00208     uint8 _lastHatPosition;
00209 
00210 #if SDL_VERSION_ATLEAST(2, 0, 0)
00211 
00214     bool _queuedFakeKeyUp;
00215 
00220     Common::Event _fakeKeyUp;
00221 #endif
00222 };
00223 
00224 #endif


Generated on Sat Jul 11 2020 05:01:03 for ResidualVM by doxygen 1.7.1
curved edge   curved edge