Skip to content

Touch controls: a touch that misses the controls is no mouse while a controller layout is shown - #150

Merged
willfaust merged 1 commit into
willfaust:mainfrom
meshoklv:pr/touch-no-mouse-with-pad-overlay
Oct 6, 2026
Merged

willfaust merged 1 commit into
willfaust:mainfrom
meshoklv:pr/touch-no-mouse-with-pad-overlay

Conversation

@meshoklv

@meshoklv meshoklv commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A touch on the game view that lands outside every on-screen control goes to the program as mouse input (post_touch_down). With Dark Souls Remastered and the built-in Xbox touch layout, stray touches beside the touch buttons reached the game as mouse events while the touch controller was in use. Some games switch to keyboard and mouse input on mouse events and then ignore the controller.

Fix

TouchMouseGate in ContentView.swift: while the landscape overlay is visible, not editing, and has at least one controller (pad) mapping, direct touches on MetalBackedView are not handled as a mouse. configureGamepad already computes this condition for touch XInput.

  • A touch that began while suppressed stays swallowed until it lifts or is cancelled, so a layout change in between never leaves a button held.
  • Not affected: touch used as a trackpad (Input settings), a hardware mouse or trackpad, and the on-screen controls themselves.
  • [touch-mouse] mode=... is logged once.

docs/CONTROLLERS.md gets a paragraph, and the settings catalog gets the new key.

Switch

env.MADEIRA_TOUCH_MOUSE: 1 always sends such touches (the previous behaviour), 0 never does, unset means the default above.

