Use libevdev for monitoring GPIO state change

Change-Id: I962af3034586f027e6ba74387dcda6ef0cf3672e
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
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 @@
 };
 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 @@
         /** @brief File descriptor manager */
         FileDescriptor fd;
 
+        /** event structure */
+        EvdevPtr device;
+
         /** @brief Completion indicator */
         bool complete = false;
 
@@ -127,11 +141,11 @@
         /** @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