ScummVM API documentation
virtual-mouse.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef BACKENDS_KEYMAPPER_VIRTUAL_MOUSE_H
23 #define BACKENDS_KEYMAPPER_VIRTUAL_MOUSE_H
24 
25 #include "common/scummsys.h"
26 
27 #include "common/events.h"
28 
29 namespace Common {
30 
31 class EventDispatcher;
32 class Keymap;
33 
44 class VirtualMouse : public EventSource, public EventObserver {
45 public:
46  VirtualMouse(EventDispatcher *eventDispatcher);
47  ~VirtualMouse() override;
48 
49  // EventSource API
50  bool pollEvent(Event &event) override;
51 
52  // EventObserver API
53  bool notifyEvent(const Event &event) override;
54 
56  void addActionsToKeymap(Keymap *keymap);
57 
58 private:
59  static const int32 kUpdateDelay = 12;
60  static const int32 kDefaultScreenWidth = 640;
61 
62  enum {
63  kCustomActionVirtualAxisUp = 10000,
64  kCustomActionVirtualAxisDown = 10001,
65  kCustomActionVirtualAxisLeft = 10002,
66  kCustomActionVirtualAxisRight = 10003,
67  kCustomActionVirtualMouseSlow = 10004
68  };
69 
70  void handleAxisMotion(int16 axisPositionX, int16 axisPositionY);
71  float computeJoystickMouseSpeedFactor() const;
72 
73  EventDispatcher *_eventDispatcher;
74 
75  int16 _inputAxisPositionX;
76  int16 _inputAxisPositionY;
77 
78  float _mouseVelocityX;
79  float _mouseVelocityY;
80  float _slowModifier;
81 
82  float _subPixelRemainderX;
83  float _subPixelRemainderY;
84 
85  uint32 _lastUpdateMillis;
86 };
87 
88 } // End of namespace Common
89 
90 #endif // #ifndef BACKENDS_KEYMAPPER_VIRTUAL_MOUSE_H
Definition: keymap.h:66
Definition: events.h:370
bool pollEvent(Event &event) override
Definition: events.h:317
Definition: events.h:198
Definition: algorithm.h:29
void addActionsToKeymap(Keymap *keymap)
bool notifyEvent(const Event &event) override
Definition: events.h:258
Definition: virtual-mouse.h:44