From 12d6baa9b832f16a28f048ed5ffab75a76ed9c41 Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Mon, 27 Jan 2014 18:34:20 -0800 Subject: [PATCH] Initialize mAffineTransform and update on modification This patch causes the InputReader to update its mAffineTransform to reflect the currently-set calibration on startup and whenever its value is changed through the InputManagerService. Change-Id: I4719122a28afa9833772040f0433780a84240b9d --- services/inputflinger/InputReader.cpp | 9 +++++++++ services/inputflinger/InputReader.h | 9 +++++++++ services/inputflinger/tests/InputReader_test.cpp | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 9a4f84882..a8ccf8bb0 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -2752,6 +2752,11 @@ void TouchInputMapper::configure(nsecs_t when, resolveCalibration(); } + if (!changes || (changes & InputReaderConfiguration::TOUCH_AFFINE_TRANSFORMATION)) { + // Update location calibration to reflect current settings + updateAffineTransformation(); + } + if (!changes || (changes & InputReaderConfiguration::CHANGE_POINTER_SPEED)) { // Update pointer speed. mPointerVelocityControl.setParameters(mConfig.pointerVelocityControlParameters); @@ -3654,6 +3659,10 @@ void TouchInputMapper::dumpAffineTransformation(String8& dump) { dump.appendFormat(INDENT4 "Y offset: %0.3f\n", mAffineTransform.y_offset); } +void TouchInputMapper::updateAffineTransformation() { + mAffineTransform = getPolicy()->getTouchAffineTransformation(mDevice->getDescriptor()); +} + void TouchInputMapper::reset(nsecs_t when) { mCursorButtonAccumulator.reset(getDevice()); mCursorScrollAccumulator.reset(getDevice()); diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h index 5c72c715e..0e57bcd6e 100644 --- a/services/inputflinger/InputReader.h +++ b/services/inputflinger/InputReader.h @@ -138,6 +138,9 @@ struct InputReaderConfiguration { // The device name alias supplied by the may have changed for some devices. CHANGE_DEVICE_ALIAS = 1 << 5, + // The location calibration matrix changed. + TOUCH_AFFINE_TRANSFORMATION = 1 << 6, + // All devices must be reopened. CHANGE_MUST_REOPEN = 1 << 31, }; @@ -304,6 +307,10 @@ public: /* Gets a user-supplied alias for a particular input device, or an empty string if none. */ virtual String8 getDeviceAlias(const InputDeviceIdentifier& identifier) = 0; + + /* Gets the affine calibration associated with the specified device. */ + virtual TouchAffineTransformation getTouchAffineTransformation( + const String8& inputDeviceDescriptor) = 0; }; @@ -535,6 +542,7 @@ public: inline int32_t getControllerNumber() const { return mControllerNumber; } inline int32_t getGeneration() const { return mGeneration; } inline const String8& getName() const { return mIdentifier.name; } + inline const String8& getDescriptor() { return mIdentifier.descriptor; } inline uint32_t getClasses() const { return mClasses; } inline uint32_t getSources() const { return mSources; } @@ -1366,6 +1374,7 @@ protected: virtual void dumpCalibration(String8& dump); virtual void dumpAffineTransformation(String8& dump); virtual bool hasStylus() const = 0; + virtual void updateAffineTransformation(); virtual void syncTouch(nsecs_t when, bool* outHavePointerIds) = 0; diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp index aaa973db4..140d16926 100644 --- a/services/inputflinger/tests/InputReader_test.cpp +++ b/services/inputflinger/tests/InputReader_test.cpp @@ -173,6 +173,10 @@ public: return mInputDevices; } + TouchAffineTransformation getTouchAffineTransformation(const String8& inputDeviceDescriptor) { + return TouchAffineTransformation(); + } + private: virtual void getReaderConfiguration(InputReaderConfiguration* outConfig) { *outConfig = mConfig;