2008-07-30 13:47:54 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2014-02-18 02:34:21 +01:00
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
2008-07-30 13:47:54 +00:00
|
|
|
|
2008-09-30 13:51:01 +00:00
|
|
|
#ifndef COMMON_ACTION_H
|
|
|
|
#define COMMON_ACTION_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
|
|
|
|
#ifdef ENABLE_KEYMAPPER
|
2008-07-21 00:11:25 +00:00
|
|
|
|
|
|
|
#include "common/events.h"
|
2008-08-01 16:44:49 +00:00
|
|
|
#include "common/func.h"
|
2008-07-21 00:11:25 +00:00
|
|
|
#include "common/list.h"
|
|
|
|
#include "common/str.h"
|
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
|
2012-02-24 13:23:55 -06:00
|
|
|
struct HardwareInput;
|
2008-07-24 10:00:56 +00:00
|
|
|
class Keymap;
|
|
|
|
|
2014-10-26 22:20:57 +01:00
|
|
|
#define ACTION_ID_SIZE (5)
|
2008-08-18 10:07:11 +00:00
|
|
|
|
2011-12-12 20:15:08 -06:00
|
|
|
struct KeyActionEntry {
|
|
|
|
const KeyState ks;
|
|
|
|
const char *id;
|
|
|
|
const char *description;
|
|
|
|
};
|
|
|
|
|
2008-08-01 16:44:49 +00:00
|
|
|
struct Action {
|
2008-07-21 00:11:25 +00:00
|
|
|
/** unique id used for saving/loading to config */
|
2008-08-18 10:07:11 +00:00
|
|
|
char id[ACTION_ID_SIZE];
|
2008-07-21 00:11:25 +00:00
|
|
|
/** Human readable description */
|
|
|
|
String description;
|
2008-08-06 14:21:05 +00:00
|
|
|
|
2008-07-21 00:11:25 +00:00
|
|
|
/** Events to be sent when mapped key is pressed */
|
|
|
|
List<Event> events;
|
|
|
|
|
2008-07-24 10:00:56 +00:00
|
|
|
private:
|
2012-02-24 13:23:55 -06:00
|
|
|
/** Hardware input that is mapped to this Action */
|
|
|
|
const HardwareInput *_hwInput;
|
2008-08-14 23:45:02 +00:00
|
|
|
Keymap *_boss;
|
2008-07-21 00:11:25 +00:00
|
|
|
|
2008-07-24 10:00:56 +00:00
|
|
|
public:
|
2012-02-21 13:34:30 -06:00
|
|
|
Action(Keymap *boss, const char *id, String des = "");
|
2008-08-18 19:54:46 +00:00
|
|
|
|
2009-05-24 15:17:42 +00:00
|
|
|
void addEvent(const Event &evt) {
|
2008-08-18 19:54:46 +00:00
|
|
|
events.push_back(evt);
|
|
|
|
}
|
|
|
|
|
2012-02-02 18:52:12 -06:00
|
|
|
void addEvent(const EventType evtType) {
|
|
|
|
Event evt;
|
|
|
|
|
|
|
|
evt.type = evtType;
|
|
|
|
events.push_back(evt);
|
|
|
|
}
|
|
|
|
|
2008-08-18 19:54:46 +00:00
|
|
|
void addKeyEvent(const KeyState &ks) {
|
|
|
|
Event evt;
|
2009-05-10 17:18:59 +00:00
|
|
|
|
2008-08-18 19:54:46 +00:00
|
|
|
evt.type = EVENT_KEYDOWN;
|
|
|
|
evt.kbd = ks;
|
|
|
|
addEvent(evt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void addLeftClickEvent() {
|
2012-02-02 18:52:12 -06:00
|
|
|
addEvent(EVENT_LBUTTONDOWN);
|
2008-08-18 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void addMiddleClickEvent() {
|
2012-02-02 18:52:12 -06:00
|
|
|
addEvent(EVENT_MBUTTONDOWN);
|
2008-08-18 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void addRightClickEvent() {
|
2012-02-02 18:52:12 -06:00
|
|
|
addEvent(EVENT_RBUTTONDOWN);
|
2008-08-18 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
2009-05-24 15:17:42 +00:00
|
|
|
Keymap *getParent() {
|
2008-08-18 19:54:46 +00:00
|
|
|
return _boss;
|
|
|
|
}
|
2008-07-24 10:00:56 +00:00
|
|
|
|
2012-02-24 13:23:55 -06:00
|
|
|
void mapInput(const HardwareInput *input);
|
|
|
|
const HardwareInput *getMappedInput() const;
|
2008-08-06 14:21:05 +00:00
|
|
|
|
2008-07-21 00:11:25 +00:00
|
|
|
};
|
|
|
|
|
2009-10-04 21:26:33 +00:00
|
|
|
} // End of namespace Common
|
2008-07-21 00:11:25 +00:00
|
|
|
|
2008-09-30 13:51:01 +00:00
|
|
|
#endif // #ifdef ENABLE_KEYMAPPER
|
|
|
|
|
|
|
|
#endif // #ifndef COMMON_ACTION_H
|