summaryrefslogtreecommitdiffstats
path: root/libs/input
diff options
context:
space:
mode:
Diffstat (limited to 'libs/input')
-rw-r--r--libs/input/Android.mk14
-rw-r--r--libs/input/IInputFlinger.cpp59
-rw-r--r--libs/input/Input.cpp70
-rw-r--r--libs/input/tests/Android.mk3
-rw-r--r--libs/input/tests/InputEvent_test.cpp21
5 files changed, 120 insertions, 47 deletions
diff --git a/libs/input/Android.mk b/libs/input/Android.mk
index 2a1e762..944ac7f 100644
--- a/libs/input/Android.mk
+++ b/libs/input/Android.mk
@@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-ifneq ($(TARGET_BUILD_PDK),true)
-
LOCAL_PATH:= $(call my-dir)
# libinput is partially built for the host (used by build time keymap validation tool)
@@ -29,6 +27,7 @@ commonSources := \
deviceSources := \
$(commonSources) \
+ IInputFlinger.cpp \
InputTransport.cpp \
VelocityControl.cpp \
VelocityTracker.cpp
@@ -61,14 +60,7 @@ LOCAL_SHARED_LIBRARIES := \
liblog \
libcutils \
libutils \
- libbinder \
- libskia \
- libz
-
-LOCAL_C_INCLUDES := \
- external/skia/include/core \
- external/icu4c/common \
- external/zlib
+ libbinder
LOCAL_MODULE:= libinput
@@ -85,5 +77,3 @@ include $(BUILD_SHARED_LIBRARY)
ifeq (,$(ONE_SHOT_MAKEFILE))
include $(call first-makefiles-under,$(LOCAL_PATH))
endif
-
-endif #!PDK
diff --git a/libs/input/IInputFlinger.cpp b/libs/input/IInputFlinger.cpp
new file mode 100644
index 0000000..e009731
--- /dev/null
+++ b/libs/input/IInputFlinger.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <binder/Parcel.h>
+#include <binder/IPCThreadState.h>
+#include <binder/IServiceManager.h>
+
+#include <input/IInputFlinger.h>
+
+
+namespace android {
+
+class BpInputFlinger : public BpInterface<IInputFlinger> {
+public:
+ BpInputFlinger(const sp<IBinder>& impl) :
+ BpInterface<IInputFlinger>(impl) { }
+
+ virtual status_t doSomething() {
+ Parcel data, reply;
+ data.writeInterfaceToken(IInputFlinger::getInterfaceDescriptor());
+ remote()->transact(BnInputFlinger::DO_SOMETHING_TRANSACTION, data, &reply);
+ return reply.readInt32();
+ }
+};
+
+IMPLEMENT_META_INTERFACE(InputFlinger, "android.input.IInputFlinger");
+
+
+status_t BnInputFlinger::onTransact(
+ uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) {
+ switch(code) {
+ case DO_SOMETHING_TRANSACTION: {
+ CHECK_INTERFACE(IInputFlinger, data, reply);
+ reply->writeInt32(0);
+ break;
+ }
+ default:
+ return BBinder::onTransact(code, data, reply, flags);
+ }
+ return NO_ERROR;
+}
+
+};
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index 7a217c3..6f53996 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -24,10 +24,6 @@
#ifdef HAVE_ANDROID_OS
#include <binder/Parcel.h>
-
-#include "SkPoint.h"
-#include "SkMatrix.h"
-#include "SkScalar.h"
#endif
namespace android {
@@ -74,6 +70,7 @@ bool KeyEvent::hasDefaultAction(int32_t keyCode) {
case AKEYCODE_MUTE:
case AKEYCODE_BRIGHTNESS_DOWN:
case AKEYCODE_BRIGHTNESS_UP:
+ case AKEYCODE_MEDIA_AUDIO_TRACK:
return true;
}
@@ -112,6 +109,7 @@ bool KeyEvent::isSystemKey(int32_t keyCode) {
case AKEYCODE_SEARCH:
case AKEYCODE_BRIGHTNESS_DOWN:
case AKEYCODE_BRIGHTNESS_UP:
+ case AKEYCODE_MEDIA_AUDIO_TRACK:
return true;
}
@@ -421,17 +419,30 @@ void MotionEvent::scale(float scaleFactor) {
}
}
-#ifdef HAVE_ANDROID_OS
-static inline float transformAngle(const SkMatrix* matrix, float angleRadians) {
+static void transformPoint(const float matrix[9], float x, float y, float *outX, float *outY) {
+ // Apply perspective transform like Skia.
+ float newX = matrix[0] * x + matrix[1] * y + matrix[2];
+ float newY = matrix[3] * x + matrix[4] * y + matrix[5];
+ float newZ = matrix[6] * x + matrix[7] * y + matrix[8];
+ if (newZ) {
+ newZ = 1.0f / newZ;
+ }
+ *outX = newX * newZ;
+ *outY = newY * newZ;
+}
+
+static float transformAngle(const float matrix[9], float angleRadians,
+ float originX, float originY) {
// Construct and transform a vector oriented at the specified clockwise angle from vertical.
// Coordinate system: down is increasing Y, right is increasing X.
- SkPoint vector;
- vector.fX = SkFloatToScalar(sinf(angleRadians));
- vector.fY = SkFloatToScalar(-cosf(angleRadians));
- matrix->mapVectors(& vector, 1);
+ float x = sinf(angleRadians);
+ float y = -cosf(angleRadians);
+ transformPoint(matrix, x, y, &x, &y);
+ x -= originX;
+ y -= originY;
// Derive the transformed vector's clockwise angle from vertical.
- float result = atan2f(SkScalarToFloat(vector.fX), SkScalarToFloat(-vector.fY));
+ float result = atan2f(x, -y);
if (result < - M_PI_2) {
result += M_PI;
} else if (result > M_PI_2) {
@@ -440,25 +451,24 @@ static inline float transformAngle(const SkMatrix* matrix, float angleRadians) {
return result;
}
-void MotionEvent::transform(const SkMatrix* matrix) {
- float oldXOffset = mXOffset;
- float oldYOffset = mYOffset;
-
+void MotionEvent::transform(const float matrix[9]) {
// The tricky part of this implementation is to preserve the value of
// rawX and rawY. So we apply the transformation to the first point
- // then derive an appropriate new X/Y offset that will preserve rawX and rawY.
- SkPoint point;
+ // then derive an appropriate new X/Y offset that will preserve rawX
+ // and rawY for that point.
+ float oldXOffset = mXOffset;
+ float oldYOffset = mYOffset;
+ float newX, newY;
float rawX = getRawX(0);
float rawY = getRawY(0);
- matrix->mapXY(SkFloatToScalar(rawX + oldXOffset), SkFloatToScalar(rawY + oldYOffset),
- & point);
- float newX = SkScalarToFloat(point.fX);
- float newY = SkScalarToFloat(point.fY);
- float newXOffset = newX - rawX;
- float newYOffset = newY - rawY;
+ transformPoint(matrix, rawX + oldXOffset, rawY + oldYOffset, &newX, &newY);
+ mXOffset = newX - rawX;
+ mYOffset = newY - rawY;
- mXOffset = newXOffset;
- mYOffset = newYOffset;
+ // Determine how the origin is transformed by the matrix so that we
+ // can transform orientation vectors.
+ float originX, originY;
+ transformPoint(matrix, 0, 0, &originX, &originY);
// Apply the transformation to all samples.
size_t numSamples = mSamplePointerCoords.size();
@@ -466,15 +476,17 @@ void MotionEvent::transform(const SkMatrix* matrix) {
PointerCoords& c = mSamplePointerCoords.editItemAt(i);
float x = c.getAxisValue(AMOTION_EVENT_AXIS_X) + oldXOffset;
float y = c.getAxisValue(AMOTION_EVENT_AXIS_Y) + oldYOffset;
- matrix->mapXY(SkFloatToScalar(x), SkFloatToScalar(y), &point);
- c.setAxisValue(AMOTION_EVENT_AXIS_X, SkScalarToFloat(point.fX) - newXOffset);
- c.setAxisValue(AMOTION_EVENT_AXIS_Y, SkScalarToFloat(point.fY) - newYOffset);
+ transformPoint(matrix, x, y, &x, &y);
+ c.setAxisValue(AMOTION_EVENT_AXIS_X, x - mXOffset);
+ c.setAxisValue(AMOTION_EVENT_AXIS_Y, y - mYOffset);
float orientation = c.getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION);
- c.setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, transformAngle(matrix, orientation));
+ c.setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION,
+ transformAngle(matrix, orientation, originX, originY));
}
}
+#ifdef HAVE_ANDROID_OS
status_t MotionEvent::readFromParcel(Parcel* parcel) {
size_t pointerCount = parcel->readInt32();
size_t sampleCount = parcel->readInt32();
diff --git a/libs/input/tests/Android.mk b/libs/input/tests/Android.mk
index 4292741..c62dff1 100644
--- a/libs/input/tests/Android.mk
+++ b/libs/input/tests/Android.mk
@@ -14,8 +14,7 @@ shared_libraries := \
libutils \
libbinder \
libui \
- libstlport \
- libskia
+ libstlport
static_libraries := \
libgtest \
diff --git a/libs/input/tests/InputEvent_test.cpp b/libs/input/tests/InputEvent_test.cpp
index ab1feb3..78ea98e 100644
--- a/libs/input/tests/InputEvent_test.cpp
+++ b/libs/input/tests/InputEvent_test.cpp
@@ -17,7 +17,6 @@
#include <math.h>
#include <binder/Parcel.h>
-#include <core/SkMatrix.h>
#include <gtest/gtest.h>
#include <input/Input.h>
@@ -519,6 +518,20 @@ TEST_F(MotionEventTest, Parcel) {
ASSERT_NO_FATAL_FAILURE(assertEqualsEventWithHistory(&outEvent));
}
+static void setRotationMatrix(float matrix[9], float angle) {
+ float sin = sinf(angle);
+ float cos = cosf(angle);
+ matrix[0] = cos;
+ matrix[1] = -sin;
+ matrix[2] = 0;
+ matrix[3] = sin;
+ matrix[4] = cos;
+ matrix[5] = 0;
+ matrix[6] = 0;
+ matrix[7] = 0;
+ matrix[8] = 1.0f;
+}
+
TEST_F(MotionEventTest, Transform) {
// Generate some points on a circle.
// Each point 'i' is a point on a circle of radius ROTATION centered at (3,2) at an angle
@@ -561,9 +574,9 @@ TEST_F(MotionEventTest, Transform) {
ASSERT_NEAR(originalRawY, event.getRawY(0), 0.001);
// Apply a rotation about the origin by ROTATION degrees clockwise.
- SkMatrix matrix;
- matrix.setRotate(ROTATION);
- event.transform(&matrix);
+ float matrix[9];
+ setRotationMatrix(matrix, ROTATION * PI_180);
+ event.transform(matrix);
// Check the points.
for (size_t i = 0; i < pointerCount; i++) {