Skip to content

feat(input): Implement SDL3 input and window management - #2639

Draft
mirelle7 wants to merge 53 commits into
TheSuperHackers:mainfrom
mirelle7:feature/sdl3-input-backport
Draft

mirelle7 wants to merge 53 commits into
TheSuperHackers:mainfrom
mirelle7:feature/sdl3-input-backport

Conversation

@mirelle7

@mirelle7 mirelle7 commented Apr 20, 2026 •

Copy link
Copy Markdown

SDL3 Input Backend
This PR updates the windowing and input pipeline to use SDL3 by default on modern toolchains (non-VC6 builds) to DirectInput and Win32 window creation. By utilizing SDL3, we bypass DirectInput emulation layers on modern systems, providing a lower-latency pipeline for Windows 11 and Wine/Linux users.

Input handling
Unified event manager that centralizes keyboard, mouse, and gamepad events into a thread-safe buffer

Gamepad Support (v0.1)
This is an initial baseline implementation focused on providing functional out-of-the-box playability. Feedback is encouraged regarding the ergonomics and logic of these default mappings.

Input Action
Left Stick Virtual mouse cursor
Right Stick Camera pan (arrow keys)
LT (hold) Currently unmapped
RT (hold) Force Attack (LCTRL)
LB Select All (Q)
RB Queue Orders (LSHIFT)
A Left click
AA Guard mode
B Right click
X Attack Move (A)
Y Stop (S)
D-Pad Control groups 1–4
Start Menu (ESC)
Back Last radar event (SPACE)
L3 Next idle worker
R3 Snap to command center

Scope Note: This implementation provides a hardcoded default layout to establish core functionality. Advanced features, such as input remapping, radial menus, adjustable deadzones, are currently out of scope for this PR and may be addressed in future iterations.

This SDL3 input/windowing backend builds on prior work from the community:

@mirelle7
mirelle7 force-pushed the feature/sdl3-input-backport branch from a785545 to 7cc0861 Compare April 20, 2026 15:00
@greptile-apps

greptile-apps Bot commented Apr 20, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR introduces a new SDL3 windowing and input backend as an alternative to the legacy Win32/DirectInput path on modern toolchains, with initial gamepad support mapping controller buttons to virtual keyboard/mouse events. Startup logic shared between both backends is consolidated into a new AppMain helper to eliminate duplication between the Generals and Zero Hour WinMain.cpp files.

  • SDL3 backend: SDL3Main.cpp, SDL3GameEngine, SDL3Mouse, SDL3Keyboard, and SDL3InputManager provide a full replacement for the Win32 input/window stack, with per-frame event polling, coordinate scaling for letterboxed displays, and SDL3's built-in animated cursor API.
  • Gamepad support (v0.1): Left stick drives a virtual mouse cursor with smoothstep acceleration and edge-boost; right stick sends arrow-key camera pan; face buttons and shoulders map to common RTS hotkeys. All synthetic events now carry the correct windowID so coordinate scaling works consistently.
  • LookAtXlat refactor: setScrolling/stopScrolling are null-guarded, controller scroll speed scales with zoom level, and edge-scroll is suppressed while a controller stick is active.

Confidence Score: 5/5

  • The SDL3 backend is well-structured and addresses known correctness issues from earlier review rounds; the only new finding is a style-rule violation in three gamepad button lambdas.
  • All synthetic input events now carry the correct windowID, the event-buffer initialisation is correct, SDL_WarpMouseInWindow uses the real window handle, GameEngine::init() is called unconditionally in headless mode, and TheMessageStream is null-guarded in every gamepad button handler. The remaining finding is an inline if-body in three lambdas that violates the repo's debugger-line convention but does not affect runtime behaviour.
  • Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp deserves a close read, particularly the gamepad input path and coordinate-scaling logic, given the volume of new code.

Important Files Changed

