Added command --hwprops

This new command lists the hardware properties of the selected device.

BUG=chromium:353779
TEST=run inputcontrol -t touchpad --hwprops

Change-Id: I0972585c99c3f11ae5a3755d0bbac7eb7be16b5e
Reviewed-on: https://chromium-review.googlesource.com/194934
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Tested-by: Dennis Kempin <denniskempin@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@chromium.org>
diff --git a/inputcontrol b/inputcontrol
index 898bd3c..92109db 100755
--- a/inputcontrol
+++ b/inputcontrol
@@ -156,7 +156,8 @@
 DEFINE_string 'id' '' 'id to operate on' 'i'
 DEFINE_boolean 'verbose' false \
       'show xinput commands executed by this script' 'v'
-DEFINE_boolean 'list' false 'list device ids'
+DEFINE_boolean 'list' false 'list device xinput ids'
+DEFINE_boolean 'hwprops' false 'print hardware properties of device'
 DEFINE_boolean 'names' false 'list device ids and their names'
 DEFINE_boolean 'status' false 'show devices status'
 DEFINE_string 'add' '' 'to be called by udev when a new device is added'
@@ -221,6 +222,16 @@
       echo $devices
     fi
   fi
+  if [ ${FLAGS_hwprops} -eq ${FLAGS_TRUE} ] ; then
+    for device in $devices; do
+      local path=$(device_get_string_prop "$device" "Device Node")
+      log "evemu-describe $path"
+      evemu-describe $path
+      if [ $? -ne 0 ]; then
+        exit 1
+      fi
+    done
+  fi
   if [ ${FLAGS_status} -eq ${FLAGS_TRUE} ] ; then
     for device in $devices; do
       device_status $device
diff --git a/xinput.sh b/xinput.sh
index 93959da..4379f3f 100755
--- a/xinput.sh
+++ b/xinput.sh
@@ -152,6 +152,13 @@
   [ "$prop" = "1" ]
 }
 
+device_get_string_prop() {
+  assert_eq $# 2
+  prop=$(device_get_prop $1 "$2")
+  # get rid of " around value via eval
+  eval echo $prop
+}
+
 device_is_mouse() {
   assert_eq $# 1
   device_get_bool_prop $1 "Device Mouse"