From 71c3fa53dab04d8a3dfa03abf038f2489d8c63c6 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 9 Mar 2015 12:42:37 +0100 Subject: [PATCH] os: add input touch event type Issue #1444 --- repos/os/include/input/event.h | 8 +++++++- repos/os/src/test/input/test.cc | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/repos/os/include/input/event.h b/repos/os/include/input/event.h index 0e9c0a9fe..05562d001 100644 --- a/repos/os/include/input/event.h +++ b/repos/os/include/input/event.h @@ -23,7 +23,7 @@ class Input::Event { public: - enum Type { INVALID, MOTION, PRESS, RELEASE, WHEEL, FOCUS, LEAVE }; + enum Type { INVALID, MOTION, PRESS, RELEASE, WHEEL, FOCUS, LEAVE, TOUCH }; private: @@ -77,6 +77,12 @@ class Input::Event bool is_absolute_motion() const { return _type == MOTION && !_rx && !_ry; } bool is_relative_motion() const { return _type == MOTION && (_rx || _ry); } + bool is_touch_release() const { return _type == TOUCH && (_rx == -1) && (_ry == -1); } + + static Event create_touch_event(int ax, int ay, int id, bool last = false) + { + return Event(Type::TOUCH, id, ax, ay, last ? -1 : 0, last ? -1 : 0); + } }; #endif /* _INCLUDE__INPUT__EVENT_H_ */ diff --git a/repos/os/src/test/input/test.cc b/repos/os/src/test/input/test.cc index 174b85e59..1705208b1 100644 --- a/repos/os/src/test/input/test.cc +++ b/repos/os/src/test/input/test.cc @@ -30,6 +30,7 @@ static char const * ev_type(Input::Event::Type type) case Input::Event::WHEEL: return "WHEEL "; case Input::Event::FOCUS: return "FOCUS "; case Input::Event::LEAVE: return "LEAVE "; + case Input::Event::TOUCH: return "TOUCH "; } return "";