Filename Overview
Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp New 1268-line file implementing SDL3Mouse, SDL3Keyboard, and SDL3InputManager with full gamepad support. The constructor correctly initialises all event-buffer slots to SDL_EVENT_FIRST and m_isQuitting to false; synthetic mouse/button events now carry the correct windowID; SDL_WarpMouseInWindow uses m_window, not nullptr. The three lambdas for NORTH/L3/R3 gamepad buttons contain inline if-bodies that violate the repo's debugger-line rule (P2).
Core/GameEngineDevice/Source/SDL3Device/Common/SDL3GameEngine.cpp New SDL3GameEngine implementation. GameEngine::init() is called unconditionally, so headless mode is handled correctly. The minimised-window throttle loop and text-input state management look sound.
Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Cursor.cpp New cursor manager that delegates frame storage to SDL3's own SDL_CreateAnimatedCursor, removing the need for a fixed-size m_frameCursors array. Direction iteration in initResources is capped at MAX_2D_CURSOR_DIRECTIONS, and getCursor() clamps out-of-range direction to 0.
Core/Main/SDL3Main.cpp New SDL3 entry point. SDL_Init failure returns early with proper shutdown; window creation failure also cleans up; headless path correctly skips SDL initialisation while still calling AppMain::run(). ApplicationHWnd is retrieved from SDL window properties for DirectX compatibility.
Core/Main/AppMain.cpp New shared startup/shutdown helper that consolidates memory manager init, working-directory setup, version object lifecycle, and single-instance mutex between Win32 and SDL3 backends. Reduces duplication across both WinMain.cpp files cleanly.
Core/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp Refactored setScrolling/stopScrolling to null-guard all subsystem pointers and move stats tracking into the state-transition guards; the input-enabled early-return is retained. Added controller scroll-speed scaling based on current zoom height and setControllerInputActive() to suppress edge-scroll during gamepad use.
Generals/Code/Main/WinMain.cpp Refactored to delegate all pre/post-window init and shutdown to AppMain helpers; focus-change handling now routes through AppMain::setAppActive(). Boilerplate removed from WinMain body.
GeneralsMD/Code/Main/WinMain.cpp Same AppMain delegation refactor as Generals/WinMain.cpp; SDL3-specific splash-surface variable added under RTS_SDL3_ENABLE guard but unused in this file (splash is rendered by SDL3Main instead).
vcpkg.json Adds sdl3 and sdl3-image dependencies with version overrides (3.4.10 / 3.4.4). The vcpkg-lock.json is included in the changeset, but reviewers should regenerate and confirm the lock matches these overrides before merging.

Sequence Diagram

sequenceDiagram
    participant OS as OS / SDL3
    participant Main as SDL3Main / WinMain
    participant Engine as SDL3GameEngine
    participant Manager as SDL3InputManager
    participant Mouse as SDL3Mouse
    participant KB as SDL3Keyboard
    participant Game as GameEngine / GameLogic

    Main->>Engine: init() — creates SDL3InputManager, stores m_SDLWindow
    Engine->>Manager: new SDL3InputManager(window)

    loop Each Frame
        Engine->>Engine: update()
        Engine->>Manager: update() via pollSDL3Events()
        OS-->>Manager: SDL_PollEvent loop
        Manager->>Manager: addMouseSDLEvent / addKeyboardSDLEvent
        Manager->>Manager: processGamepadInput() → virtualPulseMouse / virtualPulseKey
        Engine->>Game: GameEngine::update()
        Game->>Mouse: getMouseEvent() → getNextMouseEvent()
        Mouse->>Mouse: translateEvent() → scaleMouseCoordinates()
        Game->>KB: getKey() → getNextKeyboardEvent()
    end

    Manager-->>Engine: "isQuitting() → m_quitting = true"
    Engine-->>Main: getQuitting() → exit loop
Loading

Reviews (38): Last reviewed commit: "rebased" | Re-trigger Greptile

