From 4f5243c245c96aac44bbe147c61a4ea5612338f9 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Fri, 2 Oct 2026 05:30:01 +0300 Subject: [PATCH] feat: Add force disable touch controls setting for convertible laptops fixes #62 --- src/defaultOptions.ts | 2 ++ src/optionsGuiScheme.tsx | 5 +++++ src/watchOptions.ts | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/defaultOptions.ts b/src/defaultOptions.ts index 0f72a1b94..a25cae671 100644 --- a/src/defaultOptions.ts +++ b/src/defaultOptions.ts @@ -73,6 +73,8 @@ export const defaultOptions = { singleplayerAutoSave: false, alwaysBackupWorldBeforeLoading: undefined as boolean | undefined | null, alwaysShowMobileControls: false, + /** Never enable touch controls, even if the device reports a touchscreen (e.g. laptops with mouse & keyboard). */ + forceDisableTouchControls: false, /** Portrait viewport: apply `body.rotated` landscape layout without tapping the rotate button. */ autoDisplayRotation: false, excludeCommunicationDebugEvents: [] as string[], diff --git a/src/optionsGuiScheme.tsx b/src/optionsGuiScheme.tsx index 635555df7..040d9a338 100644 --- a/src/optionsGuiScheme.tsx +++ b/src/optionsGuiScheme.tsx @@ -453,6 +453,11 @@ export const guiOptionsScheme: { }, alwaysShowMobileControls: { text: 'Always Mobile Controls', + disableIf: ['forceDisableTouchControls', true], + }, + forceDisableTouchControls: { + text: 'Force Disable Touch Controls', + tooltip: 'Never show touch controls, even if your device has a touchscreen. Useful for touch laptops used with mouse and keyboard.', }, autoDisplayRotation: { text: 'Auto Landscape Rotation', diff --git a/src/watchOptions.ts b/src/watchOptions.ts index 937f50c27..022fadd45 100644 --- a/src/watchOptions.ts +++ b/src/watchOptions.ts @@ -23,7 +23,7 @@ watchValue(options, o => { // gui scale is set in scaleInterface.ts }) const updateTouch = (o) => { - miscUiState.currentTouch = o.alwaysShowMobileControls || isMobile() + miscUiState.currentTouch = !o.forceDisableTouchControls && (o.alwaysShowMobileControls || isMobile()) } watchValue(options, updateTouch) window.matchMedia('(pointer: coarse)').addEventListener('change', (e) => {