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.
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"
44 #define ACTION_ID_SIZE (4)
47 /** unique id used for saving/loading to config */
48 char id
[ACTION_ID_SIZE
];
49 /** Human readable description */
52 /** Events to be sent when mapped key is pressed */
61 /** Hardware key that is mapped to this Action */
62 const HardwareKey
*_hwKey
;
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
) {
78 evt
.type
= EVENT_KEYDOWN
;
83 void addLeftClickEvent() {
86 evt
.type
= EVENT_LBUTTONDOWN
;
90 void addMiddleClickEvent() {
93 evt
.type
= EVENT_MBUTTONDOWN
;
97 void addRightClickEvent() {
100 evt
.type
= EVENT_RBUTTONDOWN
;
104 Keymap
*getParent() {
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