Comment thread Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp Outdated
Comment thread Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp Outdated
Comment thread Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp Outdated
Comment thread Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp
Comment thread cmake/sdl3.cmake Outdated
Comment thread cmake/sdl3.cmake
Comment thread GeneralsMD/Code/Main/WinMain.cpp Outdated
Comment thread cmake/config-build.cmake Outdated
Comment thread cmake/config-build.cmake Outdated
Comment thread Core/GameEngineDevice/Source/SDL3Device/Common/SDL3GameEngine.cpp Outdated
@mirelle7
mirelle7 force-pushed the feature/sdl3-input-backport branch from e365605 to 627ef23 Compare April 20, 2026 18:24
@mirelle7 mirelle7 changed the title feat(input): Implement SDL3 input backend feat(input): Implement SDL3 input and window management Apr 20, 2026
@mirelle7
mirelle7 force-pushed the feature/sdl3-input-backport branch from eb9908a to 534e694 Compare April 21, 2026 01:17
Comment thread GeneralsMD/Code/Main/WinMain.cpp Outdated
Comment thread Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp Outdated
Comment thread Core/GameEngineDevice/Source/SDL3GameEngine.cpp Outdated
Comment thread Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Cursor.cpp
@DevGeniusCode DevGeniusCode added this to the Linux support milestone Apr 29, 2026
@xezon xezon added Gen Relates to Generals ZH Relates to Zero Hour Platform Work towards platform support, such as Linux, MacOS Input labels May 12, 2026

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs polishing. Not yet reviewed extensively until the obvious style issues are fixed.

Comment thread vcpkg-lock.json Outdated
Comment thread CMakeLists.txt Outdated
Comment thread GeneralsMD/Code/Main/WinMain.cpp Outdated
Comment thread Core/GameEngineDevice/Source/SDL3Device/Common/SDL3GameEngine.cpp Outdated
Comment thread Core/GameEngineDevice/Source/SDL3Device/Common/SDL3GameEngine.cpp Outdated
Comment thread Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp Outdated
Comment thread Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp Outdated
Comment thread Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp Outdated
Comment thread cmake/config-build.cmake Outdated
Comment thread cmake/config-build.cmake Outdated
@xezon

xezon commented May 12, 2026

Copy link
Copy Markdown

Perhaps also check Fighter19's fork for SDL related implementations. As far as I am aware he has it all done.

@mirelle7

Copy link
Copy Markdown
Author

I have looked at all existing forks and attributed where possible.

Comment thread Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp
@bobtista

bobtista commented Jun 3, 2026 •

Copy link
Copy Markdown

How about changing display-mode? eg getDisplayModeCount() / getDisplayModeDescription() using SDL_GetFullscreenDisplayModes + desktop mode + resolution filtering. EDIT: Also account for mouse position which can sometimes not match clicks to cursor position.

@bobtista

bobtista commented Jun 3, 2026

Copy link
Copy Markdown

Is it better to use SDL3InputManager (+ SDL3CursorManager) or to split out SDL3Keyboard + SDL3Mouse that subclass the engine's existing Keyboard/Mouse base classes?

Comment thread vcpkg-lock.json Outdated

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we have a SDL3Main or not?

Comment thread Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp Outdated
@mirelle7

Copy link
Copy Markdown
Author

I've started cleaning up the style and structural issues in the latest commits.

Regarding SDL3Main: The main benefit of the current approach is that we keep the game's native Win32 WinMain entry point and startup sequence intact.

To get rid of the #ifdef blocks in WinMain while minimizing duplication, I can move the window initialization out into SDL3Window.

Regarding splitting out subclasses: I don't think splitting the input handling into isolated SDL3Keyboard and SDL3Mouse subclasses is the right way. It runs contrary to how SDL3 tries to be a unified way; it relies on a single event pump where all keyboard, mouse, and gamepad signals flow together.

@xezon

xezon commented Jun 24, 2026

Copy link
Copy Markdown

I don't think splitting the input handling into isolated SDL3Keyboard and SDL3Mouse subclasses is the right way.

But this is how you currently have set this up. What is the plan here?

mirelle7 and others added 17 commits September 16, 2026 15:05
- Add radial deadzone removal, smoothstep response curve, and velocity acceleration for analog sticks
- Retire precision mode in favor of continuous stick acceleration (LT is currently unmapped)
- Add getControllerScrollScale() to scale camera panning when zoomed close to ground
- Suppress mouse edge scrolling automatically while gamepad input is active
- Expose getMinHeightAboveGround and getMaxHeightAboveGround on View

