From 3d2d30b95bff00bd71512fcccdc716ce9fa7f4c5 Mon Sep 17 00:00:00 2001 From: wangshuo <584363327@qq.com> Date: Tue, 18 Jul 2023 11:46:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A7=A6=E6=8E=A7=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BC=A0=E8=BE=93=E6=8C=89=E7=85=A7=E6=96=87=E6=A1=A3=E8=A7=84?= =?UTF-8?q?=E5=AE=9A=E4=BC=A0=E8=BE=93=EF=BC=8C=E8=A7=A3=E5=86=B3=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=89=8B=E6=9C=BA=E6=A8=AA=E5=B1=8F=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E8=A7=A6=E6=8E=A7=E4=B8=8D=E7=94=9F=E6=95=88=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloudphone/apiimpl/CloudPhoneImpl.java | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java b/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java index 323f84a..4137760 100644 --- a/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java +++ b/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java @@ -101,12 +101,8 @@ public class CloudPhoneImpl implements ICloudPhone { private Activity mActivity; private ViewGroup mViewGroup; private SurfaceView mSurfaceView = null; - private int mDisplayWidth = 9; + private int mDisplayWidth = 0; private int mDisplayHeight = 0; - private int mInputWidth = 720; - private int mInputHeight = 1280; - private float mInputXScale; - private float mInputYScale; private int mCurrentState; private DisplayMode mDisplayMode = DISPLAY_MODE_FILL; private boolean mServiceConnect = false; @@ -354,16 +350,15 @@ public class CloudPhoneImpl implements ICloudPhone { @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - CASLog.i(TAG, "width = " + width + " height = " + height); - mDisplayWidth = width; - mDisplayHeight = height; - if (mDisplayWidth > mDisplayHeight) { - mInputYScale = (float) mDisplayWidth / (float) mInputHeight; - mInputXScale = (float) mDisplayHeight / (float) mInputWidth; + + if (width > height) { + mDisplayWidth = height; + mDisplayHeight = width; } else { - mInputXScale = (float) mDisplayWidth / (float) mInputWidth; - mInputYScale = (float) mDisplayHeight / (float) mInputHeight; + mDisplayWidth = width; + mDisplayHeight = height; } + CASLog.i(TAG, "width = " + mDisplayWidth + " height = " + mDisplayHeight); if (!mIsNewCreated) { return; @@ -660,7 +655,7 @@ public class CloudPhoneImpl implements ICloudPhone { private boolean sendTouchEvent(int id, int action, final int x1, final int y1, final int pressure, long time) { int orientation = 0; - int new_orientation = 0; + int newOrientation = 0; if (mActivity != null) { try { orientation = mActivity.getRequestedOrientation(); @@ -673,24 +668,28 @@ public class CloudPhoneImpl implements ICloudPhone { switch (orientation) { case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: - new_orientation = 0; + newOrientation = 0; break; case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: - new_orientation = 1; + newOrientation = 1; break; case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: - new_orientation = 2; + newOrientation = 2; break; case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: - new_orientation = 3; + newOrientation = 3; break; default: CASLog.i(TAG, "invalid directation " + orientation); - break; + return false; } - return mCASClient.sendTouchEvent(id, action, x1, y1, pressure, time, new_orientation, mDisplayHeight, mDisplayWidth); + if (newOrientation == 0 || newOrientation == 2) { + return mCASClient.sendTouchEvent(id, action, x1, y1, pressure, time, newOrientation, mDisplayHeight, mDisplayWidth); + } else { + return mCASClient.sendTouchEvent(id, action, y1, x1, pressure, time, newOrientation, mDisplayHeight, mDisplayWidth); + } } public static class JNIState { -- Gitee From b319df58c48b7caee174da828ec685cdcc26d5c8 Mon Sep 17 00:00:00 2001 From: wangshuo <584363327@qq.com> Date: Tue, 18 Jul 2023 16:58:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A7=A6=E6=8E=A7=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BC=A0=E8=BE=93=E6=8C=89=E7=85=A7=E6=96=87=E6=A1=A3=E8=A7=84?= =?UTF-8?q?=E5=AE=9A=E4=BC=A0=E8=BE=93=EF=BC=8C=E8=A7=A3=E5=86=B3=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=89=8B=E6=9C=BA=E6=A8=AA=E5=B1=8F=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E8=A7=A6=E6=8E=A7=E4=B8=8D=E7=94=9F=E6=95=88=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloudphone/apiimpl/CloudPhoneImpl.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java b/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java index 4137760..678830c 100644 --- a/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java +++ b/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java @@ -351,13 +351,8 @@ public class CloudPhoneImpl implements ICloudPhone { @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - if (width > height) { - mDisplayWidth = height; - mDisplayHeight = width; - } else { - mDisplayWidth = width; - mDisplayHeight = height; - } + mDisplayWidth = Math.min(width, height); + mDisplayHeight = Math.max(width, height); CASLog.i(TAG, "width = " + mDisplayWidth + " height = " + mDisplayHeight); if (!mIsNewCreated) { @@ -685,11 +680,12 @@ public class CloudPhoneImpl implements ICloudPhone { return false; } - if (newOrientation == 0 || newOrientation == 2) { - return mCASClient.sendTouchEvent(id, action, x1, y1, pressure, time, newOrientation, mDisplayHeight, mDisplayWidth); - } else { - return mCASClient.sendTouchEvent(id, action, y1, x1, pressure, time, newOrientation, mDisplayHeight, mDisplayWidth); + int x = x1, y = y1; + if (newOrientation == 1 || newOrientation == 3) { + x = x1 * mDisplayWidth / mDisplayHeight; + y = y1 * mDisplayHeight / mDisplayWidth; } + return mCASClient.sendTouchEvent(id, action, x, y, pressure, time, newOrientation, mDisplayHeight, mDisplayWidth); } public static class JNIState { -- Gitee