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         int32 x, y;
00070         int16 x_vel, y_vel, x_max, y_max, x_down_count, y_down_count, joy_x, joy_y;
00071         uint32 last_time, delay_time, x_down_time, y_down_time;
00072         bool modifier;
00073     };
00074     KbdMouse _km;
00075 
00077 
00079     bool _scrollLock;
00080 
00082     SDL_Joystick *_joystick;
00083 
00084 #if SDL_VERSION_ATLEAST(2, 0, 0)
00085 
00086     SDL_GameController *_controller;
00087 #endif
00088 
00090     int _lastScreenID;
00091 
00095     SdlGraphicsManager *_graphicsManager;
00096 
00100     void loadGameControllerMappingFile();
00101 
00110     void openJoystick(int joystickIndex);
00111 
00115     void closeJoystick();
00116 
00120     virtual void preprocessEvents(SDL_Event *event) {}
00121 
00125     virtual bool dispatchSDLEvent(SDL_Event &ev, Common::Event &event);
00126 
00127 
00135 
00136     virtual bool handleKeyDown(SDL_Event &ev, Common::Event &event);
00137     virtual bool handleKeyUp(SDL_Event &ev, Common::Event &event);
00138     virtual bool handleMouseMotion(SDL_Event &ev, Common::Event &event);
00139     virtual bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event);
00140     virtual bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event);
00141     virtual bool handleSysWMEvent(SDL_Event &ev, Common::Event &event);
00142     virtual bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);
00143     virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
00144     virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event);
00145     virtual void updateKbdMouse();
00146     virtual bool handleKbdMouse(Common::Event &event);
00147 
00148 #if SDL_VERSION_ATLEAST(2, 0, 0)
00149     virtual bool handleJoystickAdded(const SDL_JoyDeviceEvent &event);
00150     virtual bool handleJoystickRemoved(const SDL_JoyDeviceEvent &device);
00151     virtual bool handleControllerButton(const SDL_Event &ev, Common::Event &event, bool buttonUp);
00152     virtual bool handleControllerAxisMotion(const SDL_Event &ev, Common::Event &event);
00153 #endif
00154 
00156 
00160     virtual bool handleAxisToMouseMotion(int16 xAxis, int16 yAxis);
00161 
00166     int16 computeJoystickMouseSpeedFactor() const;
00167 
00174     virtual bool processMouseEvent(Common::Event &event, int x, int y, int relx = 0, int rely = 0);
00175 
00180     virtual bool remapKey(SDL_Event &ev, Common::Event &event);
00181 
00185     virtual int mapKey(SDLKey key, SDLMod mod, Uint16 unicode);
00186 
00190     virtual void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event);
00191 
00195     Common::KeyCode SDLToOSystemKeycode(const SDLKey key);
00196 
00200     bool handleResizeEvent(Common::Event &event, int w, int h);
00201 
00206     uint32 obtainUnicode(const SDL_keysym keySym);
00207 
00211     SDLKey obtainKeycode(const SDL_keysym keySym);
00212 
00216     bool _queuedFakeMouseMove;
00217 
00223     Common::Event _fakeMouseMove;
00224 
00225 #if SDL_VERSION_ATLEAST(2, 0, 0)
00226 
00229     bool _queuedFakeKeyUp;
00230 
00235     Common::Event _fakeKeyUp;
00236 #endif
00237 };
00238 
00239 #endif


Generated on Sat Jul 13 2019 05:00:53 for ResidualVM by doxygen 1.7.1
curved edge   curved edge