Co-authored-by: stm <14291421+stephanmeesters@users.noreply.github.com>
- Replace SDL_GetWindowSizeInPixels with SDL_GetWindowSize in scaleMouseCoordinates
- Fixes HiDPI/Retina coordinate space mismatch where mouse & gamepad motion events delivered in logical points were scaled by physical pixel dimensions

Co-authored-by: Bobby Battista <bobtista@gmail.com>
- Fix camera panning and scroll state handling for gamepads
- Fix double-click detection for gamepad button pulses to trigger Guard mode orders
Co-authored-by: Bobby Battista <bobtista@gmail.com>
SDL3 loads .ani cursors via TheFileSystem rather than Win32's
LoadCursorFromFile, enabling cursor loading from .BIG archives
and virtual filesystems. Add a non-positive size check before
allocating memory buffers to handle empty or invalid files safely.
- Use event.wheel.mouse_x/y directly instead of calling SDL_GetMouseState,
  ensuring accurate cursor position at the exact moment of the wheel event.
- Replace Win32 timeGetTime() with SDL keyEvent.timestamp in SDL3Keyboard::getKey
  for portable millisecond key-down timing.
- Replace Win32 VK_RETURN macro with character code 13 in IME Return key dispatch.
combo box text dropping fixed
Fix the crash when launching a second instance.
Timestamp injected gamepad events so key repeat works.
Ignore gamepad input while the window is unfocused.
Let the window actually resize to the chosen resolution.
@mirelle7
mirelle7 force-pushed the feature/sdl3-input-backport branch from 7ef9d02 to 4993bc8 Compare September 16, 2026 13:07
@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Walkthrough

The change adds SDL3 build support, shared application lifecycle code, SDL3 engine and input implementations, cursor management, controller input, and related timing and window behavior updates. Existing Win32 builds retain their original backend selection.

Changes

SDL3 backend integration

