Loading core/jni/android_view_MotionEvent.cpp +29 −29 Original line number Diff line number Diff line Loading @@ -188,23 +188,23 @@ static bool validatePointerCoords(JNIEnv* env, jobject pointerCoordsObj) { static void pointerCoordsToNative(JNIEnv* env, jobject pointerCoordsObj, float xOffset, float yOffset, PointerCoords* outRawPointerCoords) { outRawPointerCoords->clear(); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_X, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_X, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.x) - xOffset); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_Y, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_Y, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.y) - yOffset); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_PRESSURE, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.pressure)); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_SIZE, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_SIZE, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.size)); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.touchMajor)); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.touchMinor)); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.toolMajor)); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.toolMinor)); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_ORIENTATION, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.orientation)); uint32_t bits = env->GetIntField(pointerCoordsObj, Loading Loading @@ -254,34 +254,34 @@ static jfloatArray obtainPackedAxisValuesArray(JNIEnv* env, uint32_t minSize, static void pointerCoordsFromNative(JNIEnv* env, const PointerCoords* rawPointerCoords, float xOffset, float yOffset, jobject outPointerCoordsObj) { env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.x, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_X) + xOffset); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_X) + xOffset); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.y, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_Y) + yOffset); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_Y) + yOffset); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.pressure, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_PRESSURE)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_PRESSURE)); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.size, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_SIZE)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_SIZE)); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.touchMajor, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR)); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.touchMinor, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR)); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.toolMajor, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR)); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.toolMinor, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR)); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.orientation, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION)); const uint32_t unpackedAxisBits = 0 | (1 << AINPUT_MOTION_AXIS_X) | (1 << AINPUT_MOTION_AXIS_Y) | (1 << AINPUT_MOTION_AXIS_PRESSURE) | (1 << AINPUT_MOTION_AXIS_SIZE) | (1 << AINPUT_MOTION_AXIS_TOUCH_MAJOR) | (1 << AINPUT_MOTION_AXIS_TOUCH_MINOR) | (1 << AINPUT_MOTION_AXIS_TOOL_MAJOR) | (1 << AINPUT_MOTION_AXIS_TOOL_MINOR) | (1 << AINPUT_MOTION_AXIS_ORIENTATION); | (1 << AMOTION_EVENT_AXIS_X) | (1 << AMOTION_EVENT_AXIS_Y) | (1 << AMOTION_EVENT_AXIS_PRESSURE) | (1 << AMOTION_EVENT_AXIS_SIZE) | (1 << AMOTION_EVENT_AXIS_TOUCH_MAJOR) | (1 << AMOTION_EVENT_AXIS_TOUCH_MINOR) | (1 << AMOTION_EVENT_AXIS_TOOL_MAJOR) | (1 << AMOTION_EVENT_AXIS_TOOL_MINOR) | (1 << AMOTION_EVENT_AXIS_ORIENTATION); uint32_t outBits = 0; uint32_t remainingBits = rawPointerCoords->bits & ~unpackedAxisBits; Loading Loading @@ -610,7 +610,7 @@ static jint android_view_MotionEvent_nativeReadFromParcel(JNIEnv* env, jclass cl Parcel* parcel = parcelForJavaObject(env, parcelObj); status_t status = event->readFromParcel(parcel); if (!status) { if (status) { if (!nativePtr) { delete event; } Loading @@ -626,7 +626,7 @@ static void android_view_MotionEvent_nativeWriteToParcel(JNIEnv* env, jclass cla Parcel* parcel = parcelForJavaObject(env, parcelObj); status_t status = event->writeToParcel(parcel); if (!status) { if (status) { jniThrowRuntimeException(env, "Failed to write MotionEvent parcel."); } } Loading include/ui/Input.h +26 −25 Original line number Diff line number Diff line Loading @@ -170,7 +170,7 @@ struct InputConfiguration { * Pointer coordinate data. */ struct PointerCoords { static const size_t MAX_AXES = 15; // 15 so that sizeof(PointerCoords) == 16 * 4 == 64 enum { MAX_AXES = 15 }; // 15 so that sizeof(PointerCoords) == 16 * 4 == 64 // Bitfield of axes that are present in this structure. uint32_t bits; // 32bits are enough for now, can raise to 64bit when needed Loading @@ -192,14 +192,14 @@ struct PointerCoords { return values[index]; } inline void setAxisValue(int32_t axis, float value) { inline status_t setAxisValue(int32_t axis, float value) { uint32_t axisBit = 1 << axis; uint32_t index = __builtin_popcount(bits & (axisBit - 1)); if (!(bits & axisBit)) { uint32_t count = __builtin_popcount(bits); if (count >= MAX_AXES) { tooManyAxes(axis); return; return NO_MEMORY; } bits |= axisBit; for (uint32_t i = count; i > index; i--) { Loading @@ -207,6 +207,7 @@ struct PointerCoords { } } values[index] = value; return OK; } inline float* editAxisValue(int32_t axis) { Loading Loading @@ -351,49 +352,49 @@ public: float getRawAxisValue(int32_t axis, size_t pointerIndex) const; inline float getRawX(size_t pointerIndex) const { return getRawAxisValue(AINPUT_MOTION_AXIS_X, pointerIndex); return getRawAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex); } inline float getRawY(size_t pointerIndex) const { return getRawAxisValue(AINPUT_MOTION_AXIS_Y, pointerIndex); return getRawAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex); } float getAxisValue(int32_t axis, size_t pointerIndex) const; inline float getX(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_X, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex); } inline float getY(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_Y, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex); } inline float getPressure(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_PRESSURE, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pointerIndex); } inline float getSize(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_SIZE, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_SIZE, pointerIndex); } inline float getTouchMajor(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex); } inline float getTouchMinor(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex); } inline float getToolMajor(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex); } inline float getToolMinor(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex); } inline float getOrientation(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex); } inline size_t getHistorySize() const { return mSampleEventTimes.size() - 1; } Loading @@ -410,59 +411,59 @@ public: inline float getHistoricalRawX(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalRawAxisValue( AINPUT_MOTION_AXIS_X, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex); } inline float getHistoricalRawY(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalRawAxisValue( AINPUT_MOTION_AXIS_Y, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex); } float getHistoricalAxisValue(int32_t axis, size_t pointerIndex, size_t historicalIndex) const; inline float getHistoricalX(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_X, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex); } inline float getHistoricalY(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_Y, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex); } inline float getHistoricalPressure(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_PRESSURE, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_PRESSURE, pointerIndex, historicalIndex); } inline float getHistoricalSize(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_SIZE, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_SIZE, pointerIndex, historicalIndex); } inline float getHistoricalTouchMajor(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_TOUCH_MAJOR, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex, historicalIndex); } inline float getHistoricalTouchMinor(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_TOUCH_MINOR, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex, historicalIndex); } inline float getHistoricalToolMajor(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_TOOL_MAJOR, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex, historicalIndex); } inline float getHistoricalToolMinor(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_TOOL_MINOR, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex, historicalIndex); } inline float getHistoricalOrientation(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_ORIENTATION, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex, historicalIndex); } void initialize( Loading libs/ui/Input.cpp +15 −15 Original line number Diff line number Diff line Loading @@ -362,10 +362,10 @@ float MotionEvent::getRawAxisValue(int32_t axis, size_t pointerIndex) const { float MotionEvent::getAxisValue(int32_t axis, size_t pointerIndex) const { float value = getRawPointerCoords(pointerIndex)->getAxisValue(axis); switch (axis) { case AINPUT_MOTION_AXIS_X: case AMOTION_EVENT_AXIS_X: value += mXOffset; break; case AINPUT_MOTION_AXIS_Y: case AMOTION_EVENT_AXIS_Y: value += mYOffset; break; } Loading @@ -386,10 +386,10 @@ float MotionEvent::getHistoricalAxisValue(int32_t axis, size_t pointerIndex, size_t historicalIndex) const { float value = getHistoricalRawPointerCoords(pointerIndex, historicalIndex)->getAxisValue(axis); switch (axis) { case AINPUT_MOTION_AXIS_X: case AMOTION_EVENT_AXIS_X: value += mXOffset; break; case AINPUT_MOTION_AXIS_Y: case AMOTION_EVENT_AXIS_Y: value += mYOffset; break; } Loading Loading @@ -419,12 +419,12 @@ void MotionEvent::scale(float scaleFactor) { PointerCoords& c = mSamplePointerCoords.editItemAt(i); // No need to scale pressure or size since they are normalized. // No need to scale orientation since it is meaningless to do so. scaleAxisValue(c, AINPUT_MOTION_AXIS_X, scaleFactor); scaleAxisValue(c, AINPUT_MOTION_AXIS_Y, scaleFactor); scaleAxisValue(c, AINPUT_MOTION_AXIS_TOUCH_MAJOR, scaleFactor); scaleAxisValue(c, AINPUT_MOTION_AXIS_TOUCH_MINOR, scaleFactor); scaleAxisValue(c, AINPUT_MOTION_AXIS_TOOL_MAJOR, scaleFactor); scaleAxisValue(c, AINPUT_MOTION_AXIS_TOOL_MINOR, scaleFactor); scaleAxisValue(c, AMOTION_EVENT_AXIS_X, scaleFactor); scaleAxisValue(c, AMOTION_EVENT_AXIS_Y, scaleFactor); scaleAxisValue(c, AMOTION_EVENT_AXIS_TOUCH_MAJOR, scaleFactor); scaleAxisValue(c, AMOTION_EVENT_AXIS_TOUCH_MINOR, scaleFactor); scaleAxisValue(c, AMOTION_EVENT_AXIS_TOOL_MAJOR, scaleFactor); scaleAxisValue(c, AMOTION_EVENT_AXIS_TOOL_MINOR, scaleFactor); } } Loading Loading @@ -471,8 +471,8 @@ void MotionEvent::transform(const SkMatrix* matrix) { size_t numSamples = mSamplePointerCoords.size(); for (size_t i = 0; i < numSamples; i++) { PointerCoords& c = mSamplePointerCoords.editItemAt(i); float* xPtr = c.editAxisValue(AINPUT_MOTION_AXIS_X); float* yPtr = c.editAxisValue(AINPUT_MOTION_AXIS_Y); float* xPtr = c.editAxisValue(AMOTION_EVENT_AXIS_X); float* yPtr = c.editAxisValue(AMOTION_EVENT_AXIS_Y); if (xPtr && yPtr) { float x = *xPtr + oldXOffset; float y = *yPtr + oldYOffset; Loading @@ -481,7 +481,7 @@ void MotionEvent::transform(const SkMatrix* matrix) { *yPtr = SkScalarToFloat(point.fY) - newYOffset; } float* orientationPtr = c.editAxisValue(AINPUT_MOTION_AXIS_ORIENTATION); float* orientationPtr = c.editAxisValue(AMOTION_EVENT_AXIS_ORIENTATION); if (orientationPtr) { *orientationPtr = transformAngle(matrix, *orientationPtr); } Loading Loading @@ -523,7 +523,7 @@ status_t MotionEvent::readFromParcel(Parcel* parcel) { for (size_t i = 0; i < pointerCount; i++) { mSamplePointerCoords.push(); status_t status = mSamplePointerCoords.editTop().readFromParcel(parcel); if (!status) { if (status) { return status; } } Loading Loading @@ -559,7 +559,7 @@ status_t MotionEvent::writeToParcel(Parcel* parcel) const { parcel->writeInt64(mSampleEventTimes.itemAt(h)); for (size_t i = 0; i < pointerCount; i++) { status_t status = (pc++)->writeToParcel(parcel); if (!status) { if (status) { return status; } } Loading libs/ui/tests/Android.mk +5 −2 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ ifneq ($(TARGET_SIMULATOR),true) # Build the unit tests. test_src_files := \ InputChannel_test.cpp \ InputEvent_test.cpp \ InputPublisherAndConsumer_test.cpp shared_libraries := \ Loading @@ -18,7 +19,8 @@ shared_libraries := \ libhardware \ libhardware_legacy \ libui \ libstlport libstlport \ libskia static_libraries := \ libgtest \ Loading @@ -28,7 +30,8 @@ c_includes := \ bionic \ bionic/libstdc++/include \ external/gtest/include \ external/stlport/stlport external/stlport/stlport \ external/skia/include/core module_tags := eng tests Loading libs/ui/tests/InputChannel_test.cpp +15 −3 Original line number Diff line number Diff line // // Copyright 2010 The Android Open Source Project // /* * Copyright (C) 2010 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 <ui/InputTransport.h> #include <utils/Timers.h> Loading Loading
core/jni/android_view_MotionEvent.cpp +29 −29 Original line number Diff line number Diff line Loading @@ -188,23 +188,23 @@ static bool validatePointerCoords(JNIEnv* env, jobject pointerCoordsObj) { static void pointerCoordsToNative(JNIEnv* env, jobject pointerCoordsObj, float xOffset, float yOffset, PointerCoords* outRawPointerCoords) { outRawPointerCoords->clear(); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_X, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_X, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.x) - xOffset); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_Y, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_Y, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.y) - yOffset); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_PRESSURE, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.pressure)); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_SIZE, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_SIZE, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.size)); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.touchMajor)); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.touchMinor)); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.toolMajor)); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.toolMinor)); outRawPointerCoords->setAxisValue(AINPUT_MOTION_AXIS_ORIENTATION, outRawPointerCoords->setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, env->GetFloatField(pointerCoordsObj, gPointerCoordsClassInfo.orientation)); uint32_t bits = env->GetIntField(pointerCoordsObj, Loading Loading @@ -254,34 +254,34 @@ static jfloatArray obtainPackedAxisValuesArray(JNIEnv* env, uint32_t minSize, static void pointerCoordsFromNative(JNIEnv* env, const PointerCoords* rawPointerCoords, float xOffset, float yOffset, jobject outPointerCoordsObj) { env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.x, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_X) + xOffset); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_X) + xOffset); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.y, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_Y) + yOffset); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_Y) + yOffset); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.pressure, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_PRESSURE)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_PRESSURE)); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.size, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_SIZE)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_SIZE)); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.touchMajor, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR)); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.touchMinor, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR)); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.toolMajor, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR)); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.toolMinor, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR)); env->SetFloatField(outPointerCoordsObj, gPointerCoordsClassInfo.orientation, rawPointerCoords->getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION)); rawPointerCoords->getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION)); const uint32_t unpackedAxisBits = 0 | (1 << AINPUT_MOTION_AXIS_X) | (1 << AINPUT_MOTION_AXIS_Y) | (1 << AINPUT_MOTION_AXIS_PRESSURE) | (1 << AINPUT_MOTION_AXIS_SIZE) | (1 << AINPUT_MOTION_AXIS_TOUCH_MAJOR) | (1 << AINPUT_MOTION_AXIS_TOUCH_MINOR) | (1 << AINPUT_MOTION_AXIS_TOOL_MAJOR) | (1 << AINPUT_MOTION_AXIS_TOOL_MINOR) | (1 << AINPUT_MOTION_AXIS_ORIENTATION); | (1 << AMOTION_EVENT_AXIS_X) | (1 << AMOTION_EVENT_AXIS_Y) | (1 << AMOTION_EVENT_AXIS_PRESSURE) | (1 << AMOTION_EVENT_AXIS_SIZE) | (1 << AMOTION_EVENT_AXIS_TOUCH_MAJOR) | (1 << AMOTION_EVENT_AXIS_TOUCH_MINOR) | (1 << AMOTION_EVENT_AXIS_TOOL_MAJOR) | (1 << AMOTION_EVENT_AXIS_TOOL_MINOR) | (1 << AMOTION_EVENT_AXIS_ORIENTATION); uint32_t outBits = 0; uint32_t remainingBits = rawPointerCoords->bits & ~unpackedAxisBits; Loading Loading @@ -610,7 +610,7 @@ static jint android_view_MotionEvent_nativeReadFromParcel(JNIEnv* env, jclass cl Parcel* parcel = parcelForJavaObject(env, parcelObj); status_t status = event->readFromParcel(parcel); if (!status) { if (status) { if (!nativePtr) { delete event; } Loading @@ -626,7 +626,7 @@ static void android_view_MotionEvent_nativeWriteToParcel(JNIEnv* env, jclass cla Parcel* parcel = parcelForJavaObject(env, parcelObj); status_t status = event->writeToParcel(parcel); if (!status) { if (status) { jniThrowRuntimeException(env, "Failed to write MotionEvent parcel."); } } Loading
include/ui/Input.h +26 −25 Original line number Diff line number Diff line Loading @@ -170,7 +170,7 @@ struct InputConfiguration { * Pointer coordinate data. */ struct PointerCoords { static const size_t MAX_AXES = 15; // 15 so that sizeof(PointerCoords) == 16 * 4 == 64 enum { MAX_AXES = 15 }; // 15 so that sizeof(PointerCoords) == 16 * 4 == 64 // Bitfield of axes that are present in this structure. uint32_t bits; // 32bits are enough for now, can raise to 64bit when needed Loading @@ -192,14 +192,14 @@ struct PointerCoords { return values[index]; } inline void setAxisValue(int32_t axis, float value) { inline status_t setAxisValue(int32_t axis, float value) { uint32_t axisBit = 1 << axis; uint32_t index = __builtin_popcount(bits & (axisBit - 1)); if (!(bits & axisBit)) { uint32_t count = __builtin_popcount(bits); if (count >= MAX_AXES) { tooManyAxes(axis); return; return NO_MEMORY; } bits |= axisBit; for (uint32_t i = count; i > index; i--) { Loading @@ -207,6 +207,7 @@ struct PointerCoords { } } values[index] = value; return OK; } inline float* editAxisValue(int32_t axis) { Loading Loading @@ -351,49 +352,49 @@ public: float getRawAxisValue(int32_t axis, size_t pointerIndex) const; inline float getRawX(size_t pointerIndex) const { return getRawAxisValue(AINPUT_MOTION_AXIS_X, pointerIndex); return getRawAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex); } inline float getRawY(size_t pointerIndex) const { return getRawAxisValue(AINPUT_MOTION_AXIS_Y, pointerIndex); return getRawAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex); } float getAxisValue(int32_t axis, size_t pointerIndex) const; inline float getX(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_X, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex); } inline float getY(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_Y, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex); } inline float getPressure(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_PRESSURE, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pointerIndex); } inline float getSize(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_SIZE, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_SIZE, pointerIndex); } inline float getTouchMajor(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex); } inline float getTouchMinor(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex); } inline float getToolMajor(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex); } inline float getToolMinor(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex); } inline float getOrientation(size_t pointerIndex) const { return getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION, pointerIndex); return getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex); } inline size_t getHistorySize() const { return mSampleEventTimes.size() - 1; } Loading @@ -410,59 +411,59 @@ public: inline float getHistoricalRawX(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalRawAxisValue( AINPUT_MOTION_AXIS_X, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex); } inline float getHistoricalRawY(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalRawAxisValue( AINPUT_MOTION_AXIS_Y, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex); } float getHistoricalAxisValue(int32_t axis, size_t pointerIndex, size_t historicalIndex) const; inline float getHistoricalX(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_X, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex); } inline float getHistoricalY(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_Y, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex); } inline float getHistoricalPressure(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_PRESSURE, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_PRESSURE, pointerIndex, historicalIndex); } inline float getHistoricalSize(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_SIZE, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_SIZE, pointerIndex, historicalIndex); } inline float getHistoricalTouchMajor(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_TOUCH_MAJOR, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex, historicalIndex); } inline float getHistoricalTouchMinor(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_TOUCH_MINOR, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex, historicalIndex); } inline float getHistoricalToolMajor(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_TOOL_MAJOR, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex, historicalIndex); } inline float getHistoricalToolMinor(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_TOOL_MINOR, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex, historicalIndex); } inline float getHistoricalOrientation(size_t pointerIndex, size_t historicalIndex) const { return getHistoricalAxisValue( AINPUT_MOTION_AXIS_ORIENTATION, pointerIndex, historicalIndex); AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex, historicalIndex); } void initialize( Loading
libs/ui/Input.cpp +15 −15 Original line number Diff line number Diff line Loading @@ -362,10 +362,10 @@ float MotionEvent::getRawAxisValue(int32_t axis, size_t pointerIndex) const { float MotionEvent::getAxisValue(int32_t axis, size_t pointerIndex) const { float value = getRawPointerCoords(pointerIndex)->getAxisValue(axis); switch (axis) { case AINPUT_MOTION_AXIS_X: case AMOTION_EVENT_AXIS_X: value += mXOffset; break; case AINPUT_MOTION_AXIS_Y: case AMOTION_EVENT_AXIS_Y: value += mYOffset; break; } Loading @@ -386,10 +386,10 @@ float MotionEvent::getHistoricalAxisValue(int32_t axis, size_t pointerIndex, size_t historicalIndex) const { float value = getHistoricalRawPointerCoords(pointerIndex, historicalIndex)->getAxisValue(axis); switch (axis) { case AINPUT_MOTION_AXIS_X: case AMOTION_EVENT_AXIS_X: value += mXOffset; break; case AINPUT_MOTION_AXIS_Y: case AMOTION_EVENT_AXIS_Y: value += mYOffset; break; } Loading Loading @@ -419,12 +419,12 @@ void MotionEvent::scale(float scaleFactor) { PointerCoords& c = mSamplePointerCoords.editItemAt(i); // No need to scale pressure or size since they are normalized. // No need to scale orientation since it is meaningless to do so. scaleAxisValue(c, AINPUT_MOTION_AXIS_X, scaleFactor); scaleAxisValue(c, AINPUT_MOTION_AXIS_Y, scaleFactor); scaleAxisValue(c, AINPUT_MOTION_AXIS_TOUCH_MAJOR, scaleFactor); scaleAxisValue(c, AINPUT_MOTION_AXIS_TOUCH_MINOR, scaleFactor); scaleAxisValue(c, AINPUT_MOTION_AXIS_TOOL_MAJOR, scaleFactor); scaleAxisValue(c, AINPUT_MOTION_AXIS_TOOL_MINOR, scaleFactor); scaleAxisValue(c, AMOTION_EVENT_AXIS_X, scaleFactor); scaleAxisValue(c, AMOTION_EVENT_AXIS_Y, scaleFactor); scaleAxisValue(c, AMOTION_EVENT_AXIS_TOUCH_MAJOR, scaleFactor); scaleAxisValue(c, AMOTION_EVENT_AXIS_TOUCH_MINOR, scaleFactor); scaleAxisValue(c, AMOTION_EVENT_AXIS_TOOL_MAJOR, scaleFactor); scaleAxisValue(c, AMOTION_EVENT_AXIS_TOOL_MINOR, scaleFactor); } } Loading Loading @@ -471,8 +471,8 @@ void MotionEvent::transform(const SkMatrix* matrix) { size_t numSamples = mSamplePointerCoords.size(); for (size_t i = 0; i < numSamples; i++) { PointerCoords& c = mSamplePointerCoords.editItemAt(i); float* xPtr = c.editAxisValue(AINPUT_MOTION_AXIS_X); float* yPtr = c.editAxisValue(AINPUT_MOTION_AXIS_Y); float* xPtr = c.editAxisValue(AMOTION_EVENT_AXIS_X); float* yPtr = c.editAxisValue(AMOTION_EVENT_AXIS_Y); if (xPtr && yPtr) { float x = *xPtr + oldXOffset; float y = *yPtr + oldYOffset; Loading @@ -481,7 +481,7 @@ void MotionEvent::transform(const SkMatrix* matrix) { *yPtr = SkScalarToFloat(point.fY) - newYOffset; } float* orientationPtr = c.editAxisValue(AINPUT_MOTION_AXIS_ORIENTATION); float* orientationPtr = c.editAxisValue(AMOTION_EVENT_AXIS_ORIENTATION); if (orientationPtr) { *orientationPtr = transformAngle(matrix, *orientationPtr); } Loading Loading @@ -523,7 +523,7 @@ status_t MotionEvent::readFromParcel(Parcel* parcel) { for (size_t i = 0; i < pointerCount; i++) { mSamplePointerCoords.push(); status_t status = mSamplePointerCoords.editTop().readFromParcel(parcel); if (!status) { if (status) { return status; } } Loading Loading @@ -559,7 +559,7 @@ status_t MotionEvent::writeToParcel(Parcel* parcel) const { parcel->writeInt64(mSampleEventTimes.itemAt(h)); for (size_t i = 0; i < pointerCount; i++) { status_t status = (pc++)->writeToParcel(parcel); if (!status) { if (status) { return status; } } Loading
libs/ui/tests/Android.mk +5 −2 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ ifneq ($(TARGET_SIMULATOR),true) # Build the unit tests. test_src_files := \ InputChannel_test.cpp \ InputEvent_test.cpp \ InputPublisherAndConsumer_test.cpp shared_libraries := \ Loading @@ -18,7 +19,8 @@ shared_libraries := \ libhardware \ libhardware_legacy \ libui \ libstlport libstlport \ libskia static_libraries := \ libgtest \ Loading @@ -28,7 +30,8 @@ c_includes := \ bionic \ bionic/libstdc++/include \ external/gtest/include \ external/stlport/stlport external/stlport/stlport \ external/skia/include/core module_tags := eng tests Loading
libs/ui/tests/InputChannel_test.cpp +15 −3 Original line number Diff line number Diff line // // Copyright 2010 The Android Open Source Project // /* * Copyright (C) 2010 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 <ui/InputTransport.h> #include <utils/Timers.h> Loading