ScummVM API documentation
input.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 ALCACHOFA_INPUT_H
23 #define ALCACHOFA_INPUT_H
24 
25 #include "common/events.h"
26 #include "common/ptr.h"
27 
28 namespace Alcachofa {
29 
30 struct Task;
31 class Process;
32 
33 class Input {
34 public:
35  inline bool wasMouseLeftPressed() const { return _wasMouseLeftPressed; }
36  inline bool wasMouseRightPressed() const { return _wasMouseRightPressed; }
37  inline bool wasAnyMousePressed() const { return _wasMouseLeftPressed || _wasMouseRightPressed; }
38  inline bool wasMouseLeftReleased() const { return _wasMouseLeftReleased; }
39  inline bool wasMouseRightReleased() const { return _wasMouseRightReleased; }
40  inline bool wasAnyMouseReleased() const { return _wasMouseLeftReleased || _wasMouseRightReleased; }
41  inline bool isMouseLeftDown() const { return _isMouseLeftDown; }
42  inline bool isMouseRightDown() const { return _isMouseRightDown; }
43  inline bool isAnyMouseDown() const { return _isMouseLeftDown || _isMouseRightDown; }
44  inline bool wasMenuKeyPressed() const { return _wasMenuKeyPressed; }
45  inline bool wasInventoryKeyPressed() const { return _wasInventoryKeyPressed; }
46  inline bool wasSubtitlesKeyPressed() const { return _wasSubtitlesKeyPressed; }
47  inline Common::Point mousePos2D() const { return _mousePos2D; }
48  inline Common::Point mousePos3D() const { return _mousePos3D; }
49  const Input &debugInput() const { scumm_assert(_debugInput != nullptr); return *_debugInput; }
50 
51  void nextFrame();
52  bool handleEvent(const Common::Event &event);
53  void toggleDebugInput(bool debugMode);
54  Task *waitForInput(Process &process);
55 
56 private:
57  void updateMousePos3D();
58 
59  bool
60  _wasMouseLeftPressed = false,
61  _wasMouseRightPressed = false,
62  _wasMouseLeftReleased = false,
63  _wasMouseRightReleased = false,
64  _isMouseLeftDown = false,
65  _isMouseRightDown = false,
66  _wasMenuKeyPressed = false,
67  _wasInventoryKeyPressed = false,
68  _wasSubtitlesKeyPressed = false;
70  _mousePos2D,
71  _mousePos3D;
72  Common::ScopedPtr<Input> _debugInput;
73 };
74 
75 }
76 
77 #endif // ALCACHOFA_INPUT_H
Definition: alcachofa.h:45
Definition: scheduler.h:84
Definition: scheduler.h:164
void toggleDebugInput(bool debugMode)
Toggles input debug mode which blocks any input not retrieved with debugInput.
Definition: ptr.h:572
Definition: events.h:210
Definition: rect.h:144
Definition: input.h:33