Speech bubbles can point down right.
[scummvm-innocent.git] / backends / keymapper / action.h
blob31576e2960d5da29149e6440215d01fd4c2bbb05
1 /* ScummVM - Graphic Adventure Engine
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.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * $URL$
22 * $Id$
26 #ifndef COMMON_ACTION_H
27 #define COMMON_ACTION_H
29 #include "common/scummsys.h"
31 #ifdef ENABLE_KEYMAPPER
33 #include "backends/keymapper/types.h"
34 #include "common/events.h"
35 #include "common/func.h"
36 #include "common/list.h"
37 #include "common/str.h"
39 namespace Common {
41 struct HardwareKey;
42 class Keymap;
44 #define ACTION_ID_SIZE (4)
46 struct Action {
47 /** unique id used for saving/loading to config */
48 char id[ACTION_ID_SIZE];
49 /** Human readable description */
50 String description;
52 /** Events to be sent when mapped key is pressed */
53 List<Event> events;
54 ActionType type;
55 KeyType preferredKey;
56 int priority;
57 int group;
58 int flags;
60 private:
61 /** Hardware key that is mapped to this Action */
62 const HardwareKey *_hwKey;
63 Keymap *_boss;
65 public:
66 Action(Keymap *boss, const char *id, String des = "",
67 ActionType typ = kGenericActionType,
68 KeyType prefKey = kGenericKeyType,
69 int pri = 0, int flg = 0 );
71 void addEvent(const Event &evt) {
72 events.push_back(evt);
75 void addKeyEvent(const KeyState &ks) {
76 Event evt;
78 evt.type = EVENT_KEYDOWN;
79 evt.kbd = ks;
80 addEvent(evt);
83 void addLeftClickEvent() {
84 Event evt;
86 evt.type = EVENT_LBUTTONDOWN;
87 addEvent(evt);
90 void addMiddleClickEvent() {
91 Event evt;
93 evt.type = EVENT_MBUTTONDOWN;
94 addEvent(evt);
97 void addRightClickEvent() {
98 Event evt;
100 evt.type = EVENT_RBUTTONDOWN;
101 addEvent(evt);
104 Keymap *getParent() {
105 return _boss;
108 void mapKey(const HardwareKey *key);
109 const HardwareKey *getMappedKey() const;
113 struct ActionPriorityComp : public BinaryFunction<Action, Action, bool> {
114 bool operator()(const Action *x, const Action *y) const {
115 return x->priority > y->priority;
117 bool operator()(const Action &x, const Action &y) const {
118 return x.priority > y.priority;
122 } // end of namespace Common
124 #endif // #ifdef ENABLE_KEYMAPPER
126 #endif // #ifndef COMMON_ACTION_H