From 77ec47996d0c8b78d0f08d17fed8ff03107a1e03 Mon Sep 17 00:00:00 2001 From: Vishwanatha Subbanna Date: Mon, 10 Apr 2017 15:43:47 +0530 Subject: Use libevdev for monitoring GPIO state change Change-Id: I962af3034586f027e6ba74387dcda6ef0cf3672e Signed-off-by: Vishwanatha Subbanna --- monitor.hpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'monitor.hpp') diff --git a/monitor.hpp b/monitor.hpp index 34803c1..68bf447 100644 --- a/monitor.hpp +++ b/monitor.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include "file.hpp" @@ -31,6 +32,16 @@ struct EventSourceDeleter }; using EventSourcePtr = std::unique_ptr; +/* Need a custom deleter for freeing up evdev struct */ +struct EvdevDeleter +{ + void operator()(struct libevdev* device) const + { + libevdev_free(device); + } +}; +using EvdevPtr = std::unique_ptr; + /** @class Monitor * @brief Responsible for catching GPIO state change * condition and taking actions @@ -118,6 +129,9 @@ class Monitor /** @brief File descriptor manager */ FileDescriptor fd; + /** event structure */ + EvdevPtr device; + /** @brief Completion indicator */ bool complete = false; @@ -127,11 +141,11 @@ class Monitor /** @brief attaches FD to events and sets up callback handler */ void registerCallback(); - /** @brief Analyzes the GPIO event and starts configured target - * - * @return - For now, returns zero - */ - int analyzeEvent(); + /** @brief Analyzes the GPIO event and starts configured target */ + void analyzeEvent(); + + /** @brief Initializes evdev handle with the fd */ + void initEvDev(); }; } // namespace gpio -- cgit v1.2.1