Skip to content

Commit

Permalink
inputcontrols: add "SimulateTouchScreen" option to InputControls
Browse files Browse the repository at this point in the history
  • Loading branch information
longjunyu2 committed Aug 10, 2024
1 parent 02c7a36 commit 392bba9
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/com/winlator/XServerDisplayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ private void setupUI() {
ControlsProfile profile = inputControlsManager.getProfile(Integer.parseInt(controlsProfile));
if (profile != null) showInputControls(profile);
}

String simTouchScreen = shortcut.getExtra("simTouchScreen");
touchpadView.setSimTouchScreen(simTouchScreen.equals("1"));
}

AppUtils.observeSoftKeyboardVisibility(drawerLayout, renderer::setScreenOffsetYRelativeToCursor);
Expand Down Expand Up @@ -550,6 +553,9 @@ private void showInputControlsDialog() {
final CheckBox cbRelativeMouseMovement = dialog.findViewById(R.id.CBRelativeMouseMovement);
cbRelativeMouseMovement.setChecked(xServer.isRelativeMouseMovement());

final CheckBox cbSimTouchScreen = dialog.findViewById(R.id.CBSimulateTouchScreen);
cbSimTouchScreen.setChecked(touchpadView.isSimTouchScreen());

final CheckBox cbShowTouchscreenControls = dialog.findViewById(R.id.CBShowTouchscreenControls);
cbShowTouchscreenControls.setChecked(inputControlsView.isShowTouchscreenControls());

Expand All @@ -574,6 +580,7 @@ private void showInputControlsDialog() {
showInputControls(inputControlsManager.getProfiles().get(position - 1));
}
else hideInputControls();
touchpadView.setSimTouchScreen(cbSimTouchScreen.isChecked());
});

dialog.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ private void createContentView() {
final Spinner sDInputMapperType = findViewById(R.id.SDInputMapperType);
sDInputMapperType.setSelection(Byte.parseByte(shortcut.getExtra("dinputMapperType", String.valueOf(WinHandler.DINPUT_MAPPER_TYPE_XINPUT))));

final CheckBox cbSimulateTouchScreen = findViewById(R.id.CBSimulateTouchScreen);
cbSimulateTouchScreen.setChecked(shortcut.getExtra("simTouchScreen", "0").equals("1"));

ContainerDetailFragment.createWinComponentsTab(getContentView(), shortcut.getExtra("wincomponents", shortcut.container.getWinComponents()));
final EnvVarsView envVarsView = createEnvVarsTab();

Expand Down Expand Up @@ -149,6 +152,7 @@ private void createContentView() {
int controlsProfile = sControlsProfile.getSelectedItemPosition() > 0 ? profiles.get(sControlsProfile.getSelectedItemPosition()-1).id : 0;
shortcut.putExtra("controlsProfile", controlsProfile > 0 ? String.valueOf(controlsProfile) : null);
shortcut.putExtra("dinputMapperType", dinputMapperType != WinHandler.DINPUT_MAPPER_TYPE_XINPUT ? String.valueOf(dinputMapperType) : null);
shortcut.putExtra("simTouchScreen", cbSimulateTouchScreen.isChecked() ? "1" : "0");
shortcut.saveData();
}
});
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/winlator/widget/TouchpadView.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class TouchpadView extends View {
private final XServer xServer;
private Runnable fourFingersTapCallback;
private final float[] xform = XForm.getInstance();
private boolean simTouchScreen = false;

public TouchpadView(Context context, XServer xServer) {
super(context);
Expand Down Expand Up @@ -369,4 +370,12 @@ private StateListDrawable createTransparentBg() {

return stateListDrawable;
}

public void setSimTouchScreen(boolean simTouchScreen) {
this.simTouchScreen = simTouchScreen;
}

public boolean isSimTouchScreen() {
return simTouchScreen;
}
}
6 changes: 6 additions & 0 deletions app/src/main/res/layout/input_controls_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/relative_mouse_movement" />

<CheckBox
android:id="@+id/CBSimulateTouchScreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/simulate_touch_screen" />
</LinearLayout>
6 changes: 6 additions & 0 deletions app/src/main/res/layout/shortcut_settings_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@
android:id="@+id/SDInputMapperType"
android:layout_width="match_parent"
android:entries="@array/dinput_mapper_type_entries" />

<CheckBox
android:id="@+id/CBSimulateTouchScreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/simulate_touch_screen" />
</LinearLayout>

<TextView
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,5 @@
<string name="do_you_want_to_restore_default_profile">你想要恢复默认配置文件吗?</string>
<string name="box86_64_rc_files">RC 文件</string>
<string name="letter">盘符</string>
<string name="simulate_touch_screen">模拟触摸屏</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,5 @@
<string name="cannot_edit_default_profile">Cannot edit default profile.</string>
<string name="do_you_want_to_restore_default_profile">Do you want to restore default profile?</string>
<string name="box86_64_rc_files">RC File</string>
<string name="simulate_touch_screen">Simulate touch screen</string>
</resources>

0 comments on commit 392bba9

Please sign in to comment.