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.
|
|
|
|
*
|
2021-12-26 18:47:58 +01:00
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2014-02-18 02:34:21 +01:00
|
|
|
*
|
|
|
|
* 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
|
2021-12-26 18:47:58 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-02-18 02:34:21 +01:00
|
|
|
*
|
|
|
|
*/
|
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 17:11:33 +02:00
|
|
|
#include "common/array.h"
|
2008-07-21 00:11:25 +00:00
|
|
|
#include "common/events.h"
|
|
|
|
#include "common/str.h"
|
2020-06-13 22:12:25 +05:30
|
|
|
#include "common/ustr.h"
|
2008-07-21 00:11:25 +00:00
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
|
2011-12-12 20:15:08 -06:00
|
|
|
struct KeyActionEntry {
|
|
|
|
const char *id;
|
2020-01-22 11:36:11 +01:00
|
|
|
const KeyState ks;
|
|
|
|
const char *defaultHwId;
|
2011-12-12 20:15:08 -06: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 14:19:41 +02:00
|
|
|
const char *id;
|
2008-07-21 00:11:25 +00:00
|
|
|
/** Human readable description */
|
2020-06-13 22:12:25 +05:30
|
|
|
U32String description;
|
2008-08-06 14:21:05 +00:00
|
|
|
|
2017-08-11 14:51:27 +02: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 17:11:33 +02:00
|
|
|
Array<String> _defaultInputMapping;
|
2020-04-18 07:59:03 +02:00
|
|
|
bool _shouldTriggerOnKbdRepeats;
|
2017-08-14 17:11:33 +02:00
|
|
|
|
2008-07-24 10:00:56 +00:00
|
|
|
public:
|
2020-06-13 22:12:25 +05:30
|
|
|
Action(const char *id, const U32String &description);
|
2008-08-18 19:54:46 +00:00
|
|
|
|
2017-08-11 14:51:27 +02:00
|
|
|
void setEvent(const Event &evt) {
|
|
|
|
event = evt;
|
2008-08-18 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 14:51:27 +02:00
|
|
|
void setEvent(const EventType evtType) {
|
|
|
|
event = Event();
|
|
|
|
event.type = evtType;
|
2012-02-02 18:52:12 -06:00
|
|
|
}
|
|
|
|
|
2017-08-15 15:48:40 +02:00
|
|
|
void setCustomBackendActionEvent(const CustomEventType evtType) {
|
|
|
|
event = Event();
|
|
|
|
event.type = EVENT_CUSTOM_BACKEND_ACTION_START;
|
|
|
|
event.customType = evtType;
|
|
|
|
}
|
|
|
|
|
2020-03-02 20:24:43 +01:00
|
|
|
void setCustomBackendActionAxisEvent(const CustomEventType evtType) {
|
|
|
|
event = Event();
|
|
|
|
event.type = EVENT_CUSTOM_BACKEND_ACTION_AXIS;
|
|
|
|
event.customType = evtType;
|
|
|
|
}
|
|
|
|
|
2020-01-25 13:41:08 +01:00
|
|
|
void setCustomEngineActionEvent(const CustomEventType evtType) {
|
|
|
|
event = Event();
|
|
|
|
event.type = EVENT_CUSTOM_ENGINE_ACTION_START;
|
|
|
|
event.customType = evtType;
|
|
|
|
}
|
|
|
|
|
2017-08-11 14:51:27 +02: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 14:51:27 +02:00
|
|
|
void setLeftClickEvent() {
|
|
|
|
setEvent(EVENT_LBUTTONDOWN);
|
2008-08-18 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 14:51:27 +02:00
|
|
|
void setMiddleClickEvent() {
|
|
|
|
setEvent(EVENT_MBUTTONDOWN);
|
2008-08-18 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 14:51:27 +02:00
|
|
|
void setRightClickEvent() {
|
|
|
|
setEvent(EVENT_RBUTTONDOWN);
|
2008-08-18 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
2020-02-09 16:45:35 +03: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-17 18:39:14 -07:00
|
|
|
/**
|
|
|
|
* Allows an action bound to a keyboard event to be repeatedly
|
|
|
|
* triggered by key repeats
|
2020-04-18 07:59:03 +02: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-17 18:39:14 -07:00
|
|
|
*/
|
2020-04-18 07:59:03 +02:00
|
|
|
void allowKbdRepeats() {
|
|
|
|
_shouldTriggerOnKbdRepeats = true;
|
2020-04-17 18:39:14 -07:00
|
|
|
}
|
|
|
|
|
2020-04-18 07:59:03 +02:00
|
|
|
bool shouldTriggerOnKbdRepeats() const { return _shouldTriggerOnKbdRepeats; }
|
|
|
|
|
2017-08-14 17:11:33 +02: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
|