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

default-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 #if !defined(BACKEND_EVENTS_DEFAULT_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
00024 #define BACKEND_EVENTS_DEFAULT_H
00025 
00026 #include "common/events.h"
00027 #include "common/queue.h"
00028 
00029 namespace Common {
00030 #ifdef ENABLE_KEYMAPPER
00031 class Keymapper;
00032 #endif
00033 #ifdef ENABLE_VKEYBD
00034 class VirtualKeyboard;
00035 #endif
00036 }
00037 
00038 
00039 class DefaultEventManager : public Common::EventManager, Common::EventObserver {
00040 #ifdef ENABLE_VKEYBD
00041     Common::VirtualKeyboard *_vk;
00042 #endif
00043 
00044 #ifdef ENABLE_KEYMAPPER
00045     Common::Keymapper *_keymapper;
00046     bool _remap;
00047 #endif
00048 
00049     Common::ArtificialEventSource _artificialEventSource;
00050 
00051     Common::Queue<Common::Event> _eventQueue;
00052     bool notifyEvent(const Common::Event &ev) override {
00053         _eventQueue.push(ev);
00054         return true;
00055     }
00056 
00057     Common::Point _mousePos;
00058     int _buttonState;
00059     int _modifierState;
00060     bool _shouldQuit;
00061     bool _shouldRTL;
00062     bool _confirmExitDialogActive;
00063 
00064     // for continuous events (keyDown)
00065     enum {
00066         kKeyRepeatInitialDelay = 400,
00067         kKeyRepeatSustainDelay = 100
00068     };
00069 
00070     bool _shouldGenerateKeyRepeatEvents;
00071     Common::KeyState _currentKeyDown;
00072     uint32 _keyRepeatTime;
00073 
00074     void handleKeyRepeat();
00075 public:
00076     DefaultEventManager(Common::EventSource *boss);
00077     ~DefaultEventManager();
00078 
00079     virtual void init() override;
00080     virtual bool pollEvent(Common::Event &event) override;
00081     virtual void pushEvent(const Common::Event &event) override;
00082     virtual void purgeMouseEvents() override;
00083 
00084     virtual Common::Point getMousePos() const override { return _mousePos; }
00085     virtual int getButtonState() const override { return _buttonState; }
00086     virtual int getModifierState() const override { return _modifierState; }
00087     virtual int shouldQuit() const override { return _shouldQuit; }
00088     virtual int shouldRTL() const override { return _shouldRTL; }
00089     virtual void resetRTL() override { _shouldRTL = false; }
00090 #ifdef FORCE_RTL
00091     virtual void resetQuit() override { _shouldQuit = false; }
00092 #endif
00093 
00094 #ifdef ENABLE_KEYMAPPER
00095      // IMPORTANT NOTE: This is part of the WIP Keymapper. If you plan to use
00096      // this, please talk to tsoliman and/or LordHoto.
00097     virtual Common::Keymapper *getKeymapper() override { return _keymapper; }
00098 #endif
00099 
00107     void setGenerateKeyRepeatEvents(bool generateKeyRepeatEvents) {
00108         _shouldGenerateKeyRepeatEvents = generateKeyRepeatEvents;
00109     }
00110 };
00111 
00112 #endif


Generated on Sat Feb 16 2019 05:00:49 for ResidualVM by doxygen 1.7.1
curved edge   curved edge