@@ -203,34 +203,18 @@ static void synthesizeButtonKeys(InputReaderContext* context, int32_t action,
203203
204204// --- InputReaderConfiguration ---
205205
206- bool InputReaderConfiguration::getDisplayInfo (int32_t displayId, bool external,
207- int32_t * width, int32_t * height, int32_t * orientation) const {
208- if (displayId == 0 ) {
209- const DisplayInfo& info = external ? mExternalDisplay : mInternalDisplay ;
210- if (info.width > 0 && info.height > 0 ) {
211- if (width) {
212- *width = info.width ;
213- }
214- if (height) {
215- *height = info.height ;
216- }
217- if (orientation) {
218- *orientation = info.orientation ;
219- }
220- return true ;
221- }
206+ bool InputReaderConfiguration::getDisplayInfo (bool external, DisplayViewport* outViewport) const {
207+ const DisplayViewport& viewport = external ? mExternalDisplay : mInternalDisplay ;
208+ if (viewport.displayId >= 0 ) {
209+ *outViewport = viewport;
210+ return true ;
222211 }
223212 return false ;
224213}
225214
226- void InputReaderConfiguration::setDisplayInfo (int32_t displayId, bool external,
227- int32_t width, int32_t height, int32_t orientation) {
228- if (displayId == 0 ) {
229- DisplayInfo& info = external ? mExternalDisplay : mInternalDisplay ;
230- info.width = width;
231- info.height = height;
232- info.orientation = orientation;
233- }
215+ void InputReaderConfiguration::setDisplayInfo (bool external, const DisplayViewport& viewport) {
216+ DisplayViewport& v = external ? mExternalDisplay : mInternalDisplay ;
217+ v = viewport;
234218}
235219
236220
@@ -2001,9 +1985,11 @@ void KeyboardInputMapper::configure(nsecs_t when,
20011985 }
20021986
20031987 if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
2004- if (mParameters .orientationAware && mParameters .associatedDisplayId >= 0 ) {
2005- if (!config->getDisplayInfo (mParameters .associatedDisplayId ,
2006- false /* external*/ , NULL , NULL , &mOrientation )) {
1988+ if (mParameters .orientationAware && mParameters .hasAssociatedDisplay ) {
1989+ DisplayViewport v;
1990+ if (config->getDisplayInfo (false /* external*/ , &v)) {
1991+ mOrientation = v.orientation ;
1992+ } else {
20071993 mOrientation = DISPLAY_ORIENTATION_0;
20081994 }
20091995 } else {
@@ -2017,16 +2003,16 @@ void KeyboardInputMapper::configureParameters() {
20172003 getDevice ()->getConfiguration ().tryGetProperty (String8 (" keyboard.orientationAware" ),
20182004 mParameters .orientationAware );
20192005
2020- mParameters .associatedDisplayId = - 1 ;
2006+ mParameters .hasAssociatedDisplay = false ;
20212007 if (mParameters .orientationAware ) {
2022- mParameters .associatedDisplayId = 0 ;
2008+ mParameters .hasAssociatedDisplay = true ;
20232009 }
20242010}
20252011
20262012void KeyboardInputMapper::dumpParameters (String8& dump) {
20272013 dump.append (INDENT3 " Parameters:\n " );
2028- dump.appendFormat (INDENT4 " AssociatedDisplayId : %d \n " ,
2029- mParameters .associatedDisplayId );
2014+ dump.appendFormat (INDENT4 " HasAssociatedDisplay : %s \n " ,
2015+ toString ( mParameters .hasAssociatedDisplay ) );
20302016 dump.appendFormat (INDENT4 " OrientationAware: %s\n " ,
20312017 toString (mParameters .orientationAware ));
20322018}
@@ -2086,7 +2072,7 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t keyCode,
20862072
20872073 if (down) {
20882074 // Rotate key codes according to orientation if needed.
2089- if (mParameters .orientationAware && mParameters .associatedDisplayId >= 0 ) {
2075+ if (mParameters .orientationAware && mParameters .hasAssociatedDisplay ) {
20902076 keyCode = rotateKeyCode (keyCode, mOrientation );
20912077 }
20922078
@@ -2317,9 +2303,11 @@ void CursorInputMapper::configure(nsecs_t when,
23172303 }
23182304
23192305 if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
2320- if (mParameters .orientationAware && mParameters .associatedDisplayId >= 0 ) {
2321- if (!config->getDisplayInfo (mParameters .associatedDisplayId ,
2322- false /* external*/ , NULL , NULL , &mOrientation )) {
2306+ if (mParameters .orientationAware && mParameters .hasAssociatedDisplay ) {
2307+ DisplayViewport v;
2308+ if (config->getDisplayInfo (false /* external*/ , &v)) {
2309+ mOrientation = v.orientation ;
2310+ } else {
23232311 mOrientation = DISPLAY_ORIENTATION_0;
23242312 }
23252313 } else {
@@ -2344,16 +2332,16 @@ void CursorInputMapper::configureParameters() {
23442332 getDevice ()->getConfiguration ().tryGetProperty (String8 (" cursor.orientationAware" ),
23452333 mParameters .orientationAware );
23462334
2347- mParameters .associatedDisplayId = - 1 ;
2335+ mParameters .hasAssociatedDisplay = false ;
23482336 if (mParameters .mode == Parameters::MODE_POINTER || mParameters .orientationAware ) {
2349- mParameters .associatedDisplayId = 0 ;
2337+ mParameters .hasAssociatedDisplay = true ;
23502338 }
23512339}
23522340
23532341void CursorInputMapper::dumpParameters (String8& dump) {
23542342 dump.append (INDENT3 " Parameters:\n " );
2355- dump.appendFormat (INDENT4 " AssociatedDisplayId : %d \n " ,
2356- mParameters .associatedDisplayId );
2343+ dump.appendFormat (INDENT4 " HasAssociatedDisplay : %s \n " ,
2344+ toString ( mParameters .hasAssociatedDisplay ) );
23572345
23582346 switch (mParameters .mode ) {
23592347 case Parameters::MODE_POINTER:
@@ -2420,7 +2408,7 @@ void CursorInputMapper::sync(nsecs_t when) {
24202408 bool moved = deltaX != 0 || deltaY != 0 ;
24212409
24222410 // Rotate delta according to orientation if needed.
2423- if (mParameters .orientationAware && mParameters .associatedDisplayId >= 0
2411+ if (mParameters .orientationAware && mParameters .hasAssociatedDisplay
24242412 && (deltaX != 0 .0f || deltaY != 0 .0f )) {
24252413 rotateDelta (mOrientation , &deltaX, &deltaY);
24262414 }
@@ -2782,15 +2770,15 @@ void TouchInputMapper::configureParameters() {
27822770 getDevice ()->getConfiguration ().tryGetProperty (String8 (" touch.orientationAware" ),
27832771 mParameters .orientationAware );
27842772
2785- mParameters .associatedDisplayId = - 1 ;
2773+ mParameters .hasAssociatedDisplay = false ;
27862774 mParameters .associatedDisplayIsExternal = false ;
27872775 if (mParameters .orientationAware
27882776 || mParameters .deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN
27892777 || mParameters .deviceType == Parameters::DEVICE_TYPE_POINTER) {
2778+ mParameters .hasAssociatedDisplay = true ;
27902779 mParameters .associatedDisplayIsExternal =
27912780 mParameters .deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN
27922781 && getDevice ()->isExternal ();
2793- mParameters .associatedDisplayId = 0 ;
27942782 }
27952783}
27962784
@@ -2822,8 +2810,9 @@ void TouchInputMapper::dumpParameters(String8& dump) {
28222810 ALOG_ASSERT (false );
28232811 }
28242812
2825- dump.appendFormat (INDENT4 " AssociatedDisplay: id=%d, isExternal=%s\n " ,
2826- mParameters .associatedDisplayId , toString (mParameters .associatedDisplayIsExternal ));
2813+ dump.appendFormat (INDENT4 " AssociatedDisplay: present=%s, isExternal=%s\n " ,
2814+ toString (mParameters .hasAssociatedDisplay ),
2815+ toString (mParameters .associatedDisplayIsExternal ));
28272816 dump.appendFormat (INDENT4 " OrientationAware: %s\n " ,
28282817 toString (mParameters .orientationAware ));
28292818}
@@ -2861,7 +2850,7 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
28612850 mSource |= AINPUT_SOURCE_STYLUS;
28622851 }
28632852 } else if (mParameters .deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN
2864- && mParameters .associatedDisplayId >= 0 ) {
2853+ && mParameters .hasAssociatedDisplay ) {
28652854 mSource = AINPUT_SOURCE_TOUCHSCREEN;
28662855 mDeviceMode = DEVICE_MODE_DIRECT;
28672856 if (hasStylus ()) {
@@ -2881,15 +2870,13 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
28812870 }
28822871
28832872 // Get associated display dimensions.
2884- if (mParameters .associatedDisplayId >= 0 ) {
2885- if (!mConfig .getDisplayInfo (mParameters .associatedDisplayId ,
2886- mParameters .associatedDisplayIsExternal ,
2887- &mAssociatedDisplayWidth , &mAssociatedDisplayHeight ,
2888- &mAssociatedDisplayOrientation )) {
2873+ if (mParameters .hasAssociatedDisplay ) {
2874+ if (!mConfig .getDisplayInfo (mParameters .associatedDisplayIsExternal ,
2875+ &mAssociatedDisplayViewport )) {
28892876 ALOGI (INDENT " Touch device '%s' could not query the properties of its associated "
2890- " display %d . The device will be inoperable until the display size "
2877+ " display. The device will be inoperable until the display size "
28912878 " becomes available." ,
2892- getDeviceName ().string (), mParameters . associatedDisplayId );
2879+ getDeviceName ().string ());
28932880 mDeviceMode = DEVICE_MODE_DISABLED;
28942881 return ;
28952882 }
@@ -2898,10 +2885,16 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
28982885 // Configure dimensions.
28992886 int32_t width, height, orientation;
29002887 if (mDeviceMode == DEVICE_MODE_DIRECT || mDeviceMode == DEVICE_MODE_POINTER) {
2901- width = mAssociatedDisplayWidth ;
2902- height = mAssociatedDisplayHeight ;
2888+ width = mAssociatedDisplayViewport .logicalRight - mAssociatedDisplayViewport .logicalLeft ;
2889+ height = mAssociatedDisplayViewport .logicalBottom - mAssociatedDisplayViewport .logicalTop ;
2890+ if (mAssociatedDisplayViewport .orientation == DISPLAY_ORIENTATION_90
2891+ || mAssociatedDisplayViewport .orientation == DISPLAY_ORIENTATION_270) {
2892+ int32_t temp = height;
2893+ height = width;
2894+ width = temp;
2895+ }
29032896 orientation = mParameters .orientationAware ?
2904- mAssociatedDisplayOrientation : DISPLAY_ORIENTATION_0;
2897+ mAssociatedDisplayViewport . orientation : DISPLAY_ORIENTATION_0;
29052898 } else {
29062899 width = mRawPointerAxes .x .maxValue - mRawPointerAxes .x .minValue + 1 ;
29072900 height = mRawPointerAxes .y .maxValue - mRawPointerAxes .y .minValue + 1 ;
@@ -3163,8 +3156,7 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
31633156 int32_t rawWidth = mRawPointerAxes .x .maxValue - mRawPointerAxes .x .minValue + 1 ;
31643157 int32_t rawHeight = mRawPointerAxes .y .maxValue - mRawPointerAxes .y .minValue + 1 ;
31653158 float rawDiagonal = hypotf (rawWidth, rawHeight);
3166- float displayDiagonal = hypotf (mAssociatedDisplayWidth ,
3167- mAssociatedDisplayHeight );
3159+ float displayDiagonal = hypotf (width, height);
31683160
31693161 // Scale movements such that one whole swipe of the touch pad covers a
31703162 // given area relative to the diagonal size of the display when no acceleration
0 commit comments