Testing

  • Verified on iPhone Air, iOS 27.2, with Dark Souls Remastered on a build based on d5a8e0a. Not rebuilt on current main.
  • The device build also had the foreground-window change (win32u iOS: make a process's main window foreground while it polls XInput #149). I did not isolate whether either change alone is sufficient.
  • One difference from the tested version: the trackpad-mode exemption is new here. The tested build suppressed in trackpad mode too, but that mode was not in use.
  • On this branch, all 53 Swift files of app/Madeira type-check together on macOS: swiftc -typecheck for arm64-apple-ios17.0 with the bridging header passes with no errors. The Xcode project was not built.
  • The catalog row was produced by running the generator over this repository only; the full --check (which also scans the submodules) was not run.

Details: #56, this comment, item 4.

AI assistance: prepared with Claude under the owner's direction (Co-Authored-By trailer). Signed off (DCO) by meshoklv.

🤖 Generated with Claude Code

…controller layout is shown

A touch on the game view that lands outside every on-screen control
reaches the program as a mouse. Some games switch to keyboard and mouse
input on any mouse event and then ignore the controller; with Dark Souls
Remastered, stray touches beside the touch buttons went to the game as
mouse input while the touch controller was in use.

While the landscape overlay shows at least one controller mapping, such
direct touches are no longer sent. A touch that began while suppressed
stays swallowed until it lifts, so a layout change in between never
leaves a button held. Touch used as a trackpad and a hardware mouse or
trackpad are not affected. MADEIRA_TOUCH_MOUSE=1 always sends them, as
before; 0 never does.

Signed-off-by: meshoklv <119141917+meshoklv@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@willfaust
willfaust merged commit 4c83d16 into willfaust:main Oct 6, 2026
willfaust added a commit that referenced this pull request Oct 6, 2026
Controller fixes for games that ship their own XInput or need focus, touch
taps that stay off the mouse, and a crash-guard fix (#148-#150 and
willfaust/wine#18-#19).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
willfaust pushed a commit that referenced this pull request Oct 14, 2026
…the gate

While a touch controller layout is shown, the touch-mouse gate (#150) drops
the touches that miss the controls, so they do not move the mouse. In a
Madeira Dock session the desktop's windows are used with the pointer: with
the Xbox layout shown, every tap on GTA V Enhanced's window was dropped when
it started through the Rockstar Games Launcher, so the window never got the
click that would also have brought it to the front (fork build 433,
2026-10-07 19:27). In auto mode a desktop session now keeps touches as the
mouse. The gate also reads env.MADEIRA_TOUCH_MOUSE from the game's own lines
first, so a game's line applies (the Red Dead Redemption 2 and GTA V
Enhanced lists set 1).

On by default for desktop sessions; env.MADEIRA_TOUCH_MOUSE = 1 or 0 still
forces either behaviour for every session.

This is the app half of the fullscreen-foreground topic, whose win32u half
gives a full-screen window shown with activation the foreground (the same
GTA V Enhanced run).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0189oLHghpaYKLk4f786a6bc
Signed-off-by: bahacan16 <190844990+bahacan16@users.noreply.github.com>
willfaust pushed a commit that referenced this pull request Oct 14, 2026
…d while none is in front (#293)

iOS has no window manager, and Windows' foreground lock kept GTA V Enhanced (started by its launcher) and Horizon Zero Dawn out of the foreground, so they got no input. The full-screen rule is on by default; the main-window rule is opt-in (Horizon Zero Dawn's list sets it). The app's touch gate change rides along.

---

**win32u iOS: a full-screen window shown with activation gets the foreground**

iOS has no window manager, and the wineserver keeps Windows' foreground
lock: a process that has had neither input nor the foreground may not
take it from another process unless its parent holds it. GTA V Enhanced,
started by Launcher.exe in a Madeira Dock session (madeira-bcd build
433, log 2026-10-07 19:27), asked four times to activate its 1920x1080
window after the launcher's windows had held the foreground, and sat at
its first screen with no keyboard, mouse or pad; started on its own it
played with a pad on the same build.

A window manager gives a newly shown full-screen window the activation
it asks for, so now a visible top-level window covering the whole
virtual screen, shown without SWP_NOACTIVATE, is made foreground by its
own thread at its next message poll, unless a window of its process
already is; once per show; smaller windows (launchers, dialogs) are left
to the lock, and a hidden window never takes the foreground. On by
default; MADEIRA_FULLSCREEN_FOREGROUND=0 turns it off. [fg-show] and
[winios-tree] lines log it.

Same pull request as input-foreground (its foreground-when-none call
sits in this change's poll hook). Will rebuilds libwin32u_unix.a.

---

**win32u iOS: opt-in foreground for a main window while nothing is in front**

Horizon Zero Dawn (madeira-bcd build 471, 2026-10-09 15:01) showed its
window through style changes and SetWindowPos with SWP_NOACTIVATE only,
and reads no XInput (it uses Windows.Gaming.Input), so neither the
full-screen rule nor the XInput foreground check made it foreground:
GetForegroundWindow() stayed NULL. The wineserver queues WM_INPUT only
for the foreground process and sends keys to the foreground thread's
focus, so its language menu got none of the Enter presses or taps.

With env.MADEIRA_INPUT_FOREGROUND = 1, while no window at all is
foreground, a wine thread polling its messages or posting injected input
makes its process's main window (the largest visible top-level window of
320x200 or more) foreground, at most every 250 ms; never while some
window is foreground, so it cannot take the foreground from another
process. [fg-none] logs the first 16. Off by default; the Horizon Zero
Dawn list sets it.

docs/CONTROLLERS.md describes it, and MADEIRA_WGI_HOST_PADS: XInput pads
as Windows.Gaming.Input gamepads, which is willfaust/wine
pr/wine-wgi-host-pads of this wave (Will rebuilds
windows.gaming.input.dll with build/wine-pe/build-modules.sh).
tests/host/check-input-foreground.py checks the rule. Same pull request
as fullscreen-foreground. Will rebuilds libwin32u_unix.a.

---

**Touch: a Dock desktop keeps touches as the mouse; a game's line sets the gate**

While a touch controller layout is shown, the touch-mouse gate (#150) drops
the touches that miss the controls, so they do not move the mouse. In a
Madeira Dock session the desktop's windows are used with the pointer: with
the Xbox layout shown, every tap on GTA V Enhanced's window was dropped when
it started through the Rockstar Games Launcher, so the window never got the
click that would also have brought it to the front (fork build 433,
2026-10-07 19:27). In auto mode a desktop session now keeps touches as the
mouse. The gate also reads env.MADEIRA_TOUCH_MOUSE from the game's own lines
first, so a game's line applies (the Red Dead Redemption 2 and GTA V
Enhanced lists set 1).

On by default for desktop sessions; env.MADEIRA_TOUCH_MOUSE = 1 or 0 still
forces either behaviour for every session.

This is the app half of the fullscreen-foreground topic, whose win32u half
gives a full-screen window shown with activation the foreground (the same
GTA V Enhanced run).

Squashed from #293.

Signed-off-by: bahacan16 <190844990+bahacan16@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iediot pushed a commit to iediot/Madeira that referenced this pull request Oct 18, 2026
…d while none is in front (willfaust#293)

iOS has no window manager, and Windows' foreground lock kept GTA V Enhanced (started by its launcher) and Horizon Zero Dawn out of the foreground, so they got no input. The full-screen rule is on by default; the main-window rule is opt-in (Horizon Zero Dawn's list sets it). The app's touch gate change rides along.

---

**win32u iOS: a full-screen window shown with activation gets the foreground**

iOS has no window manager, and the wineserver keeps Windows' foreground
lock: a process that has had neither input nor the foreground may not
take it from another process unless its parent holds it. GTA V Enhanced,
started by Launcher.exe in a Madeira Dock session (madeira-bcd build
433, log 2026-10-07 19:27), asked four times to activate its 1920x1080
window after the launcher's windows had held the foreground, and sat at
its first screen with no keyboard, mouse or pad; started on its own it
played with a pad on the same build.

A window manager gives a newly shown full-screen window the activation
it asks for, so now a visible top-level window covering the whole
virtual screen, shown without SWP_NOACTIVATE, is made foreground by its
own thread at its next message poll, unless a window of its process
already is; once per show; smaller windows (launchers, dialogs) are left
to the lock, and a hidden window never takes the foreground. On by
default; MADEIRA_FULLSCREEN_FOREGROUND=0 turns it off. [fg-show] and
[winios-tree] lines log it.

Same pull request as input-foreground (its foreground-when-none call
sits in this change's poll hook). Will rebuilds libwin32u_unix.a.

---

**win32u iOS: opt-in foreground for a main window while nothing is in front**

Horizon Zero Dawn (madeira-bcd build 471, 2026-10-09 15:01) showed its
window through style changes and SetWindowPos with SWP_NOACTIVATE only,
and reads no XInput (it uses Windows.Gaming.Input), so neither the
full-screen rule nor the XInput foreground check made it foreground:
GetForegroundWindow() stayed NULL. The wineserver queues WM_INPUT only
for the foreground process and sends keys to the foreground thread's
focus, so its language menu got none of the Enter presses or taps.

With env.MADEIRA_INPUT_FOREGROUND = 1, while no window at all is
foreground, a wine thread polling its messages or posting injected input
makes its process's main window (the largest visible top-level window of
320x200 or more) foreground, at most every 250 ms; never while some
window is foreground, so it cannot take the foreground from another
process. [fg-none] logs the first 16. Off by default; the Horizon Zero
Dawn list sets it.

docs/CONTROLLERS.md describes it, and MADEIRA_WGI_HOST_PADS: XInput pads
as Windows.Gaming.Input gamepads, which is willfaust/wine
pr/wine-wgi-host-pads of this wave (Will rebuilds
windows.gaming.input.dll with build/wine-pe/build-modules.sh).
tests/host/check-input-foreground.py checks the rule. Same pull request
as fullscreen-foreground. Will rebuilds libwin32u_unix.a.

---

**Touch: a Dock desktop keeps touches as the mouse; a game's line sets the gate**

While a touch controller layout is shown, the touch-mouse gate (willfaust#150) drops
the touches that miss the controls, so they do not move the mouse. In a
Madeira Dock session the desktop's windows are used with the pointer: with
the Xbox layout shown, every tap on GTA V Enhanced's window was dropped when
it started through the Rockstar Games Launcher, so the window never got the
click that would also have brought it to the front (fork build 433,
2026-10-07 19:27). In auto mode a desktop session now keeps touches as the
mouse. The gate also reads env.MADEIRA_TOUCH_MOUSE from the game's own lines
first, so a game's line applies (the Red Dead Redemption 2 and GTA V
Enhanced lists set 1).

On by default for desktop sessions; env.MADEIRA_TOUCH_MOUSE = 1 or 0 still
forces either behaviour for every session.

This is the app half of the fullscreen-foreground topic, whose win32u half
gives a full-screen window shown with activation the foreground (the same
GTA V Enhanced run).

Squashed from willfaust#293.

Signed-off-by: bahacan16 <190844990+bahacan16@users.noreply.github.com>
icey9527 pushed a commit to icey9527/Madeira-15.6 that referenced this pull request Oct 26, 2026
…d while none is in front (willfaust#293)

iOS has no window manager, and Windows' foreground lock kept GTA V Enhanced (started by its launcher) and Horizon Zero Dawn out of the foreground, so they got no input. The full-screen rule is on by default; the main-window rule is opt-in (Horizon Zero Dawn's list sets it). The app's touch gate change rides along.

---

**win32u iOS: a full-screen window shown with activation gets the foreground**

iOS has no window manager, and the wineserver keeps Windows' foreground
lock: a process that has had neither input nor the foreground may not
take it from another process unless its parent holds it. GTA V Enhanced,
started by Launcher.exe in a Madeira Dock session (madeira-bcd build
433, log 2026-10-07 19:27), asked four times to activate its 1920x1080
window after the launcher's windows had held the foreground, and sat at
its first screen with no keyboard, mouse or pad; started on its own it
played with a pad on the same build.

A window manager gives a newly shown full-screen window the activation
it asks for, so now a visible top-level window covering the whole
virtual screen, shown without SWP_NOACTIVATE, is made foreground by its
own thread at its next message poll, unless a window of its process
already is; once per show; smaller windows (launchers, dialogs) are left
to the lock, and a hidden window never takes the foreground. On by
default; MADEIRA_FULLSCREEN_FOREGROUND=0 turns it off. [fg-show] and
[winios-tree] lines log it.

Same pull request as input-foreground (its foreground-when-none call
sits in this change's poll hook). Will rebuilds libwin32u_unix.a.

---

**win32u iOS: opt-in foreground for a main window while nothing is in front**

Horizon Zero Dawn (madeira-bcd build 471, 2026-10-09 15:01) showed its
window through style changes and SetWindowPos with SWP_NOACTIVATE only,
and reads no XInput (it uses Windows.Gaming.Input), so neither the
full-screen rule nor the XInput foreground check made it foreground:
GetForegroundWindow() stayed NULL. The wineserver queues WM_INPUT only
for the foreground process and sends keys to the foreground thread's
focus, so its language menu got none of the Enter presses or taps.

With env.MADEIRA_INPUT_FOREGROUND = 1, while no window at all is
foreground, a wine thread polling its messages or posting injected input
makes its process's main window (the largest visible top-level window of
320x200 or more) foreground, at most every 250 ms; never while some
window is foreground, so it cannot take the foreground from another
process. [fg-none] logs the first 16. Off by default; the Horizon Zero
Dawn list sets it.

docs/CONTROLLERS.md describes it, and MADEIRA_WGI_HOST_PADS: XInput pads
as Windows.Gaming.Input gamepads, which is willfaust/wine
pr/wine-wgi-host-pads of this wave (Will rebuilds
windows.gaming.input.dll with build/wine-pe/build-modules.sh).
tests/host/check-input-foreground.py checks the rule. Same pull request
as fullscreen-foreground. Will rebuilds libwin32u_unix.a.

---

**Touch: a Dock desktop keeps touches as the mouse; a game's line sets the gate**

While a touch controller layout is shown, the touch-mouse gate (willfaust#150) drops
the touches that miss the controls, so they do not move the mouse. In a
Madeira Dock session the desktop's windows are used with the pointer: with
the Xbox layout shown, every tap on GTA V Enhanced's window was dropped when
it started through the Rockstar Games Launcher, so the window never got the
click that would also have brought it to the front (fork build 433,
2026-10-07 19:27). In auto mode a desktop session now keeps touches as the
mouse. The gate also reads env.MADEIRA_TOUCH_MOUSE from the game's own lines
first, so a game's line applies (the Red Dead Redemption 2 and GTA V
Enhanced lists set 1).

On by default for desktop sessions; env.MADEIRA_TOUCH_MOUSE = 1 or 0 still
forces either behaviour for every session.

This is the app half of the fullscreen-foreground topic, whose win32u half
gives a full-screen window shown with activation the foreground (the same
GTA V Enhanced run).

Squashed from willfaust#293.

Signed-off-by: bahacan16 <190844990+bahacan16@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants