|
|
/media/doraemon/works/android/mtk/6735/b2/alps_ok/frameworks/native/services/inputflinger/InputReader.cpp::::::::::
void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
int32_t oldDeviceMode = mDeviceMode;
// Determine device mode.
if (mParameters.deviceType == Parameters: EVICE_TYPE_POINTER
&& mConfig.pointerGesturesEnabled) {
mSource = AINPUT_SOURCE_MOUSE;
mDeviceMode = DEVICE_MODE_POINTER;
if (hasStylus()) {
mSource |= AINPUT_SOURCE_STYLUS;
}
} else if (mParameters.deviceType == Parameters: EVICE_TYPE_TOUCH_SCREEN
&& mParameters.hasAssociatedDisplay) {
mSource = AINPUT_SOURCE_TOUCHSCREEN;
mDeviceMode = DEVICE_MODE_DIRECT;
if (hasStylus()) {
mSource |= AINPUT_SOURCE_STYLUS;
}
} else if (mParameters.deviceType == Parameters: EVICE_TYPE_TOUCH_NAVIGATION) {
mSource = AINPUT_SOURCE_TOUCH_NAVIGATION;
mDeviceMode = DEVICE_MODE_NAVIGATION;
} else {
mSource = AINPUT_SOURCE_TOUCHPAD;
mDeviceMode = DEVICE_MODE_UNSCALED;
}
// Ensure we have valid X and Y axes.
if (!mRawPointerAxes.x.valid || !mRawPointerAxes.y.valid) {
ALOGW(INDENT "Touch device '%s' did not report support for X or Y axis! "
"The device will be inoperable.", getDeviceName().string());
mDeviceMode = DEVICE_MODE_DISABLED;
return;
}
// Raw width and height in the natural orientation.
int32_t rawWidth = mRawPointerAxes.x.maxValue - mRawPointerAxes.x.minValue + 1;
int32_t rawHeight = mRawPointerAxes.y.maxValue - mRawPointerAxes.y.minValue + 1;
// Get associated display dimensions.
DisplayViewport newViewport;
if (mParameters.hasAssociatedDisplay) {
if (!mConfig.getDisplayInfo(mParameters.associatedDisplayIsExternal, &newViewport)) {
ALOGI(INDENT "Touch device '%s' could not query the properties of its associated "
"display. The device will be inoperable until the display size "
"becomes available.",
getDeviceName().string());
mDeviceMode = DEVICE_MODE_DISABLED;
return;
}
} else {
newViewport.setNonDisplayViewport(rawWidth, rawHeight);
}
bool viewportChanged = mViewport != newViewport;
if (viewportChanged) {
mViewport = newViewport;
if (mDeviceMode == DEVICE_MODE_DIRECT || mDeviceMode == DEVICE_MODE_POINTER) {
// Convert rotated viewport to natural surface coordinates.
int32_t naturalLogicalWidth, naturalLogicalHeight;
int32_t naturalPhysicalWidth, naturalPhysicalHeight;
int32_t naturalPhysicalLeft, naturalPhysicalTop;
int32_t naturalDeviceWidth, naturalDeviceHeight;
switch (mViewport.orientation) {
case DISPLAY_ORIENTATION_90:
naturalLogicalWidth = mViewport.logicalBottom - mViewport.logicalTop;
naturalLogicalHeight = mViewport.logicalRight - mViewport.logicalLeft;
naturalPhysicalWidth = mViewport.physicalBottom - mViewport.physicalTop;
naturalPhysicalHeight = mViewport.physicalRight - mViewport.physicalLeft;
naturalPhysicalLeft = mViewport.deviceHeight - mViewport.physicalBottom;
naturalPhysicalTop = mViewport.physicalLeft;
naturalDeviceWidth = mViewport.deviceHeight;
naturalDeviceHeight = mViewport.deviceWidth;
break;
case DISPLAY_ORIENTATION_180:
naturalLogicalWidth = mViewport.logicalRight - mViewport.logicalLeft;
naturalLogicalHeight = mViewport.logicalBottom - mViewport.logicalTop;
naturalPhysicalWidth = mViewport.physicalRight - mViewport.physicalLeft;
naturalPhysicalHeight = mViewport.physicalBottom - mViewport.physicalTop;
naturalPhysicalLeft = mViewport.deviceWidth - mViewport.physicalRight;
naturalPhysicalTop = mViewport.deviceHeight - mViewport.physicalBottom;
naturalDeviceWidth = mViewport.deviceWidth;
naturalDeviceHeight = mViewport.deviceHeight;
break;
case DISPLAY_ORIENTATION_270:
naturalLogicalWidth = mViewport.logicalBottom - mViewport.logicalTop;
naturalLogicalHeight = mViewport.logicalRight - mViewport.logicalLeft;
naturalPhysicalWidth = mViewport.physicalBottom - mViewport.physicalTop;
naturalPhysicalHeight = mViewport.physicalRight - mViewport.physicalLeft;
naturalPhysicalLeft = mViewport.physicalTop;
naturalPhysicalTop = mViewport.deviceWidth - mViewport.physicalRight;
naturalDeviceWidth = mViewport.deviceHeight;
naturalDeviceHeight = mViewport.deviceWidth;
break;
case DISPLAY_ORIENTATION_0:
default:
naturalLogicalWidth = mViewport.logicalRight - mViewport.logicalLeft;
naturalLogicalHeight = mViewport.logicalBottom - mViewport.logicalTop;
naturalPhysicalWidth = mViewport.physicalRight - mViewport.physicalLeft;
naturalPhysicalHeight = mViewport.physicalBottom - mViewport.physicalTop;
naturalPhysicalLeft = mViewport.physicalLeft;
naturalPhysicalTop = mViewport.physicalTop;
naturalDeviceWidth = mViewport.deviceWidth;
naturalDeviceHeight = mViewport.deviceHeight;
break;
}
//zcfdebug++<<
naturalLogicalWidth = mViewport.logicalBottom - mViewport.logicalTop;
naturalLogicalHeight = mViewport.logicalRight - mViewport.logicalLeft;
naturalPhysicalWidth = mViewport.physicalBottom - mViewport.physicalTop;
naturalPhysicalHeight = mViewport.physicalRight - mViewport.physicalLeft;
naturalPhysicalLeft = mViewport.deviceHeight - mViewport.physicalBottom;
naturalPhysicalTop = mViewport.physicalLeft;
naturalDeviceWidth = mViewport.deviceHeight;
naturalDeviceHeight = mViewport.deviceWidth;
ALOGI("zcfdebug","naturalLogicalWidth is %d",naturalLogicalWidth);
ALOGI("zcfdebug","naturalLogicalHeight is %d",naturalLogicalHeight);
ALOGI("zcfdebug","naturalPhysicalWidth is %d",naturalPhysicalWidth);
ALOGI("zcfdebug","naturalPhysicalHeight is %d",naturalPhysicalHeight);
ALOGI("zcfdebug","naturalPhysicalLeft is %d",naturalPhysicalLeft);
ALOGI("zcfdebug","naturalPhysicalTop is %d",naturalPhysicalTop);
ALOGI("zcfdebug","naturalDeviceWidth is %d",naturalDeviceWidth);
ALOGI("zcfdebug","naturalDeviceHeight is %d",naturalDeviceHeight);
//zcfdebug>>++
mSurfaceWidth = naturalLogicalWidth * naturalDeviceWidth / naturalPhysicalWidth;
mSurfaceHeight = naturalLogicalHeight * naturalDeviceHeight / naturalPhysicalHeight;
mSurfaceHeight=mSurfaceHeight*2;
mSurfaceLeft = naturalPhysicalLeft * naturalLogicalWidth / naturalPhysicalWidth;
mSurfaceTop = naturalPhysicalTop * naturalLogicalHeight / naturalPhysicalHeight;
//zcfdebug-- mSurfaceOrientation = mParameters.orientationAware ?
//zcfdebug-- mViewport.orientation : DISPLAY_ORIENTATION_0;
mSurfaceOrientation = DISPLAY_ORIENTATION_90;//zcfdebug++
//zcfdebug-- mViewport.orientation : DISPLAY_ORIENTATION_0;
} else {
mSurfaceWidth = rawWidth;
mSurfaceHeight = rawHeight;
mSurfaceLeft = 0;
mSurfaceTop = 0;
mSurfaceOrientation = DISPLAY_ORIENTATION_0;
}
}
|
|