mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-23 23:42:32 +00:00
event_filter: allow remapping of KEY_UNKNOWN
KEY_UNKNOWN is a collective symbols for all unknown keycodes. Remapping thus requires iterating through all corresponding codes instead of only applying the policy to the first match. Issue genodelabs#4069
This commit is contained in:
parent
f6aabfe233
commit
e86387d557
@ -36,6 +36,24 @@ namespace Event_filter {
|
||||
}
|
||||
throw Unknown_key();
|
||||
}
|
||||
|
||||
/*
|
||||
* \throw Unknown_key
|
||||
*/
|
||||
template<typename FN>
|
||||
void for_each_key_with_name(Key_name const &name, FN const &fn)
|
||||
{
|
||||
bool found = false;
|
||||
for (unsigned i = 0; i < Input::KEY_MAX; i++) {
|
||||
Input::Keycode const code = Input::Keycode(i);
|
||||
if (name == Input::key_name(code)) {
|
||||
fn(code);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
throw Unknown_key();
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _EVENT_FILTER__KEY_CODE_BY_NAME_H_ */
|
||||
|
@ -106,13 +106,13 @@ class Event_filter::Remap_source : public Source, Source::Filter
|
||||
Key_name const key_name = node.attribute_value("name", Key_name());
|
||||
|
||||
try {
|
||||
Input::Keycode const code = key_code_by_name(key_name);
|
||||
|
||||
if (node.has_attribute("to")) {
|
||||
Key_name const to = node.attribute_value("to", Key_name());
|
||||
try { _keys[code].code = key_code_by_name(to); }
|
||||
catch (Unknown_key) { warning("ignoring remap rule ", node); }
|
||||
}
|
||||
for_each_key_with_name(key_name, [&] (Input::Keycode code) {
|
||||
if (node.has_attribute("to")) {
|
||||
Key_name const to = node.attribute_value("to", Key_name());
|
||||
try { _keys[code].code = key_code_by_name(to); }
|
||||
catch (Unknown_key) { warning("ignoring remap rule ", node); }
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Unknown_key) {
|
||||
warning("invalid key name ", key_name); }
|
||||
|
Loading…
Reference in New Issue
Block a user