ScummVM API documentation
action.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 COMMON_ACTION_H
23 #define COMMON_ACTION_H
24 
25 #include "common/scummsys.h"
26 
27 #include "common/array.h"
28 #include "common/events.h"
29 #include "common/str.h"
30 #include "common/ustr.h"
31 
32 namespace Common {
33 
35  const char *id;
36  const KeyState ks;
37  const char *defaultHwId;
38  const char *description;
39 };
40 
41 struct Action {
43  const char *id;
46 
49 
50 private:
51  Array<String> _defaultInputMapping;
52  bool _shouldTriggerOnKbdRepeats;
53 
54 public:
55  Action(const char *id, const U32String &description);
56 
57  void setEvent(const Event &evt) {
58  event = evt;
59  }
60 
61  void setEvent(const EventType evtType) {
62  event = Event();
63  event.type = evtType;
64  }
65 
66  void setCustomBackendActionEvent(const CustomEventType evtType) {
67  event = Event();
68  event.type = EVENT_CUSTOM_BACKEND_ACTION_START;
69  event.customType = evtType;
70  }
71 
72  void setCustomBackendActionAxisEvent(const CustomEventType evtType) {
73  event = Event();
74  event.type = EVENT_CUSTOM_BACKEND_ACTION_AXIS;
75  event.customType = evtType;
76  }
77 
78  void setCustomEngineActionEvent(const CustomEventType evtType) {
79  event = Event();
80  event.type = EVENT_CUSTOM_ENGINE_ACTION_START;
81  event.customType = evtType;
82  }
83 
84  void setKeyEvent(const KeyState &ks) {
85  event = Event();
86  event.type = EVENT_KEYDOWN;
87  event.kbd = ks;
88  }
89 
90  void setLeftClickEvent() {
91  setEvent(EVENT_LBUTTONDOWN);
92  }
93 
94  void setMiddleClickEvent() {
95  setEvent(EVENT_MBUTTONDOWN);
96  }
97 
98  void setRightClickEvent() {
99  setEvent(EVENT_RBUTTONDOWN);
100  }
101 
102  void setMouseWheelUpEvent() {
103  setEvent(EVENT_WHEELUP);
104  }
105 
106  void setMouseWheelDownEvent() {
107  setEvent(EVENT_WHEELDOWN);
108  }
109 
110  void setX1ClickEvent() {
111  setEvent(EVENT_X1BUTTONDOWN);
112  }
113 
114  void setX2ClickEvent() {
115  setEvent(EVENT_X2BUTTONDOWN);
116  }
117 
129  _shouldTriggerOnKbdRepeats = true;
130  }
131 
132  bool shouldTriggerOnKbdRepeats() const { return _shouldTriggerOnKbdRepeats; }
133 
143  void addDefaultInputMapping(const String &hwId);
144 
145  const Array<String> &getDefaultInputMapping() const {
146  return _defaultInputMapping;
147  }
148 
149 };
150 
151 } // End of namespace Common
152 
153 #endif // #ifndef COMMON_ACTION_H
Definition: str.h:59
U32String description
Definition: action.h:45
Definition: events.h:52
Definition: action.h:41
EventType
Definition: events.h:49
Definition: action.h:34
uint32 CustomEventType
Definition: events.h:193
const char * id
Definition: action.h:43
Definition: events.h:111
Definition: ustr.h:57
Definition: events.h:199
Definition: algorithm.h:29
Event event
Definition: action.h:48
void allowKbdRepeats()
Definition: action.h:128
Definition: keyboard.h:294