presence: Un-hardcode input device path

Allow a device path to be configured.

Change-Id: I2eabd71747b124eae96738d1332f58b96ece6dc9
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/presence/example/example.yaml b/presence/example/example.yaml
index 140e1ec..69a322b 100644
--- a/presence/example/example.yaml
+++ b/presence/example/example.yaml
@@ -37,6 +37,7 @@
     - type: gpio
       key: 123
       physpath: /sys/devices/foo/bar
+      devpath: /dev/input/by-path/platform-gpio-keys-event
 
 - name: Example Fan2
   description: >
@@ -58,6 +59,7 @@
     - type: gpio
       key: 124
       physpath: /sys/devices/foo/bar
+      devpath: /dev/input/by-path/platform-gpio-keys-polled-event
     - type: tach
       sensors:
         - fan2
@@ -75,6 +77,7 @@
     - type: gpio
       key: 125
       physpath: /sys/devices/foo/bar
+      devpath: /dev/input/by-path/platform-gpio-keys-polled-event
     - type: tach
       sensors:
         - fan3
diff --git a/presence/gpio.cpp b/presence/gpio.cpp
index 28db46e..2a0a4c0 100644
--- a/presence/gpio.cpp
+++ b/presence/gpio.cpp
@@ -31,10 +31,10 @@
 
 Gpio::Gpio(
         const std::string& physDevice,
+        const std::string& device,
         unsigned int physPin) :
     currentState(false),
-    evdevfd(open("/dev/input/by-path/platform-gpio-keys-event",
-                 O_RDONLY | O_NONBLOCK)),
+    evdevfd(open(device.c_str(), O_RDONLY | O_NONBLOCK)),
     evdev(evdevpp::evdev::newFromFD(evdevfd())),
     phys(physDevice),
     pin(physPin),
diff --git a/presence/gpio.hpp b/presence/gpio.hpp
index e516e0f..978fdd9 100644
--- a/presence/gpio.hpp
+++ b/presence/gpio.hpp
@@ -41,9 +41,13 @@
          * @brief Construct a gpio sensor.
          *
          * @param[in] physDevice - The physical gpio device path.
+         * @param[in] device - The gpio-keys input device.
          * @param[in] physPin - The physical gpio pin number.
          */
-        Gpio(const std::string& physDevice, unsigned int physPin);
+        Gpio(
+                const std::string& physDevice,
+                const std::string& device,
+                unsigned int physPin);
 
         /**
          * @brief start
diff --git a/presence/pfpgen.py b/presence/pfpgen.py
index 00ba900..187be32 100755
--- a/presence/pfpgen.py
+++ b/presence/pfpgen.py
@@ -139,6 +139,7 @@
     def __init__(self, *a, **kw):
         self.key = kw.pop('key')
         self.physpath = kw.pop('physpath')
+        self.devpath = kw.pop('devpath')
         kw['name'] = 'gpio-{}'.format(self.key)
         super(Gpio, self).__init__(**kw)
 
diff --git a/presence/templates/gpio.mako.hpp b/presence/templates/gpio.mako.hpp
index fb1f46f..d2a25d8 100644
--- a/presence/templates/gpio.mako.hpp
+++ b/presence/templates/gpio.mako.hpp
@@ -1,2 +1,2 @@
 std::make_unique<PolicyAccess<Gpio, ConfigPolicy>>(
-${indent(1)}${g.policy}, "${g.physpath}"s, ${g.key})\
+${indent(1)}${g.policy}, "${g.physpath}"s, "${g.devpath}"s, ${g.key})\