2008-07-30 13:47:54 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2014-02-18 01:34:21 +00: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"
|
|
|
|
|
2017-08-14 15:11:33 +00:00
|
|
|
#include "common/array.h"
|
2008-07-21 00:11:25 +00:00
|
|
|
#include "common/events.h"
|
|
|
|
#include "common/str.h"
|
2020-06-13 16:42:25 +00:00
|
|
|
#include "common/ustr.h"
|
2008-07-21 00:11:25 +00:00
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
|
2011-12-13 02:15:08 +00:00
|
|
|
struct KeyActionEntry {
|
|
|
|
const char *id;
|
2020-01-22 10:36:11 +00:00
|
|
|
const KeyState ks;
|
|
|
|
const char *defaultHwId;
|
2011-12-13 02:15:08 +00:00
|
|
|
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 */
|
2017-08-11 12:19:41 +00:00
|
|
|
const char *id;
|
2008-07-21 00:11:25 +00:00
|
|
|
/** Human readable description */
|
2020-06-13 16:42:25 +00:00
|
|
|
U32String description;
|
2008-08-06 14:21:05 +00:00
|
|
|
|
2017-08-11 12:51:27 +00:00
|
|
|
/** Event to be sent when mapped key is pressed */
|
|
|
|
Event event;
|
2008-07-21 00:11:25 +00:00
|
|
|
|
2008-07-24 10:00:56 +00:00
|
|
|
private:
|
2017-08-14 15:11:33 +00:00
|
|
|
Array<String> _defaultInputMapping;
|
2020-04-18 05:59:03 +00:00
|
|
|
bool _shouldTriggerOnKbdRepeats;
|
2017-08-14 15:11:33 +00:00
|
|
|
|
2008-07-24 10:00:56 +00:00
|
|
|
public:
|
2020-06-13 16:42:25 +00:00
|
|
|
Action(const char *id, const U32String &description);
|
2008-08-18 19:54:46 +00:00
|
|
|
|
2017-08-11 12:51:27 +00:00
|
|
|
void setEvent(const Event &evt) {
|
|
|
|
event = evt;
|
2008-08-18 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 12:51:27 +00:00
|
|
|
void setEvent(const EventType evtType) {
|
|
|
|
event = Event();
|
|
|
|
event.type = evtType;
|
2012-02-03 00:52:12 +00:00
|
|
|
}
|
|
|
|
|
2017-08-15 13:48:40 +00:00
|
|
|
void setCustomBackendActionEvent(const CustomEventType evtType) {
|
|
|
|
event = Event();
|
|
|
|
event.type = EVENT_CUSTOM_BACKEND_ACTION_START;
|
|
|
|
event.customType = evtType;
|
|
|
|
}
|
|
|
|
|
2020-03-02 19:24:43 +00:00
|
|
|
void setCustomBackendActionAxisEvent(const CustomEventType evtType) {
|
|
|
|
event = Event();
|
|
|
|
event.type = EVENT_CUSTOM_BACKEND_ACTION_AXIS;
|
|
|
|
event.customType = evtType;
|
|
|
|
}
|
|
|
|
|
2020-01-25 12:41:08 +00:00
|
|
|
void setCustomEngineActionEvent(const CustomEventType evtType) {
|
|
|
|
event = Event();
|
|
|
|
event.type = EVENT_CUSTOM_ENGINE_ACTION_START;
|
|
|
|
event.customType = evtType;
|
|
|
|
}
|
|
|
|
|
2017-08-11 12:51:27 +00:00
|
|
|
void setKeyEvent(const KeyState &ks) {
|
|
|
|
event = Event();
|
|
|
|
event.type = EVENT_KEYDOWN;
|
|
|
|
event.kbd = ks;
|
2008-08-18 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 12:51:27 +00:00
|
|
|
void setLeftClickEvent() {
|
|
|
|
setEvent(EVENT_LBUTTONDOWN);
|
2008-08-18 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 12:51:27 +00:00
|
|
|
void setMiddleClickEvent() {
|
|
|
|
setEvent(EVENT_MBUTTONDOWN);
|
2008-08-18 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 12:51:27 +00:00
|
|
|
void setRightClickEvent() {
|
|
|
|
setEvent(EVENT_RBUTTONDOWN);
|
2008-08-18 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
2020-02-09 13:45:35 +00:00
|
|
|
void setMouseWheelUpEvent() {
|
|
|
|
setEvent(EVENT_WHEELUP);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMouseWheelDownEvent() {
|
|
|
|
setEvent(EVENT_WHEELDOWN);
|
|
|
|
}
|
|
|
|
|
2020-02-11 21:09:56 +00:00
|
|
|
void setX1ClickEvent() {
|
|
|
|
setEvent(EVENT_X1BUTTONDOWN);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setX2ClickEvent() {
|
|
|
|
setEvent(EVENT_X2BUTTONDOWN);
|
|
|
|
}
|
|
|
|
|
2020-04-18 01:39:14 +00:00
|
|
|
/**
|
|
|
|
* Allows an action bound to a keyboard event to be repeatedly
|
|
|
|
* triggered by key repeats
|
2020-04-18 05:59:03 +00:00
|
|
|
*
|
|
|
|
* Note that key repeat events should probably not be used for anything
|
|
|
|
* else than text input as they do not trigger when the action is bound
|
|
|
|
* to something else than a keyboard key. Furthermore, the frequency at
|
|
|
|
* which they trigger and whether they trigger at all is operating system
|
|
|
|
* controlled.
|
2020-04-18 01:39:14 +00:00
|
|
|
*/
|
2020-04-18 05:59:03 +00:00
|
|
|
void allowKbdRepeats() {
|
|
|
|
_shouldTriggerOnKbdRepeats = true;
|
2020-04-18 01:39:14 +00:00
|
|
|
}
|
|
|
|
|
2020-04-18 05:59:03 +00:00
|
|
|
bool shouldTriggerOnKbdRepeats() const { return _shouldTriggerOnKbdRepeats; }
|
|
|
|
|
2017-08-14 15:11:33 +00:00
|
|
|
/**
|
|
|
|
* Add a default input mapping for the action
|
|
|
|
*
|
|
|
|
* Unknown hardware inputs will be silently ignored.
|
|
|
|
* Having keyboard bindings by default will not cause trouble
|
|
|
|
* on devices without a keyboard.
|
|
|
|
*
|
|
|
|
* @param hwId Hardware input identifier as registered with the keymapper
|
|
|
|
*/
|
|
|
|
void addDefaultInputMapping(const String &hwId);
|
|
|
|
|
|
|
|
const Array<String> &getDefaultInputMapping() const {
|
|
|
|
return _defaultInputMapping;
|
|
|
|
}
|
|
|
|
|
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 // #ifndef COMMON_ACTION_H
|