Layer / File(s) Summary
SDL3 build and dependency configuration
.github/workflows/*, CMakeLists.txt, CMakePresets.json, cmake/*, triplets/*, vcpkg*.json
SDL3 and SDL3_image configuration, vcpkg registries, dependency versions, overlay triplets, and conditional build wiring were added.
Shared application lifecycle and entry points
Core/Main/*, Generals/Code/Main/*, GeneralsMD/Code/Main/*, Core/Libraries/.../dx8wrapper.cpp
Application initialization, shutdown, splash lookup, activity state, and main-loop handling moved into AppMain. SDL3 and Win32 entry points select the appropriate startup path. Window positioning suppresses WM_WINDOWPOSCHANGING notifications.
SDL3 engine, input, and cursor runtime
Core/GameEngineDevice/Include/SDL3Device/*, Core/GameEngineDevice/Source/SDL3Device/*, Generals*/Code/GameEngineDevice/.../W3DGameClient.h, Core/GameEngine/Include/GameClient/Display.h
SDL3 engine, mouse, keyboard, gamepad, virtual input, text input, event queues, cursor loading, and cursor caching were added. SDL3 builds select these adapters and expose viewport access.
Shared timing, cursor synchronization, and controller camera behavior
Generals*/Code/GameEngine/*, Core/GameEngine/Include/GameClient/*, Core/GameEngine/Source/GameClient/*
The engine exposes millisecond ticks. Mouse initialization synchronizes with the system cursor. Look-at scrolling handles optional dependencies, controller state, and zoom-scaled movement.

Priority: ➖ Normal

Estimated code review effort: 5 (Critical) | ~90 minutes

Change: Feature

Merge Risk: 🟡 Moderate · up to 138be

Controller disconnect or focus loss can leave a virtual mouse button pressed when input traffic fills the queue. Ensure release delivery before merging.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: SDL3 input and window management implementation.
Description check ✅ Passed The description directly explains the SDL3 input backend, windowing changes, gamepad mappings, scope, and implementation objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot requested review from bobtista and xezon September 16, 2026 13:08

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b10c0e59-5b76-4a9a-9960-26ac59b3d55a

📥 Commits

Reviewing files that changed from the base of the PR and between 039bd17 and 4993bc8.

📒 Files selected for processing (39)
  • .github/workflows/ci.yml
  • .github/workflows/reusable-build-toolchain.yml
  • CMakeLists.txt
  • CMakePresets.json
  • Core/GameEngine/Include/GameClient/Display.h
  • Core/GameEngine/Include/GameClient/LookAtXlat.h
  • Core/GameEngine/Include/GameClient/Mouse.h
  • Core/GameEngine/Include/GameClient/View.h
  • Core/GameEngine/Source/GameClient/Input/Keyboard.cpp
  • Core/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
  • Core/GameEngineDevice/CMakeLists.txt
  • Core/GameEngineDevice/Include/SDL3Device/Common/SDL3GameEngine.h
  • Core/GameEngineDevice/Include/SDL3Device/GameClient/SDL3Cursor.h
  • Core/GameEngineDevice/Include/SDL3Device/GameClient/SDL3Input.h
  • Core/GameEngineDevice/Source/SDL3Device/Common/SDL3GameEngine.cpp
  • Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Cursor.cpp
  • Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp
  • Core/Main/AppMain.cpp
  • Core/Main/AppMain.h
  • Core/Main/SDL3Main.cpp
  • Core/Main/SDL3Main.h
  • Generals/Code/GameEngine/Include/Common/GameEngine.h
  • Generals/Code/GameEngine/Source/Common/GameEngine.cpp
  • Generals/Code/GameEngine/Source/GameClient/GameClient.cpp
  • Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DGameClient.h
  • Generals/Code/Main/CMakeLists.txt
  • Generals/Code/Main/WinMain.cpp
  • GeneralsMD/Code/GameEngine/Include/Common/GameEngine.h
  • GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
  • GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp
  • GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DGameClient.h
  • GeneralsMD/Code/Main/CMakeLists.txt
  • GeneralsMD/Code/Main/WinMain.cpp
  • cmake/config-build.cmake
  • cmake/sdl3.cmake
  • triplets/x86-windows.cmake
  • vcpkg-configuration.json
  • vcpkg.json

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread cmake/sdl3.cmake Outdated
Comment thread Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Cursor.cpp
Comment thread Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp Outdated
Comment thread Core/Main/AppMain.cpp Outdated
…oints

SDL3Main.cpp had no SetUnhandledExceptionFilter/try-catch, losing crash
dumps on that path; move WinMain.cpp's handler into AppMain so both
entry points install it once instead of duplicating it, and wrap
AppMain::run() in a catch-all so both paths get equivalent coverage.
…heck

The shared fallback branch called FetchContent_MakeAvailable(SDL3)
whenever SDL3_image's version check failed, even if SDL3 was already
found via find_package - defining its targets twice and stopping the
configure. Give each library its own guarded fallback branch.
Restore ALT-key release (resetKeys instead of the no-op reset), audio
mute/unmute, and stuck gamepad-driven virtual keys on window focus
change, and stop double-counting gamepad cursor motion deltas.
loadANI now returns nullptr instead of a cursor with a null SDL_Cursor
when creation fails; clamp viewport-scaled mouse coordinates to the
last valid pixel instead of one past it; skip loading the splash BMP
in headless mode; drop the dead addSDLEvent wrappers and unused
SDL3CursorManager::init(); use snprintf for the splash path buffer.
setScrolling/stopScrolling were retrofitted with null checks for
TheMouse/TheDisplay et al. but canScrollAtScreenEdge still
dereferenced TheMouse and TheDisplay unconditionally.
@mirelle7
mirelle7 force-pushed the feature/sdl3-input-backport branch from 1570138 to 138be1c Compare September 16, 2026 19:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 903dd94a-ed5f-4511-8606-db3f1e01b64a

📥 Commits

Reviewing files that changed from the base of the PR and between 4993bc8 and 138be1c.

📒 Files selected for processing (12)
  • Core/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
  • Core/GameEngineDevice/Include/SDL3Device/GameClient/SDL3Cursor.h
  • Core/GameEngineDevice/Include/SDL3Device/GameClient/SDL3Input.h
  • Core/GameEngineDevice/Source/SDL3Device/Common/SDL3GameEngine.cpp
  • Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Cursor.cpp
  • Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp
  • Core/Main/AppMain.cpp
  • Core/Main/AppMain.h
  • Core/Main/SDL3Main.cpp
  • Generals/Code/Main/WinMain.cpp
  • GeneralsMD/Code/Main/WinMain.cpp
  • cmake/sdl3.cmake
💤 Files with no reviewable changes (1)
  • Core/GameEngineDevice/Include/SDL3Device/GameClient/SDL3Cursor.h

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

if (m_state.buttonState[SDL_GAMEPAD_BUTTON_DPAD_LEFT]) virtualPulseKey(SDL_SCANCODE_1, false);
if (m_state.buttonState[SDL_GAMEPAD_BUTTON_DPAD_RIGHT]) virtualPulseKey(SDL_SCANCODE_3, false);

m_state = GamepadState();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '800,1030p' Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp
sed -n '100,190p' Core/GameEngineDevice/Include/SDL3Device/GameClient/SDL3Input.h
rg -n 'releaseGamepadVirtualInputs|addMouseEvent|addKeyboardEvent|virtual.*(Mouse|Key)|clear.*(Mouse|Keyboard)|reset.*(Mouse|Keyboard)|getMouseEvent|getKeyboardEvent' Core/GameEngineDevice Core/GameEngine

Repository: TheSuperHackers/GeneralsGameCode

Length of output: 19375


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- event ingestion and queue consumers ---'
sed -n '1,430p' Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp
printf '%s\n' '--- gamepad injection and state transitions ---'
sed -n '1020,1250p' Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp
printf '%s\n' '--- SDL input declarations and reset-related symbols ---'
sed -n '1,190p' Core/GameEngineDevice/Include/SDL3Device/GameClient/SDL3Input.h
rg -n -C 4 'reset\\(|SDL_EVENT_MOUSE_MOTION|SDL_EVENT_MOUSE_BUTTON|SDL_EVENT_KEY|addMouseSDLEvent|addKeyboardSDLEvent|m_mouseNext|getNextMouseEvent|m_keyNext|getNextKeyboardEvent' Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp Core/GameEngineDevice/Include/SDL3Device/GameClient/SDL3Input.h Core/GameEngine/Source/GameClient/Input Core/GameEngine/Include/GameClient

Repository: TheSuperHackers/GeneralsGameCode

Length of output: 22766


🏁 Script executed:

sed -n '1,430p' Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp
sed -n '1020,1250p' Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp
rg -n -C 4 'reset\(|SDL_EVENT_MOUSE_MOTION|SDL_EVENT_MOUSE_BUTTON|SDL_EVENT_KEY|addMouseSDLEvent|addKeyboardSDLEvent|m_mouseNext|getNextMouseEvent|m_keyNext|getNextKeyboardEvent' Core/GameEngineDevice/Source/SDL3Device/GameClient/SDL3Input.cpp Core/GameEngineDevice/Include/SDL3Device/GameClient/SDL3Input.h Core/GameEngine/Source/GameClient/Input Core/GameEngine/Include/GameClient

Repository: TheSuperHackers/GeneralsGameCode

Length of output: 50388


Guarantee synthesized releases before clearing m_state.

SDL3InputManager::update() queues SDL_EVENT_MOUSE_MOTION through addMouseSDLEvent(), so motion can fill the mouse ring. A full ring drops the event. releaseGamepadVirtualInputs() uses the same path for SOUTH and EAST button-up events, then clears m_state without retrying. Focus loss and gamepad disconnect can therefore leave a virtual mouse button pressed.

SDL3Mouse::reset() and Keyboard::reset() do not clear this queued or pressed state. Guarantee release insertion before clearing m_state by reserving capacity for releases or evicting non-critical motion events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Input Platform Work towards platform support, such as Linux, MacOS ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants