OSDN Git Service

Default to TOOL_TYPE_STYLUS for external stylus events.
authorMichael Wright <michaelwr@google.com>
Tue, 21 Apr 2015 18:01:58 +0000 (19:01 +0100)
committerMichael Wright <michaelwr@google.com>
Tue, 21 Apr 2015 21:41:15 +0000 (22:41 +0100)
Change-Id: Ife6a7c4802e8b1ec1ff8445e639f8a6d90a00592

services/inputflinger/InputReader.cpp

index 3e9f765..8de8132 100644 (file)
@@ -6511,6 +6511,11 @@ void ExternalStylusInputMapper::sync(nsecs_t when) {
 
     mStylusState.when = when;
 
+    mStylusState.toolType = mTouchButtonAccumulator.getToolType();
+    if (mStylusState.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+        mStylusState.toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+    }
+
     int32_t pressure = mSingleTouchMotionAccumulator.getAbsolutePressure();
     if (mRawPressureAxis.valid) {
         mStylusState.pressure = float(pressure) / mRawPressureAxis.maxValue;
@@ -6521,7 +6526,6 @@ void ExternalStylusInputMapper::sync(nsecs_t when) {
     }
 
     mStylusState.buttons = mTouchButtonAccumulator.getButtonState();
-    mStylusState.toolType = mTouchButtonAccumulator.getToolType();
 
     mContext->dispatchExternalStylusState(mStylusState);
 }