summaryrefslogtreecommitdiffstats
path: root/native/android
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2010-07-23 21:28:06 -0700
committerJeff Brown <jeffbrown@google.com>2010-07-28 14:16:15 -0700
commit6d0fec2de3601821f4f44eeb7d7deedebb2b7117 (patch)
tree9fdea32c5691a6d0bcb3085df47f42a8e6ecd565 /native/android
parentb350bec514eb9fee473e4ef62680c53e992dc49b (diff)
downloadframeworks_base-6d0fec2de3601821f4f44eeb7d7deedebb2b7117.zip
frameworks_base-6d0fec2de3601821f4f44eeb7d7deedebb2b7117.tar.gz
frameworks_base-6d0fec2de3601821f4f44eeb7d7deedebb2b7117.tar.bz2
Refactor input reader to support new device types more easily.
Refactored the input reader so that each raw input protocol is handled by a separate subclass of the new InputMapper type. This way, behaviors pertaining to keyboard, trackballs, touchscreens, switches and other devices are clearly distinguished for improved maintainability. Added partial support for describing capabilities of input devices (incomplete and untested for now, will be fleshed out in later commits). Simplified EventHub interface somewhat since InputReader is taking over more of the work. Cleaned up some of the interactions between InputManager and WindowManagerService related to reading input state. Fixed swiping finger from screen edge into display area. Added logging of device information to 'dumpsys window'. Change-Id: I17faffc33e3aec3a0f33f0b37e81a70609378612
Diffstat (limited to 'native/android')
-rw-r--r--native/android/input.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/native/android/input.cpp b/native/android/input.cpp
index 59bf711..a82282d 100644
--- a/native/android/input.cpp
+++ b/native/android/input.cpp
@@ -21,14 +21,21 @@
#include <ui/Input.h>
#include <ui/InputTransport.h>
#include <utils/PollLoop.h>
+#include <utils/RefBase.h>
+#include <utils/Vector.h>
#include <android_runtime/android_app_NativeActivity.h>
#include <poll.h>
+#include <errno.h>
using android::InputEvent;
using android::KeyEvent;
using android::MotionEvent;
+using android::InputDeviceInfo;
+using android::InputDeviceProxy;
+using android::sp;
+using android::Vector;
int32_t AInputEvent_getType(const AInputEvent* event) {
return static_cast<const InputEvent*>(event)->getType();
@@ -263,3 +270,74 @@ int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event) {
void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled) {
queue->finishEvent(event, handled != 0);
}
+
+
+int32_t AInputDevice_getDeviceIds(int32_t* idBuf, size_t nMax, size_t* nActual) {
+ Vector<int32_t> ids;
+ InputDeviceProxy::getDeviceIds(ids);
+
+ if (nActual) {
+ *nActual = ids.size();
+ }
+
+ if (idBuf && ids.size() < nMax) {
+ memcpy(idBuf, ids.array(), ids.size() * sizeof(int32_t));
+ return 0;
+ }
+
+ return -ENOMEM;
+}
+
+AInputDevice* AInputDevice_acquire(int32_t deviceId) {
+ sp<InputDeviceProxy> proxy(InputDeviceProxy::getDevice(deviceId));
+ if (proxy == NULL) {
+ return NULL;
+ }
+ proxy->incStrong((void*)AInputDevice_acquire);
+ return static_cast<AInputDevice*>(proxy.get());
+}
+
+void AInputDevice_release(AInputDevice* device) {
+ if (device) {
+ InputDeviceProxy* proxy = static_cast<InputDeviceProxy*>(device);
+ proxy->decStrong((void*)AInputDevice_acquire);
+ }
+}
+
+const char* AInputDevice_getName(AInputDevice* device) {
+ InputDeviceProxy* proxy = static_cast<InputDeviceProxy*>(device);
+ return proxy->getInfo()->getName().string();
+}
+
+uint32_t AInputDevice_getSources(AInputDevice* device) {
+ InputDeviceProxy* proxy = static_cast<InputDeviceProxy*>(device);
+ return proxy->getInfo()->getSources();
+}
+
+int32_t AInputDevice_getKeyboardType(AInputDevice* device) {
+ InputDeviceProxy* proxy = static_cast<InputDeviceProxy*>(device);
+ return proxy->getInfo()->getKeyboardType();
+}
+
+int32_t AInputDevice_getMotionRange(AInputDevice* device, int32_t rangeType,
+ float* outMin, float* outMax, float* outFlat, float* outFuzz) {
+ InputDeviceProxy* proxy = static_cast<InputDeviceProxy*>(device);
+ const InputDeviceInfo::MotionRange* range = proxy->getInfo()->getMotionRange(rangeType);
+ if (range) {
+ if (outMin) {
+ *outMin = range->min;
+ }
+ if (outMax) {
+ *outMax = range->max;
+ }
+ if (outFlat) {
+ *outFlat = range->flat;
+ }
+ if (outFuzz) {
+ *outFuzz = range->fuzz;
+ }
+ return 0;
+ } else {
+ return -ENOTSUP;
+ }
+}