summaryrefslogtreecommitdiffstats
path: root/monitor.hpp
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-04-10 15:43:47 +0530
committerVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-04-27 14:42:10 +0530
commit77ec47996d0c8b78d0f08d17fed8ff03107a1e03 (patch)
tree2167a88b66797894a78cd2dbd39c0ba949194712 /monitor.hpp
parentd7f9cd1f7033e4a544d14a91546e26cabe84d7af (diff)
downloadphosphor-gpio-monitor-77ec47996d0c8b78d0f08d17fed8ff03107a1e03.tar.gz
phosphor-gpio-monitor-77ec47996d0c8b78d0f08d17fed8ff03107a1e03.zip
Use libevdev for monitoring GPIO state change
Change-Id: I962af3034586f027e6ba74387dcda6ef0cf3672e Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
Diffstat (limited to 'monitor.hpp')
-rw-r--r--monitor.hpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/monitor.hpp b/monitor.hpp
index 34803c1..68bf447 100644
--- a/monitor.hpp
+++ b/monitor.hpp
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <string>
#include <linux/input.h>
+#include <libevdev/libevdev.h>
#include <systemd/sd-event.h>
#include <sdbusplus/bus.hpp>
#include "file.hpp"
@@ -31,6 +32,16 @@ struct EventSourceDeleter
};
using EventSourcePtr = std::unique_ptr<sd_event_source, EventSourceDeleter>;
+/* 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<struct libevdev, EvdevDeleter>;
+
/** @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
OpenPOWER on IntegriCloud