From 618e8360ef8fcdf46509ec90bf0b3a02b320234f Mon Sep 17 00:00:00 2001 From: ewt45 <79033456+ewt45@users.noreply.github.com> Date: Fri, 24 Nov 2023 14:28:18 +0800 Subject: [PATCH] readme --- .../GestureMachineConfigurerHoMM3.java | 72 +++++++++++++++---- .../axs/widgets/popupMenu/AXSPopupMenu.java | 8 ++- .../FAB/dialogfragment/PulseAudio.java | 72 +++++++++++-------- .../com/example/datainsert/exagear/QH.java | 9 +-- .../action/AddEnvironmentVariables.java | 4 +- .../exagear/action/AddPopupMenuItems.java | 23 ++++++ app/src/main/java/com/winlator/readme.md | 70 ++++++++++++++++++ .../ewt45/patchapp/thread/FuncAddEnvs.java | 3 +- .../com/ewt45/patchapp/thread/FuncFAB.java | 4 ++ 9 files changed, 213 insertions(+), 52 deletions(-) create mode 100644 app/src/main/java/com/example/datainsert/exagear/action/AddPopupMenuItems.java diff --git a/app/src/main/java/com/eltechs/axs/gamesControls/GestureMachineConfigurerHoMM3.java b/app/src/main/java/com/eltechs/axs/gamesControls/GestureMachineConfigurerHoMM3.java index 3c7781fd..1267aaaa 100644 --- a/app/src/main/java/com/eltechs/axs/gamesControls/GestureMachineConfigurerHoMM3.java +++ b/app/src/main/java/com/eltechs/axs/gamesControls/GestureMachineConfigurerHoMM3.java @@ -2,8 +2,12 @@ import com.eltechs.axs.GestureStateMachine.GestureContext; import com.eltechs.axs.GestureStateMachine.GestureState1FingerMeasureSpeed; -import com.eltechs.axs.GestureStateMachine.GestureState1FingerMoveToScrollAsync; +import com.eltechs.axs.GestureStateMachine.GestureState1FingerMoveToMouseMove; +import com.eltechs.axs.GestureStateMachine.GestureState1FingerMoveToScrollSync; import com.eltechs.axs.GestureStateMachine.GestureState1FingerToLongClick; +import com.eltechs.axs.GestureStateMachine.GestureState1FingerToZoomMove; +import com.eltechs.axs.GestureStateMachine.GestureState2FingersToZoom; +import com.eltechs.axs.GestureStateMachine.GestureStateCheckIfZoomed; import com.eltechs.axs.GestureStateMachine.GestureStateClickToFingerFirstCoords; import com.eltechs.axs.GestureStateMachine.GestureStateMouseWarpToFingerLastCoords; import com.eltechs.axs.GestureStateMachine.GestureStateNeutral; @@ -12,12 +16,11 @@ import com.eltechs.axs.GestureStateMachine.GestureStateWaitForNeutral; import com.eltechs.axs.GestureStateMachine.PointerContext; import com.eltechs.axs.GuestAppActionAdapters.AlignedMouseClickAdapter; -import com.eltechs.axs.GuestAppActionAdapters.AsyncScrollAdapterWithPointer; import com.eltechs.axs.GuestAppActionAdapters.MouseClickAdapterWithCheckPlacementContext; -import com.eltechs.axs.GuestAppActionAdapters.MouseMoveAdapter; +import com.eltechs.axs.GuestAppActionAdapters.OffsetMouseMoveAdapter; import com.eltechs.axs.GuestAppActionAdapters.PressAndHoldMouseClickAdapter; -import com.eltechs.axs.GuestAppActionAdapters.PressAndHoldWithPauseMouseClickAdapter; import com.eltechs.axs.GuestAppActionAdapters.PressAndReleaseMouseClickAdapter; +import com.eltechs.axs.GuestAppActionAdapters.ScrollAdapterControlArrow; import com.eltechs.axs.GuestAppActionAdapters.SimpleMouseMoveAdapter; import com.eltechs.axs.GuestAppActionAdapters.SimpleMousePointAndClickAdapter; import com.eltechs.axs.KeyCodesX; @@ -25,7 +28,7 @@ import com.eltechs.axs.TouchEventMultiplexor; import com.eltechs.axs.finiteStateMachine.FiniteStateMachine; import com.eltechs.axs.finiteStateMachine.generalStates.FSMStateRunRunnable; -import com.eltechs.axs.geom.Rectangle; +import com.eltechs.axs.widgets.viewOfXServer.TransformationHelpers; import com.eltechs.axs.widgets.viewOfXServer.ViewOfXServer; /* loaded from: classes.dex */ @@ -33,25 +36,68 @@ public class GestureMachineConfigurerHoMM3 { private static final float clickAlignThresholdInches = 0.3f; private static final float doubleClickMaxDistance = 0.15f; private static final int doubleClickMaxIntervalMs = 200; - private static final int finger2FlashMaxTimeMs = 64; - private static final int finger2SpeedCheckTimeMs = 300; - private static final float finger2StandingMaxMoveInches = 0.01f; - private static final float fingerAimingMaxMoveInches = 0.12f; + private static final float fingerAimingMaxMoveInches = 0.6f; private static final int fingerSpeedCheckTimeMs = 400; private static final float fingerStandingMaxMoveInches = 0.12f; - private static final float fingerTapMaxMoveInches = 0.12f; + private static final float fingerTapMaxMoveInches = 0.2f; private static final int fingerTapMaxTimeMs = 400; private static final int maxTapTimeMs = 100; private static final int mouseActionSleepMs = 50; private static final float pixelsInScrollUnit = 66.0f; private static final int pointerMarginXPixels = 50; private static final float pointerOffsetAimInchesX = 0.0f; - private static final float pointerOffsetAimInchesY = 0.0f; + private static final float pointerOffsetAimInchesY = -0.3f; private static final long scrollPeriodMs = 150; public static GestureContext createGestureContext(ViewOfXServer viewOfXServer, TouchArea touchArea, TouchEventMultiplexor touchEventMultiplexor, int i, Runnable runnable) { GestureContext gestureContext = new GestureContext(viewOfXServer, touchArea, touchEventMultiplexor); - + PointerContext pointerContext = new PointerContext(); + GestureStateNeutral gestureStateNeutral = new GestureStateNeutral(gestureContext); + GestureStateWaitForNeutral gestureStateWaitForNeutral = new GestureStateWaitForNeutral(gestureContext); + float f = i; + GestureState1FingerMeasureSpeed gestureState1FingerMeasureSpeed = new GestureState1FingerMeasureSpeed(gestureContext, 400, fingerStandingMaxMoveInches * f, fingerAimingMaxMoveInches * f, fingerTapMaxMoveInches * f, 400.0f); + GestureStateCheckIfZoomed gestureStateCheckIfZoomed = new GestureStateCheckIfZoomed(gestureContext); + GestureStateMouseWarpToFingerLastCoords gestureStateMouseWarpToFingerLastCoords = new GestureStateMouseWarpToFingerLastCoords(gestureContext, new SimpleMouseMoveAdapter(gestureContext.getPointerReporter()), pointerContext); + SimpleMousePointAndClickAdapter simpleMousePointAndClickAdapter = new SimpleMousePointAndClickAdapter(new SimpleMouseMoveAdapter(gestureContext.getPointerReporter()), new PressAndReleaseMouseClickAdapter(gestureContext.getPointerReporter(), 1, 50), pointerContext); + SimpleMouseMoveAdapter simpleMouseMoveAdapter = new SimpleMouseMoveAdapter(gestureContext.getPointerReporter()); + PressAndReleaseMouseClickAdapter pressAndReleaseMouseClickAdapter = new PressAndReleaseMouseClickAdapter(gestureContext.getPointerReporter(), 1, 50); + PressAndReleaseMouseClickAdapter pressAndReleaseMouseClickAdapter2 = new PressAndReleaseMouseClickAdapter(gestureContext.getPointerReporter(), 1, 50); + float f2 = clickAlignThresholdInches * f; + GestureStateClickToFingerFirstCoords gestureStateClickToFingerFirstCoords = new GestureStateClickToFingerFirstCoords(gestureContext, new MouseClickAdapterWithCheckPlacementContext(simpleMousePointAndClickAdapter, new AlignedMouseClickAdapter(simpleMouseMoveAdapter, pressAndReleaseMouseClickAdapter, pressAndReleaseMouseClickAdapter2, viewOfXServer, pointerContext, f2), new AlignedMouseClickAdapter(new SimpleMouseMoveAdapter(gestureContext.getPointerReporter()), new PressAndReleaseMouseClickAdapter(gestureContext.getPointerReporter(), 1, 50), new PressAndReleaseMouseClickAdapter(gestureContext.getPointerReporter(), 1, 50), viewOfXServer, pointerContext, 0.15f * f), pointerContext, 200)); + GestureStateWaitFingersNumberChangeWithTimeout gestureStateWaitFingersNumberChangeWithTimeout = new GestureStateWaitFingersNumberChangeWithTimeout(gestureContext, 100); + GestureStateWaitFingersNumberChangeWithTimeout gestureStateWaitFingersNumberChangeWithTimeout2 = new GestureStateWaitFingersNumberChangeWithTimeout(gestureContext, 100); + FSMStateRunRunnable fSMStateRunRunnable = new FSMStateRunRunnable(runnable); + GestureStatePressKey gestureStatePressKey = new GestureStatePressKey(gestureContext, KeyCodesX.KEY_SPACE); + GestureStatePressKey gestureStatePressKey2 = new GestureStatePressKey(gestureContext, KeyCodesX.KEY_RETURN); + GestureState1FingerMoveToMouseMove gestureState1FingerMoveToMouseMove = new GestureState1FingerMoveToMouseMove(gestureContext, pointerContext, new OffsetMouseMoveAdapter(new SimpleMouseMoveAdapter(gestureContext.getPointerReporter()), 0.0f * f, f * pointerOffsetAimInchesY)); + GestureState1FingerToLongClick gestureState1FingerToLongClick = new GestureState1FingerToLongClick(gestureContext, new MouseClickAdapterWithCheckPlacementContext(new SimpleMousePointAndClickAdapter(new SimpleMouseMoveAdapter(gestureContext.getPointerReporter()), new PressAndHoldMouseClickAdapter(gestureContext.getPointerReporter(), 3), pointerContext), new AlignedMouseClickAdapter(new SimpleMouseMoveAdapter(gestureContext.getPointerReporter()), new PressAndHoldMouseClickAdapter(gestureContext.getPointerReporter(), 3), new PressAndReleaseMouseClickAdapter(gestureContext.getPointerReporter(), 1, 50), viewOfXServer, pointerContext, f2), new SimpleMousePointAndClickAdapter(new SimpleMouseMoveAdapter(gestureContext.getPointerReporter()), new PressAndHoldMouseClickAdapter(gestureContext.getPointerReporter(), 3), pointerContext), pointerContext, 200)); + GestureState1FingerMoveToScrollSync gestureState1FingerMoveToScrollSync = new GestureState1FingerMoveToScrollSync(gestureContext, new ScrollAdapterControlArrow(gestureContext.getKeyboardReporter()), 0.015151516f * TransformationHelpers.getScaleX(viewOfXServer.getViewToXServerTransformationMatrix()), 0.015151516f * TransformationHelpers.getScaleY(viewOfXServer.getViewToXServerTransformationMatrix()), 0.0f, true, 50, scrollPeriodMs, false); + GestureState1FingerToZoomMove gestureState1FingerToZoomMove = new GestureState1FingerToZoomMove(gestureContext); + GestureState2FingersToZoom gestureState2FingersToZoom = new GestureState2FingersToZoom(gestureContext); + FiniteStateMachine finiteStateMachine = new FiniteStateMachine(); + finiteStateMachine.setStatesList(gestureStateNeutral, gestureState1FingerMeasureSpeed, gestureStateMouseWarpToFingerLastCoords, gestureStateClickToFingerFirstCoords, gestureStateCheckIfZoomed, gestureStateWaitFingersNumberChangeWithTimeout, gestureStateWaitFingersNumberChangeWithTimeout2, fSMStateRunRunnable, gestureStatePressKey, gestureStatePressKey2, gestureState1FingerMoveToMouseMove, gestureState1FingerToLongClick, gestureState1FingerMoveToScrollSync, gestureState1FingerToZoomMove, gestureState2FingersToZoom, gestureStateWaitForNeutral); + finiteStateMachine.addTransition(gestureStateWaitForNeutral, GestureStateWaitForNeutral.GESTURE_COMPLETED, gestureStateNeutral); + finiteStateMachine.addTransition(gestureStateNeutral, GestureStateNeutral.FINGER_TOUCHED, gestureState1FingerMeasureSpeed); + finiteStateMachine.addTransition(gestureState1FingerMeasureSpeed, GestureState1FingerMeasureSpeed.FINGER_STANDING, gestureState1FingerToLongClick); + finiteStateMachine.addTransition(gestureState1FingerMeasureSpeed, GestureState1FingerMeasureSpeed.FINGER_WALKED, gestureState1FingerMoveToMouseMove); + finiteStateMachine.addTransition(gestureState1FingerMeasureSpeed, GestureState1FingerMeasureSpeed.FINGER_FLASHED, gestureStateCheckIfZoomed); + finiteStateMachine.addTransition(gestureState1FingerMeasureSpeed, GestureState1FingerMeasureSpeed.FINGER_TOUCHED, gestureStateWaitFingersNumberChangeWithTimeout); + finiteStateMachine.addTransition(gestureState1FingerMeasureSpeed, GestureState1FingerMeasureSpeed.FINGER_TAPPED, gestureStateClickToFingerFirstCoords); + finiteStateMachine.addTransition(gestureState1FingerMeasureSpeed, GestureState1FingerMeasureSpeed.FINGER_WALKED_AND_GONE, gestureStateMouseWarpToFingerLastCoords); + finiteStateMachine.addTransition(gestureStateCheckIfZoomed, GestureStateCheckIfZoomed.ZOOM_OFF, gestureState1FingerMoveToScrollSync); + finiteStateMachine.addTransition(gestureStateCheckIfZoomed, GestureStateCheckIfZoomed.ZOOM_ON, gestureState1FingerToZoomMove); + finiteStateMachine.addTransition(gestureStateWaitFingersNumberChangeWithTimeout, GestureStateWaitFingersNumberChangeWithTimeout.FINGER_TOUCHED, gestureStateWaitFingersNumberChangeWithTimeout2); + finiteStateMachine.addTransition(gestureStateWaitFingersNumberChangeWithTimeout, GestureStateWaitFingersNumberChangeWithTimeout.FINGER_RELEASED, gestureStatePressKey2); + finiteStateMachine.addTransition(gestureStateWaitFingersNumberChangeWithTimeout, GestureStateWaitFingersNumberChangeWithTimeout.TIMED_OUT, gestureState2FingersToZoom); + finiteStateMachine.addTransition(gestureStateWaitFingersNumberChangeWithTimeout2, GestureStateWaitFingersNumberChangeWithTimeout.FINGER_RELEASED, gestureStatePressKey); + finiteStateMachine.addTransition(gestureStateWaitFingersNumberChangeWithTimeout2, GestureStateWaitFingersNumberChangeWithTimeout.TIMED_OUT, gestureStatePressKey); + finiteStateMachine.addTransition(gestureStateWaitFingersNumberChangeWithTimeout2, GestureStateWaitFingersNumberChangeWithTimeout.FINGER_TOUCHED, fSMStateRunRunnable); + finiteStateMachine.addTransition(gestureState2FingersToZoom, GestureState2FingersToZoom.FINGER_RELEASED, gestureState1FingerToZoomMove); + finiteStateMachine.addTransition(gestureState1FingerToZoomMove, GestureState1FingerToZoomMove.FINGER_TOUCHED, gestureState2FingersToZoom); + finiteStateMachine.setInitialState(gestureStateNeutral); + finiteStateMachine.setDefaultState(gestureStateWaitForNeutral); + finiteStateMachine.configurationCompleted(); + gestureContext.setMachine(finiteStateMachine); return gestureContext; } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/eltechs/axs/widgets/popupMenu/AXSPopupMenu.java b/app/src/main/java/com/eltechs/axs/widgets/popupMenu/AXSPopupMenu.java index c44b9da1..d8d507f7 100644 --- a/app/src/main/java/com/eltechs/axs/widgets/popupMenu/AXSPopupMenu.java +++ b/app/src/main/java/com/eltechs/axs/widgets/popupMenu/AXSPopupMenu.java @@ -9,6 +9,8 @@ import com.eltechs.axs.helpers.Assert; import com.eltechs.axs.widgets.actions.Action; import com.eltechs.axs.widgets.actions.ActionGroup; +import com.example.datainsert.exagear.action.AddPopupMenuItems; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -20,7 +22,7 @@ public class AXSPopupMenu { /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes.dex */ - public interface MenuItemWrapper { + private interface MenuItemWrapper { void addItemsToMenu(Menu menu, int i); } @@ -82,6 +84,10 @@ public void show() { menuItemWrapper.addItemsToMenu(menu, i); i++; } + + //大部分操作模式(除了自定义)都用的是这个类来显示弹窗菜单。那么在每次显示前都添加一个选项好了 +// AddPopupMenuItems.addBeforeShow(this); + this.impl.show(); } diff --git a/app/src/main/java/com/example/datainsert/exagear/FAB/dialogfragment/PulseAudio.java b/app/src/main/java/com/example/datainsert/exagear/FAB/dialogfragment/PulseAudio.java index 926803f8..f67a336c 100644 --- a/app/src/main/java/com/example/datainsert/exagear/FAB/dialogfragment/PulseAudio.java +++ b/app/src/main/java/com/example/datainsert/exagear/FAB/dialogfragment/PulseAudio.java @@ -1,5 +1,6 @@ package com.example.datainsert.exagear.FAB.dialogfragment; +import static com.example.datainsert.exagear.RR.dimen.margin8Dp; import static com.example.datainsert.exagear.RR.getS; import android.content.Context; @@ -38,8 +39,9 @@ import java.util.StringTokenizer; public class PulseAudio extends BaseFragment { - private final static File logFile = new File(Globals.getAppContext().getExternalFilesDir(""), "logs/palog.txt"); - private final static File paWorkDir = new File(Globals.getAppContext().getFilesDir(), "pulseaudio-xsdl"); + private final static File paWorkDir = new File(QH.Files.edPatchDir(), "pulseaudio-xsdl"); + private final static File logFile = new File(paWorkDir, "logs/palog.txt"); + /** * 是否在启动容器时启动pulse。默认为PREF_VAL_PULSE_AUTORUN(true) */ @@ -60,13 +62,14 @@ public class PulseAudio extends BaseFragment { private static final String TAG = "PulseAudio"; - public static void installAndRun() { - //启动pulseaudio (貌似多次启动会导致失效,要么就启动一次,要么就先停止再启动) + /** + * 启动pulseaudio (貌似多次启动会导致失效,要么就启动一次,要么就先停止再启动) + * @param isStart 停止还是运行 + */ + public static void installAndRun(boolean isStart) { //解压要求paDir不存在 if (paWorkDir.exists() && (!paWorkDir.isDirectory() || paWorkDir.list().length == 0) && !paWorkDir.delete()) return; - - //解压必要文件 ZipInstallerAssets.installIfNecessary(Globals.getAppContext(), new ZipInstallerAssets.InstallCallback() { @Override public void installationFailed(String str) { @@ -76,9 +79,7 @@ public void installationFailed(String str) { @Override public void installationFinished(String str) { - //设置pulseaudio路径并启动pulseaudio (即使不勾选启用,也要先调用这个执行停止,否则停不下来了) -// setEnv(paDir.getAbsolutePath()); - killAndStartPulseaudio(); + killAndStartPulseaudio(isStart);//设置pulseaudio路径并启动pulseaudio (即使不勾选启用,也要先调用这个执行停止,否则停不下来了) } }, paWorkDir, "pulseaudio-xsdl.zip"); @@ -87,8 +88,9 @@ public void installationFinished(String str) { /** * 确保so文件存在,新建java进程 停止pulse。 * 若勾选启用,则运行pulseaudio + * @param isStart 停止还是运行 */ - private static void killAndStartPulseaudio() { + private static void killAndStartPulseaudio(boolean isStart) { Log.d(TAG, "startPulseaudio: 停止pulseaudio"); try { @@ -128,10 +130,9 @@ else if(subFile.isDirectory() && subFile.getName().contains(".config")){ } //如果设置不开启pulse,直接返回 - if (!getPreference().getBoolean(PREF_KEY_PULSE_AUTORUN, PREF_DEF_VAL_PULSE_AUTORUN)) + if (!isStart) return; - // builder.command( // "./pulseaudio", // "--start", @@ -156,14 +157,6 @@ else if(subFile.isDirectory() && subFile.getName().contains(".config")){ builder.redirectOutput(ProcessBuilder.Redirect.appendTo(logFile)); } builder.start(); - - -// Runtime.getRuntime().exec( -// dir + "/pulseaudio --disable-shm -n -F " + dir + "/pulseaudio.conf --dl-search-path="+dir+" --daemonize=false --use-pid-file=false --log-target=stderr --log-level=debug", -// new String[]{"HOME=" + dir, "TMPDIR=" + dir, "LD_LIBRARY_PATH=" + dir}, -// paDir -// ); - } catch (IOException | InterruptedException e) { try (PrintWriter printWriter = new PrintWriter(logFile);) { e.printStackTrace(printWriter); @@ -180,14 +173,35 @@ protected ViewGroup buildUI() { Context c = requireContext(); LinearLayout linearRoot = new LinearLayout(c); linearRoot.setOrientation(LinearLayout.VERTICAL); - LinearLayout.LayoutParams paddingParams = new LinearLayout.LayoutParams(-2, -2); - paddingParams.topMargin = AndroidHelpers.dpToPx(20); + LinearLayout.LayoutParams paddingParams = new LinearLayout.LayoutParams(-1, -2); + paddingParams.topMargin = margin8Dp(); //顶端简介 TextView tvShortInfo = new TextView(c); tvShortInfo.setText(getS(RR.pa_explain)); linearRoot.addView(tvShortInfo, paddingParams); + //立即停止和开始 +// Button btnRunNow = new Button(c); +// btnRunNow.setText("Run Now"); +// btnRunNow.setOnClickListener(v->{ +// installAndRun(true); +// dismiss(); +// }); +// Button btnStopNow = new Button(c); +// btnStopNow.setText("stop now"); +// btnStopNow.setOnClickListener(v->{ +// installAndRun(false); +// dismiss(); +// }); +// LinearLayout linearRunOrStop = new LinearLayout(c); +// linearRunOrStop.setOrientation(LinearLayout.HORIZONTAL); +// LinearLayout.LayoutParams weightParams = new LinearLayout.LayoutParams(0,-2); +// weightParams.weight=1; +// linearRunOrStop.addView(btnRunNow,weightParams); +// linearRunOrStop.addView(btnStopNow,weightParams); +// linearRoot.addView(linearRunOrStop,paddingParams); + //是否启动pulse服务 String[] checkRunStr = getS(RR.pa_checkRun).split("\\$"); CheckBox checkAutorun = new CheckBox(c); @@ -259,13 +273,6 @@ protected ViewGroup buildUI() { String trShTxt1 = trShStrs[1]; String trShTxt2 = trShStrs[2]; - //Audio Seleted driver: pulseaudio Test Sound -// "检查PulseAudio服务是否正常工作:启动容器后打开winecfg,在音效栏中,“选中的驱动”显示winepulse.drv,点击“测试音频”按钮能听到声音。" + -// "\n\n若测试结果不正确,请检查以下几点:" + -// "\n1. elf正常运行:勾选输出日志,且日志中无报错," + -// "\n2. 环境变量导出:PULSE_SERVER=tcp:127.0.0.1:4713正常会被自动导出。也可用Exaterm或Putty手动确认。" + -// "\n3. 注册表项:打开regedit,[HKEY_CURENT_USER\\Software\\Wine\\Drivers] 不存在Audio项,若存在则其值应该有 pulse 。" - TextView tvTbSt = new TextView(c); tvTbSt.setLineSpacing(0, 1.2f); tvTbSt.setTextIsSelectable(true); @@ -317,6 +324,13 @@ private TextView getDescriptionTextView(String text) { return textView; } + /** + * 是否应该启动pulseaudio。从pref读取 + */ + public static boolean shouldStartByPref(){ + return QH.getPreference().getBoolean(PREF_KEY_PULSE_AUTORUN, PREF_DEF_VAL_PULSE_AUTORUN); + } + @Override public void callWhenFirstStart(AppCompatActivity activity) { diff --git a/app/src/main/java/com/example/datainsert/exagear/QH.java b/app/src/main/java/com/example/datainsert/exagear/QH.java index 3d919d60..de6e3720 100644 --- a/app/src/main/java/com/example/datainsert/exagear/QH.java +++ b/app/src/main/java/com/example/datainsert/exagear/QH.java @@ -35,7 +35,6 @@ import android.widget.CompoundButton; import android.widget.EditText; import android.widget.LinearLayout; -import android.widget.ScrollView; import android.widget.TextView; import com.eltechs.axs.Globals; @@ -293,15 +292,13 @@ private static View.OnClickListener getInfoShowClickListener(String info) { return v -> new AlertDialog.Builder(v.getContext()).setMessage(info).setPositiveButton(android.R.string.yes, null).show(); } - public static Object getFieldReflectInst(Class clz, Object clzInst, String fieldName, boolean isHide) { + public static Object reflectPrivateMember(Class clz, Object clzInst, String fieldName) { Object fieldInst = null; try { Field field = clz.getDeclaredField(fieldName); - if (isHide) - field.setAccessible(true); + field.setAccessible(true); fieldInst = field.get(clzInst); - if (isHide) - field.setAccessible(false); + field.setAccessible(false); } catch (Throwable throwable) { throwable.printStackTrace(); } diff --git a/app/src/main/java/com/example/datainsert/exagear/action/AddEnvironmentVariables.java b/app/src/main/java/com/example/datainsert/exagear/action/AddEnvironmentVariables.java index 2b01e392..becf5147 100644 --- a/app/src/main/java/com/example/datainsert/exagear/action/AddEnvironmentVariables.java +++ b/app/src/main/java/com/example/datainsert/exagear/action/AddEnvironmentVariables.java @@ -165,7 +165,7 @@ private void setOtherArgv(UBTLaunchConfiguration ubtConfig, long contId, File xd //插入参数 Arguments.allFromPoolFile((int) contId); - wineCmd = ConSetOtherArgv.insertArgsToWineCmd(wineCmd,ubtConfig.getGuestEnvironmentVariables(), (int) contId); + wineCmd = ConSetOtherArgv.insertArgsToWineCmd(wineCmd, ubtConfig.getGuestEnvironmentVariables(), (int) contId); //添加实时输入 if (QH.isTesting()) { @@ -223,7 +223,7 @@ private void addDrives(SharedPreferences sp, UBTLaunchConfiguration ubtConfig, l } private void startPulseAudio(UBTLaunchConfiguration ubtConfig) { - PulseAudio.installAndRun(); + PulseAudio.installAndRun(PulseAudio.shouldStartByPref()); ubtConfig.addEnvironmentVariable("PULSE_SERVER", "tcp:127.0.0.1:4713"); } diff --git a/app/src/main/java/com/example/datainsert/exagear/action/AddPopupMenuItems.java b/app/src/main/java/com/example/datainsert/exagear/action/AddPopupMenuItems.java new file mode 100644 index 00000000..8aa8a359 --- /dev/null +++ b/app/src/main/java/com/example/datainsert/exagear/action/AddPopupMenuItems.java @@ -0,0 +1,23 @@ +package com.example.datainsert.exagear.action; + +import android.widget.PopupMenu; + +import com.eltechs.axs.widgets.popupMenu.AXSPopupMenu; +import com.example.datainsert.exagear.FAB.dialogfragment.PulseAudio; +import com.example.datainsert.exagear.QH; + +/** + * 为启动容器后,多指点击弹出的弹窗菜单添加一些选项 + */ +public class AddPopupMenuItems { + /** + * 为启动容器后,多指点击弹出的弹窗菜单添加一些选项 + */ + public static void addBeforeShow(AXSPopupMenu axsPopupMenu){ + PopupMenu popupMenu = (PopupMenu) QH.reflectPrivateMember(AXSPopupMenu.class,axsPopupMenu,"impl"); + popupMenu.getMenu().add("pulseaudio").setOnMenuItemClickListener(item->{ + new PulseAudio().show(QH.getCurrentActivity().getSupportFragmentManager(),"pulseaudio"); + return true; + }); + } +} diff --git a/app/src/main/java/com/winlator/readme.md b/app/src/main/java/com/winlator/readme.md index 2e585b44..a7a5b8e3 100644 --- a/app/src/main/java/com/winlator/readme.md +++ b/app/src/main/java/com/winlator/readme.md @@ -1,5 +1,75 @@ [TOC] +# xserver左侧抽屉栏添加额外内容 +进入容器后,按手机返回键,可显示左侧抽屉栏。在里面添加一些额外功能。 +1. 下载smali压缩包并添加。 +## ~~pulseaudio~~,旋转屏幕 +1. 编辑smali。com.winlator.XServerDisplayActivity类,onCreate方法, 搜索字符串 setupUI 定位,在下一行添加。用于在侧栏显示更多选项。 + ``` + invoke-static {p0}, Lcom/example/datainsert/winlator/all/XserverNavMenuControl;->addItems(Lcom/winlator/XServerDisplayActivity;)V + ``` +~~2. 向apk/assets中添加pulseaudio-xsdl.tar.zst 链接: https://pan.baidu.com/s/17BKYH4OzsPSysewXlyxDAQ?pwd=c94e 提取码: c94e~~ +## 光标样式 +1. 编辑smali。com.winlator.XServerDisplayActivity类,showInputControlsDialog方法末尾,ContentDialog.show()之前,添加一行。用于修改光标样式。 + ``` + #添加这一行 + invoke-static {p0, v0}, Lcom/example/datainsert/winlator/all/XserverNavMenuControl;->addInputControlsItems(Lcom/winlator/XServerDisplayActivity;Lcom/winlator/widget/ContentDialog;)V + + invoke-virtual {v0}, Lcom/winlator/widget/ContentDialog;->show()V + ``` +2. WindowAttributes类,getCursor方法,整个替换 + ``` + .method public getCursor()Lcom/winlator/xserver/Cursor; + .registers 2 + + .line 104 + sget-boolean v0, Lcom/example/datainsert/winlator/all/XserverNavMenuControl;->isGameStyleCursor:Z + + if-nez v0, :cond_7 + + .line 105 + iget-object v0, p0, Lcom/winlator/xserver/WindowAttributes;->cursor:Lcom/winlator/xserver/Cursor; + + return-object v0 + + .line 108 + :cond_7 + iget-object v0, p0, Lcom/winlator/xserver/WindowAttributes;->cursor:Lcom/winlator/xserver/Cursor; + + if-nez v0, :cond_20 + + iget-object v0, p0, Lcom/winlator/xserver/WindowAttributes;->window:Lcom/winlator/xserver/Window; + + invoke-virtual {v0}, Lcom/winlator/xserver/Window;->getParent()Lcom/winlator/xserver/Window; + + move-result-object v0 + + if-eqz v0, :cond_20 + + .line 109 + iget-object v0, p0, Lcom/winlator/xserver/WindowAttributes;->window:Lcom/winlator/xserver/Window; + + invoke-virtual {v0}, Lcom/winlator/xserver/Window;->getParent()Lcom/winlator/xserver/Window; + + move-result-object v0 + + iget-object v0, v0, Lcom/winlator/xserver/Window;->attributes:Lcom/winlator/xserver/WindowAttributes; + + invoke-virtual {v0}, Lcom/winlator/xserver/WindowAttributes;->getCursor()Lcom/winlator/xserver/Cursor; + + move-result-object v0 + + return-object v0 + + .line 110 + :cond_20 + iget-object v0, p0, Lcom/winlator/xserver/WindowAttributes;->cursor:Lcom/winlator/xserver/Cursor; + + return-object v0 + .end method + ``` + + # 自定义wine修复 1. XServerDisplayActivity类,setupXEnvironment函数中,从上往下找到“WINEDEBUG"附近,然后按照下方提示修改。从`#开始修改`开始。该改动用于跳过未初始化的wininfo,container等成员变量的读取 ```smali diff --git a/patchapp/src/main/java/com/ewt45/patchapp/thread/FuncAddEnvs.java b/patchapp/src/main/java/com/ewt45/patchapp/thread/FuncAddEnvs.java index 017b905b..8d9e50c1 100644 --- a/patchapp/src/main/java/com/ewt45/patchapp/thread/FuncAddEnvs.java +++ b/patchapp/src/main/java/com/ewt45/patchapp/thread/FuncAddEnvs.java @@ -38,7 +38,8 @@ public Void call() throws Exception { //复制自己的类 PatcherFile.copy(PatcherFile.TYPE_SMALI, new String[]{ - "/com/example/datainsert/exagear/action", + "/com/example/datainsert/exagear/action/addenv", + "/com/example/datainsert/exagear/action/AddEnvironmentVariables.smali", "/com/example/datainsert/exagear/RR.smali", "/com/example/datainsert/exagear/QH.smali", }); diff --git a/patchapp/src/main/java/com/ewt45/patchapp/thread/FuncFAB.java b/patchapp/src/main/java/com/ewt45/patchapp/thread/FuncFAB.java index fb2f50da..47b8395a 100644 --- a/patchapp/src/main/java/com/ewt45/patchapp/thread/FuncFAB.java +++ b/patchapp/src/main/java/com/ewt45/patchapp/thread/FuncFAB.java @@ -318,6 +318,10 @@ public void updateSelfPackage() throws Exception { //用到的xsdl的so库 PatcherFile.copy(PatcherFile.TYPE_ASSETS, new String[]{"/pulseaudio-xsdl.zip"}); +// PatcherFile.copy(TYPE_SMALI, new String[]{ +// "/com/example/datainsert/exagear/action/AddPopupMenuItems.smali", +// "/com/eltechs/axs/widgets/popupMenu/AXSPopupMenu.smali"}); + } }