Touch controls (#2053)

* WIP touch controls

* Action icons

* Updates

* Don't mutate freeCamera config; allow switching between touch and controller cam

* Wow

* Fix build & add Skip button

* Fix build & add settings

* RCSS cleanup

* Dpad and fishing, might redo

* Add menu mouse controls

* More pointer & fix icons

* Optimizations & introduce layout system

* Update aurora

* Implement touch controls layout editor

* Cleanup & fixes

* Allow disabling mouse/touch in menus

* More fixes
This commit is contained in:
Luke Street
2026-06-15 12:48:04 -06:00
committed by GitHub
parent a6e5160c71
commit ad53af5c78
66 changed files with 6372 additions and 136 deletions
+39
View File
@@ -22,6 +22,7 @@
#include "menu_bar.hpp"
#include "pane.hpp"
#include "prelaunch.hpp"
#include "touch_controls_editor.hpp"
#include "ui.hpp"
#include <aurora/lib/window.hpp>
@@ -35,6 +36,17 @@
#include <algorithm>
#include <filesystem>
#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif
#if defined(TARGET_ANDROID) || defined(__ANDROID__) || \
(defined(__APPLE__) && TARGET_OS_IOS && !TARGET_OS_MACCATALYST)
#define TOUCH_CONTROLS_AVAILABLE true
#else
#define TOUCH_CONTROLS_AVAILABLE false
#endif
namespace dusk::ui {
namespace {
@@ -968,6 +980,31 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
.onChange = [](bool value) { aurora_set_background_input(value); },
});
#if TOUCH_CONTROLS_AVAILABLE
leftPane.add_section("Touch");
addOption("Touch Controls", getSettings().game.enableTouchControls,
"Enables controls overlay for touch screens.<br/><br/>Press and drag on the left side "
"of the screen to move, and on the right side of the screen to control the camera.");
auto& customizeTouchLayout = leftPane.add_button(ControlledButton::Props{
.text = "Customize Layout",
.isDisabled = [] { return !getSettings().game.enableTouchControls; },
});
leftPane.register_control(customizeTouchLayout.on_pressed(
[this] { push(std::make_unique<TouchControlsEditor>()); }),
rightPane, [](Pane& pane) {
pane.clear();
pane.add_text("Open the touch controls layout editor.");
});
config_percent_select(leftPane, rightPane, getSettings().game.touchCameraXSensitivity,
"Touch Camera X Sensitivity",
"Adjusts touch camera horizontal sensitivity.<br/><br/>Applies to touch input only.",
25, 400, 5, [] { return !getSettings().game.enableTouchControls; });
config_percent_select(leftPane, rightPane, getSettings().game.touchCameraYSensitivity,
"Touch Camera Y Sensitivity",
"Adjusts touch camera vertical sensitivity.<br/><br/>Applies to touch input only.", 25,
400, 5, [] { return !getSettings().game.enableTouchControls; });
#endif
leftPane.add_section("Camera");
addOption("Free Camera", getSettings().game.freeCamera,
"Enables free camera control, letting you control the camera fully with the C-Stick.");
@@ -1035,6 +1072,8 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
[] { return !getSettings().game.enableMouseAim || !getSettings().game.enableMouseCamera; });
leftPane.add_section("Gameplay");
addOption("Mouse/Touch in Menus", getSettings().game.enableMenuPointer,
"Enables mouse and touch input for supported in-game menus.");
addOption("Invert Air/Swim X Axis", getSettings().game.invertAirSwimX,
"Invert horizontal movement while flying or swimming.");
addOption("Invert Air/Swim Y Axis", getSettings().game.invertAirSwimY,