Add new hover move action and scroll wheel plumbing.

Added support for tracking the mouse position even when the mouse button
is not pressed.  To avoid confusing existing applications, mouse movements
are reported using the new ACTION_HOVER_MOVE action when the mouse button
is not pressed.

Added some more plumbing for the scroll wheel axes.  The values are
reported to Views but they are not yet handled by the framework.

Change-Id: I1706be850d25cf34e5adf880bbed5cc3265cf4b1
diff --git a/services/input/EventHub.cpp b/services/input/EventHub.cpp
index f79d106..b31381a 100644
--- a/services/input/EventHub.cpp
+++ b/services/input/EventHub.cpp
@@ -101,12 +101,14 @@
         const InputDeviceIdentifier& identifier) :
         next(NULL),
         fd(fd), id(id), path(path), identifier(identifier),
-        classes(0), keyBitmask(NULL), configuration(NULL), virtualKeyMap(NULL) {
+        classes(0), keyBitmask(NULL), relBitmask(NULL),
+        configuration(NULL), virtualKeyMap(NULL) {
 }
 
 EventHub::Device::~Device() {
     close();
     delete[] keyBitmask;
+    delete[] relBitmask;
     delete configuration;
     delete virtualKeyMap;
 }
@@ -189,6 +191,18 @@
     return OK;
 }
 
+bool EventHub::hasRelativeAxis(int32_t deviceId, int axis) const {
+    if (axis >= 0 && axis <= REL_MAX) {
+        AutoMutex _l(mLock);
+
+        Device* device = getDeviceLocked(deviceId);
+        if (device && device->relBitmask) {
+            return test_bit(axis, device->relBitmask);
+        }
+    }
+    return false;
+}
+
 int32_t EventHub::getScanCodeState(int32_t deviceId, int32_t scanCode) const {
     if (scanCode >= 0 && scanCode <= KEY_MAX) {
         AutoMutex _l(mLock);
@@ -772,6 +786,24 @@
     memset(sw_bitmask, 0, sizeof(sw_bitmask));
     ioctl(fd, EVIOCGBIT(EV_SW, sizeof(sw_bitmask)), sw_bitmask);
 
+    device->keyBitmask = new uint8_t[sizeof(key_bitmask)];
+    if (device->keyBitmask != NULL) {
+        memcpy(device->keyBitmask, key_bitmask, sizeof(key_bitmask));
+    } else {
+        delete device;
+        LOGE("out of memory allocating key bitmask");
+        return -1;
+    }
+
+    device->relBitmask = new uint8_t[sizeof(rel_bitmask)];
+    if (device->relBitmask != NULL) {
+        memcpy(device->relBitmask, rel_bitmask, sizeof(rel_bitmask));
+    } else {
+        delete device;
+        LOGE("out of memory allocating rel bitmask");
+        return -1;
+    }
+
     // See if this is a keyboard.  Ignore everything in the button range except for
     // joystick and gamepad buttons which are handled like keyboards for the most part.
     bool haveKeyboardKeys = containsNonZeroByte(key_bitmask, 0, sizeof_bit_array(BTN_MISC))
@@ -781,14 +813,6 @@
                 sizeof_bit_array(BTN_DIGI));
     if (haveKeyboardKeys || haveGamepadButtons) {
         device->classes |= INPUT_DEVICE_CLASS_KEYBOARD;
-        device->keyBitmask = new uint8_t[sizeof(key_bitmask)];
-        if (device->keyBitmask != NULL) {
-            memcpy(device->keyBitmask, key_bitmask, sizeof(key_bitmask));
-        } else {
-            delete device;
-            LOGE("out of memory allocating key bitmask");
-            return -1;
-        }
     }
 
     // See if this is a cursor device such as a trackball or mouse.