[PR #955] gameinput: pads plugged in after start under Wine, and IJKL on the keyboard pad's right stick (RT-GAMEINPUT-WINE-HOTPLUG) #993

Open
opened 2026-11-26 20:19:44 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/955
Author: @UwUCammie
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: pr/gameinput-wine-hotplug


📝 Commits (1)

  • 3f59ed6 gameinput: pads plugged in after start under Wine, and IJKL on the keyboard pad's right stick (RT-GAMEINPUT-WINE-HOTPLUG)

📊 Changes

2 files changed (+100 additions, -1 deletions)

View changed files

📝 docs/gameinput.md (+2 -0)
📝 runtime/shims/gameinput.cpp (+98 -1)

📄 Description

Claimed in the coordination issue as: RT-GAMEINPUT-WINE-HOTPLUG

What and why

Under Wine a controller plugged in after the game has started never reaches the title. SDL's Windows backends only rescan when Windows reports a device change: the XInput and DirectInput drivers through CM_Register_Notification, HIDAPI through WM_DEVICECHANGE on its message window. Wine delivers neither for a pad that arrives later. Measured on Wine 11.22: a run started with no pad never showed one after it was connected. A pad that is unplugged does go away, because its reads fail.

The poll thread now builds a small signature once a second, without touching SDL internals:

  • which XInput slots answer XInputGetCapabilities;
  • the HID devices in GetRawInputDeviceList with usage page 1 and usage joystick, gamepad or multi-axis.

Wine refreshes both lists itself. When the signature changes, SDL's gamepad subsystem is restarted (SDL_QuitSubSystem / SDL_InitSubSystem(SDL_INIT_GAMEPAD)), the one public way to make every backend scan again. Open pads are closed first through the normal close_pad path, so the title sees a disconnect and a reconnect, and only when the hardware changed. LEONIDA_GAMEINPUT_HOTPLUG=0 turns it off.

The keyboard pad also gets I/J/K/L as the right stick at full deflection, over the mouse. The retail title's legal terms screen scrolls each policy text on the right stick, and its checkboxes only count once a text has been scrolled to the end. Without a pad or a working mouse path (headless runs), that screen could not be passed. docs/gameinput.md lists both.

Tested

  • gameinput_test.exe on this branch (clang-cl + xwin cross build, run under Wine 11.22): 364 checks, 0 failures.
  • The same change on a local integration branch, retail 1.0.2.1 under Wine with an 8BitDo pad (XInput, 2dc8:301d). At start SDL listed the one pad three times (as an Xbox 360, an Xbox One S and an XInput controller). After the first signature change (Wine finishing its device list) the restart left exactly one pad plus the keyboard pad, and input kept working. With K held, the terms screen scrolled to the end of each text and its Confirm button enabled.
  • Not tested: physically plugging a pad in mid-run on this machine (I ran remotely). The restart path is the same one the first signature change exercised.

GPUs tested: n/a (input only; the machine is an AMD Radeon RX 7900 XT, RADV, Mesa 26.3.1, CachyOS, Wine 11.22)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/955 **Author:** [@UwUCammie](https://github.com/UwUCammie) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/gameinput-wine-hotplug` --- ### 📝 Commits (1) - [`3f59ed6`](https://github.com/ubiquitarianism/leonida/commit/3f59ed6f8818e7e96b5b4b963b0b053f4afb88cb) gameinput: pads plugged in after start under Wine, and IJKL on the keyboard pad's right stick (RT-GAMEINPUT-WINE-HOTPLUG) ### 📊 Changes **2 files changed** (+100 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/gameinput.md` (+2 -0) 📝 `runtime/shims/gameinput.cpp` (+98 -1) </details> ### 📄 Description Claimed in the coordination issue as: RT-GAMEINPUT-WINE-HOTPLUG ### What and why Under Wine a controller plugged in after the game has started never reaches the title. SDL's Windows backends only rescan when Windows reports a device change: the XInput and DirectInput drivers through `CM_Register_Notification`, HIDAPI through `WM_DEVICECHANGE` on its message window. Wine delivers neither for a pad that arrives later. Measured on Wine 11.22: a run started with no pad never showed one after it was connected. A pad that is unplugged does go away, because its reads fail. The poll thread now builds a small signature once a second, without touching SDL internals: - which XInput slots answer `XInputGetCapabilities`; - the HID devices in `GetRawInputDeviceList` with usage page 1 and usage joystick, gamepad or multi-axis. Wine refreshes both lists itself. When the signature changes, SDL's gamepad subsystem is restarted (`SDL_QuitSubSystem` / `SDL_InitSubSystem(SDL_INIT_GAMEPAD)`), the one public way to make every backend scan again. Open pads are closed first through the normal `close_pad` path, so the title sees a disconnect and a reconnect, and only when the hardware changed. `LEONIDA_GAMEINPUT_HOTPLUG=0` turns it off. The keyboard pad also gets I/J/K/L as the right stick at full deflection, over the mouse. The retail title's legal terms screen scrolls each policy text on the right stick, and its checkboxes only count once a text has been scrolled to the end. Without a pad or a working mouse path (headless runs), that screen could not be passed. `docs/gameinput.md` lists both. ### Tested - `gameinput_test.exe` on this branch (clang-cl + xwin cross build, run under Wine 11.22): `364 checks, 0 failures`. - The same change on a local integration branch, retail 1.0.2.1 under Wine with an 8BitDo pad (XInput, `2dc8:301d`). At start SDL listed the one pad three times (as an Xbox 360, an Xbox One S and an XInput controller). After the first signature change (Wine finishing its device list) the restart left exactly one pad plus the keyboard pad, and input kept working. With K held, the terms screen scrolled to the end of each text and its Confirm button enabled. - Not tested: physically plugging a pad in mid-run on this machine (I ran remotely). The restart path is the same one the first signature change exercised. GPUs tested: n/a (input only; the machine is an AMD Radeon RX 7900 XT, RADV, Mesa 26.3.1, CachyOS, Wine 11.22) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#993
No description provided.