mirror of
https://github.com/libretro/scummvm.git
synced 2025-05-13 17:46:22 +00:00
KEYMAPPER: EventMapper must now eat all events
This commit is contained in:
parent
ae992bebe3
commit
e7ade8ae05
@ -181,12 +181,24 @@ void Keymapper::popKeymap(const char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Keymapper::notifyEvent(const Common::Event &ev) {
|
bool Keymapper::notifyEvent(const Common::Event &ev) {
|
||||||
|
bool mapped = false;
|
||||||
|
|
||||||
if (ev.type == Common::EVENT_KEYDOWN)
|
if (ev.type == Common::EVENT_KEYDOWN)
|
||||||
return mapKeyDown(ev.kbd);
|
mapped = mapKeyDown(ev.kbd);
|
||||||
else if (ev.type == Common::EVENT_KEYUP)
|
else if (ev.type == Common::EVENT_KEYUP)
|
||||||
return mapKeyUp(ev.kbd);
|
mapped = mapKeyUp(ev.kbd);
|
||||||
|
|
||||||
|
if (mapped)
|
||||||
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return mapEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Keymapper::mapEvent(const Common::Event &ev) {
|
||||||
|
// pass through - copy the event
|
||||||
|
Event evt = ev;
|
||||||
|
addEvent(evt);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Keymapper::mapKeyDown(const KeyState& key) {
|
bool Keymapper::mapKeyDown(const KeyState& key) {
|
||||||
|
@ -163,6 +163,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool mapKeyUp(const KeyState& key);
|
bool mapKeyUp(const KeyState& key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map non-key incoming events
|
||||||
|
* @param ev incoming event
|
||||||
|
*/
|
||||||
|
bool mapEvent(const Common::Event &ev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/disable the keymapper
|
* Enable/disable the keymapper
|
||||||
*/
|
*/
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/events.h"
|
#include "common/events.h"
|
||||||
|
#include "common/textconsole.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
@ -54,18 +55,20 @@ void EventDispatcher::dispatch() {
|
|||||||
// We only try to process the events via the setup event mapper, when
|
// We only try to process the events via the setup event mapper, when
|
||||||
// we have a setup mapper and when the event source allows mapping.
|
// we have a setup mapper and when the event source allows mapping.
|
||||||
if (_mapper && allowMapping) {
|
if (_mapper && allowMapping) {
|
||||||
if (_mapper->notifyEvent(event)) {
|
bool mapped = _mapper->notifyEvent(event);
|
||||||
// We allow the event mapper to create multiple events, when
|
// EventMappers must map all events
|
||||||
// eating an event.
|
if (!mapped)
|
||||||
while (_mapper->pollEvent(event))
|
error("Event [%u] was not mapped by the EventMapper!", event.type);
|
||||||
dispatchEvent(event);
|
// We allow the event mapper to create multiple events, when
|
||||||
|
// eating an event.
|
||||||
|
while (_mapper->pollEvent(event))
|
||||||
|
dispatchEvent(event);
|
||||||
|
|
||||||
// Try getting another event from the current EventSource.
|
// Try getting another event from the current EventSource.
|
||||||
continue;
|
continue;
|
||||||
}
|
} else {
|
||||||
|
dispatchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatchEvent(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user