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 // multiplier used to increase resolution for keyboard/joystick mouse
00032 #define MULTIPLIER 16
00033 
00037 class SdlEventSource : public Common::EventSource {
00038 public:
00039     SdlEventSource();
00040     virtual ~SdlEventSource();
00041 
00042     void setGraphicsManager(SdlGraphicsManager *gMan) { _graphicsManager = gMan; }
00043 
00047     virtual bool pollEvent(Common::Event &event);
00048 
00052     virtual void resetKeyboardEmulation(int16 x_max, int16 y_max);
00053 
00058     void fakeWarpMouse(const int x, const int y);
00059 
00060 protected:
00067 
00068     struct KbdMouse {
00069         int16 x, y, x_vel, y_vel, x_max, y_max, x_down_count, y_down_count, joy_x, joy_y;
00070         uint32 last_time, delay_time, x_down_time, y_down_time;
00071         bool modifier;
00072     };
00073     KbdMouse _km;
00074 
00076 
00078     bool _scrollLock;
00079 
00081     SDL_Joystick *_joystick;
00082 
00083 #if SDL_VERSION_ATLEAST(2, 0, 0)
00084 
00085     SDL_GameController *_controller;
00086 #endif
00087 
00089     int _lastScreenID;
00090 
00094     SdlGraphicsManager *_graphicsManager;
00095 
00099     void loadGameControllerMappingFile();
00100 
00109     void openJoystick(int joystickIndex);
00110 
00114     void closeJoystick();
00115 
00119     virtual void preprocessEvents(SDL_Event *event) {}
00120 
00124     virtual bool dispatchSDLEvent(SDL_Event &ev, Common::Event &event);
00125 
00126 
00134 
00135     virtual bool handleKeyDown(SDL_Event &ev, Common::Event &event);
00136     virtual bool handleKeyUp(SDL_Event &ev, Common::Event &event);
00137     virtual bool handleMouseMotion(SDL_Event &ev, Common::Event &event);
00138     virtual bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event);
00139     virtual bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event);
00140     virtual bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);
00141     virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
00142     virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event);
00143     virtual void updateKbdMouse();
00144     virtual bool handleKbdMouse(Common::Event &event);
00145 
00146 #if SDL_VERSION_ATLEAST(2, 0, 0)
00147     virtual bool handleJoystickAdded(const SDL_JoyDeviceEvent &event);
00148     virtual bool handleJoystickRemoved(const SDL_JoyDeviceEvent &device);
00149     virtual bool handleControllerButton(const SDL_Event &ev, Common::Event &event, bool buttonUp);
00150     virtual bool handleControllerAxisMotion(const SDL_Event &ev, Common::Event &event);
00151 #endif
00152 
00154 
00158     virtual bool handleAxisToMouseMotion(int16 xAxis, int16 yAxis);
00159 
00164     int16 computeJoystickMouseSpeedFactor() const;
00165 
00172     virtual bool processMouseEvent(Common::Event &event, int x, int y, int relx = 0, int rely = 0);
00173 
00178     virtual bool remapKey(SDL_Event &ev, Common::Event &event);
00179 
00183     virtual int mapKey(SDLKey key, SDLMod mod, Uint16 unicode);
00184 
00188     virtual void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event);
00189 
00193     Common::KeyCode SDLToOSystemKeycode(const SDLKey key);
00194 
00198     bool handleResizeEvent(Common::Event &event, int w, int h);
00199 
00204     uint32 obtainUnicode(const SDL_keysym keySym);
00205 
00209     SDLKey obtainKeycode(const SDL_keysym keySym);
00210 
00214     bool _queuedFakeMouseMove;
00215 
00221     Common::Event _fakeMouseMove;
00222 
00223 #if SDL_VERSION_ATLEAST(2, 0, 0)
00224 
00227     bool _queuedFakeKeyUp;
00228 
00233     Common::Event _fakeKeyUp;
00234 #endif
00235 };
00236 
00237 #endif


Generated on Sat May 18 2019 05:01:19 for ResidualVM by doxygen 1.7.1
curved edge   curved edge