mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-13 14:13:40 +00:00
input: disarm obnoxious press/release events
This patch adds a sanity check to the Event::type accessor. If the key code of a given PRESS or RELEASE event is out of the valid range, it reports an INVALID event. This way, client side code does not need to deal with such edge cases. E.g., on Lenovo notebooks, the ps2 driver reports strange key events when pressing shift-pageup/pagedown, violating the general assumption that there is a release event for each press event. By flagging these events as INVALID, the client-side logic stays intact.
This commit is contained in:
parent
f2a5648deb
commit
a255ffaee9
@ -83,10 +83,22 @@ class Input::Event
|
||||
((unsigned)utf8.b1 << 8) | ((unsigned)utf8.b0 << 0))
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Return event type
|
||||
*/
|
||||
Type type() const
|
||||
{
|
||||
/* prevent obnoxious events from being processed by clients */
|
||||
if ((_type == PRESS || _type == RELEASE)
|
||||
&& (_code <= KEY_RESERVED || _code >= KEY_UNKNOWN))
|
||||
return INVALID;
|
||||
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessors
|
||||
*/
|
||||
Type type() const { return _type; }
|
||||
int code() const { return _code; }
|
||||
int ax() const { return _ax; }
|
||||
int ay() const { return _ay; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user