mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-03 01:15:58 +00:00
KEYMAPPER: Change custom backend action events not to be instant
Allows action consumers to choose if they want to react on the start or on the end of an user interaction.
This commit is contained in:
parent
2d7588d9c3
commit
cc336635a1
@ -190,7 +190,7 @@ MaemoSdlEventObserver::MaemoSdlEventObserver(MaemoSdlEventSource *eventSource) {
|
||||
|
||||
bool MaemoSdlEventObserver::notifyEvent(const Common::Event &event) {
|
||||
#ifdef ENABLE_KEYMAPPER
|
||||
if (event.type != Common::EVENT_CUSTOM_BACKEND_ACTION)
|
||||
if (event.type != Common::EVENT_CUSTOM_BACKEND_ACTION_START)
|
||||
return false;
|
||||
if (event.customType == kEventClickMode) {
|
||||
assert(_eventSource);
|
||||
|
@ -183,20 +183,20 @@ List<Event> Keymapper::mapEvent(const Event &ev) {
|
||||
|
||||
Keymapper::IncomingEventType Keymapper::convertToIncomingEventType(const Event &ev) const {
|
||||
if (ev.type == EVENT_CUSTOM_BACKEND_HARDWARE) {
|
||||
return kIncomingNonKey;
|
||||
return kIncomingEventInstant;
|
||||
} else if (ev.type == EVENT_KEYDOWN) {
|
||||
return kIncomingKeyDown;
|
||||
return kIncomingEventStart;
|
||||
} else {
|
||||
return kIncomingKeyUp;
|
||||
return kIncomingEventEnd;
|
||||
}
|
||||
}
|
||||
|
||||
Event Keymapper::executeAction(const Action *action, IncomingEventType incomingType) {
|
||||
Event evt = Event(action->event);
|
||||
EventType convertedType = convertDownToUp(evt.type);
|
||||
EventType convertedType = convertStartToEnd(evt.type);
|
||||
|
||||
// hardware keys need to send up instead when they are up
|
||||
if (incomingType == kIncomingKeyUp) {
|
||||
if (incomingType == kIncomingEventEnd) {
|
||||
evt.type = convertedType;
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ Event Keymapper::executeAction(const Action *action, IncomingEventType incomingT
|
||||
|
||||
// Check if the event is coming from a non-key hardware event
|
||||
// that is mapped to a key event
|
||||
if (incomingType == kIncomingNonKey && convertedType != EVENT_INVALID) {
|
||||
if (incomingType == kIncomingEventInstant && convertedType != EVENT_INVALID) {
|
||||
// WORKAROUND: Delay the down events coming from non-key hardware events
|
||||
// with a zero delay. This is to prevent DOWN1 DOWN2 UP1 UP2.
|
||||
addDelayedEvent(0, evt);
|
||||
@ -220,7 +220,7 @@ Event Keymapper::executeAction(const Action *action, IncomingEventType incomingT
|
||||
return evt;
|
||||
}
|
||||
|
||||
EventType Keymapper::convertDownToUp(EventType type) {
|
||||
EventType Keymapper::convertStartToEnd(EventType type) {
|
||||
EventType result = EVENT_INVALID;
|
||||
switch (type) {
|
||||
case EVENT_KEYDOWN:
|
||||
@ -235,6 +235,9 @@ EventType Keymapper::convertDownToUp(EventType type) {
|
||||
case EVENT_MBUTTONDOWN:
|
||||
result = EVENT_MBUTTONUP;
|
||||
break;
|
||||
case EVENT_CUSTOM_BACKEND_ACTION_START:
|
||||
result = EVENT_CUSTOM_BACKEND_ACTION_END;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -129,16 +129,16 @@ public:
|
||||
private:
|
||||
|
||||
enum IncomingEventType {
|
||||
kIncomingKeyDown,
|
||||
kIncomingKeyUp,
|
||||
kIncomingNonKey
|
||||
kIncomingEventStart,
|
||||
kIncomingEventEnd,
|
||||
kIncomingEventInstant
|
||||
};
|
||||
|
||||
HardwareInputSet *_hardwareInputs;
|
||||
const KeymapperDefaultBindings *_backendDefaultBindings;
|
||||
|
||||
Event executeAction(const Action *act, IncomingEventType incomingType);
|
||||
EventType convertDownToUp(EventType eventType);
|
||||
EventType convertStartToEnd(EventType eventType);
|
||||
IncomingEventType convertToIncomingEventType(const Event &ev) const;
|
||||
|
||||
EventManager *_eventMan;
|
||||
|
@ -204,7 +204,7 @@ Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() {
|
||||
|
||||
act = new Action("CLKM", _("Click Mode"));
|
||||
Event evt = Event();
|
||||
evt.type = EVENT_CUSTOM_BACKEND_ACTION;
|
||||
evt.type = EVENT_CUSTOM_BACKEND_ACTION_START;
|
||||
evt.customType = Maemo::kEventClickMode;
|
||||
act->setEvent(evt);
|
||||
globalMap->addAction(act);
|
||||
|
@ -56,6 +56,11 @@ void EventDispatcher::dispatch() {
|
||||
if (i->source->allowMapping()) {
|
||||
assert(_mapper);
|
||||
|
||||
// Backends may not produce directly action event types, those are meant
|
||||
// to be the output of the event mapper.
|
||||
assert(event.type != EVENT_CUSTOM_BACKEND_ACTION_START);
|
||||
assert(event.type != EVENT_CUSTOM_BACKEND_ACTION_END);
|
||||
|
||||
List<Event> mappedEvents = _mapper->mapEvent(event);
|
||||
|
||||
for (List<Event>::iterator j = mappedEvents.begin(); j != mappedEvents.end(); ++j) {
|
||||
|
@ -77,7 +77,8 @@ enum EventType {
|
||||
#ifdef ENABLE_KEYMAPPER
|
||||
// IMPORTANT NOTE: This is part of the WIP Keymapper. If you plan to use
|
||||
// this, please talk to tsoliman and/or LordHoto.
|
||||
EVENT_CUSTOM_BACKEND_ACTION = 18,
|
||||
EVENT_CUSTOM_BACKEND_ACTION_START = 18,
|
||||
EVENT_CUSTOM_BACKEND_ACTION_END = 19,
|
||||
EVENT_CUSTOM_BACKEND_HARDWARE = 21,
|
||||
#endif
|
||||
#ifdef ENABLE_VKEYBD
|
||||
|
Loading…
x
Reference in New Issue
Block a user