forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 232
feat(input): Implement SDL3 input and window management #2639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
githubawn
wants to merge
39
commits into
TheSuperHackers:main
Choose a base branch
from
githubawn:feature/sdl3-input-backport
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
e406fca
SDL3 Input: Complete backport with Gamepad support and hardening
githubawn 17f1816
SDL3 Input: Complete backport with Gamepad support and hardening
githubawn bd9921f
added build guards
githubawn 86f996b
greptile feedback
githubawn 43beb41
greptile feedback
githubawn 96d0b3d
fixed build error
githubawn 47b934c
greptile feedback
githubawn 8cfcef4
added vcpkg
githubawn ebab585
vcpkg fix
githubawn 2774a78
changed dpad group numbers
githubawn 186eaf7
switch back to static linking
githubawn 6b3bec1
move SDL3_image out SDL3input
githubawn d775816
properly fail on SDL_INIT failure
githubawn 40d480c
removed custom ICO decoder
githubawn a959ecb
fixes SDL_WarpMouseInWindow mismatch
githubawn ea63a09
removed some dead declarations
githubawn 13f1f66
temporary re-added custom decoder
githubawn 94d3f4b
dont early return for headless mode
githubawn c75d632
applied clang to files new in this PR
githubawn 4b87f56
updated SDL to latest version
githubawn 2a55d23
renamed SAGE_USE_SDL3 to RTS_SDL3_ENABLE
githubawn 8533760
cleaned up comments
githubawn 25d8a42
build: upgrade SDL_image and clean up SDL3Cursor loadANI
githubawn 57bcdf9
style: remove legacy empty parameter list style (void) -> ()
githubawn 5e4c4d7
build: update vcpkg dependencies and fix SDL3 input scancode translation
githubawn 808f8d0
move cmake to RTS_BUILD_OPTION_SDL3, fix sorting
githubawn 81bf8f9
Move SDL3GameEngine files to Common directory.
githubawn 785d213
style/fix: address PR review feedback on SDL3 input and engine device
githubawn 78f7e15
Refactor entry points: extract AppMain lifecycle and isolate SDL3Main
githubawn 6640a47
fix(build): correct include ordering in AppMain and SDL3Main for VC6 …
githubawn a19098f
fix(sdl3): address PR review feedback on SDL3 input and app lifecycle
githubawn 3d7a346
feat(sdl3): backport gamepad stick acceleration and camera modulation
githubawn 826c951
fix(sdl3): use logical window points in scaleMouseCoordinates
githubawn 3bd8573
feat(sdl3): gamepad camera scrolling and double-click Guard mode
githubawn f1c78e9
Polar Gamepad Cursor Acceleration (with Instant Hard Stop)
githubawn ade29fc
fix(sdl3): backport SDL3 input, focus, and windowing fixes from review
githubawn 694e709
prevent cursor direction count possible exceeding bounds
githubawn e481399
greptile feedback
githubawn 41d2769
greptile feedback
githubawn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
Core/GameEngineDevice/Include/SDL3Device/Common/SDL3GameEngine.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| ** Command & Conquer Generals Zero Hour(tm) | ||
| ** Copyright 2026 TheSuperHackers | ||
| ** | ||
| ** This program is free software: you can redistribute it and/or modify | ||
| ** it under the terms of the GNU General Public License as published by | ||
| ** the Free Software Foundation, either version 3 of the License, or | ||
| ** (at your option) any later version. | ||
| ** | ||
| ** This program is distributed in the hope that it will be useful, | ||
| ** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| ** GNU General Public License for more details. | ||
| ** | ||
| ** You should have received a copy of the GNU General Public License | ||
| ** along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "Lib/BaseType.h" | ||
|
|
||
| #include <SDL3/SDL.h> | ||
|
|
||
| #include "Common/GameEngine.h" | ||
|
|
||
| // SDL3 window typically provided by WinMain integration | ||
| extern SDL_Window* TheSDL3Window; | ||
|
|
||
| // Forward declarations for base classes | ||
| class AudioManager; | ||
| class Mouse; | ||
| class Keyboard; | ||
| class GameWindow; | ||
| class LocalFileSystem; | ||
| class ArchiveFileSystem; | ||
| class ThingFactory; | ||
| class ModuleFactory; | ||
| class FunctionLexicon; | ||
| class Radar; | ||
| class WebBrowser; | ||
| class ParticleSystemManager; | ||
|
|
||
| class SDL3GameEngine : public GameEngine | ||
| { | ||
| public: | ||
| SDL3GameEngine(); | ||
| virtual ~SDL3GameEngine(); | ||
|
|
||
| // GameEngine interface | ||
| virtual void init() override; | ||
| virtual void reset() override; | ||
| virtual void update() override; | ||
| virtual void serviceWindowsOS() override; | ||
| virtual Bool isActive() override; | ||
| virtual void setIsActive(Bool isActive) override; | ||
|
|
||
| // Factory methods (override GameEngine) | ||
| virtual LocalFileSystem* createLocalFileSystem() override; | ||
| virtual ArchiveFileSystem* createArchiveFileSystem() override; | ||
| virtual GameLogic* createGameLogic() override; | ||
| virtual GameClient* createGameClient() override; | ||
| virtual ModuleFactory* createModuleFactory() override; | ||
| virtual ThingFactory* createThingFactory() override; | ||
| virtual FunctionLexicon* createFunctionLexicon() override; | ||
| virtual Radar* createRadar(Bool dummy) override; | ||
| virtual WebBrowser* createWebBrowser() override; | ||
| virtual ParticleSystemManager* createParticleSystemManager(Bool dummy) override; | ||
| virtual AudioManager* createAudioManager(Bool dummy) override; | ||
|
|
||
| // SDL3 specific | ||
| virtual SDL_Window* getSDLWindow() const { return m_SDLWindow; } | ||
| virtual void forwardTextInputEvent(const char* utf8Text); | ||
|
|
||
| protected: | ||
| SDL_Window* m_SDLWindow; | ||
| Bool m_IsInitialized; | ||
| Bool m_IsActive; | ||
| Bool m_IsTextInputActive; | ||
| GameWindow* m_TextInputFocusWindow; | ||
|
|
||
| // Event processing | ||
| void pollSDL3Events(); | ||
| void updateTextInputState(); | ||
| }; |
61 changes: 61 additions & 0 deletions
61
Core/GameEngineDevice/Include/SDL3Device/GameClient/SDL3Cursor.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| ** Command & Conquer Generals Zero Hour(tm) | ||
| ** Copyright 2026 TheSuperHackers | ||
| ** | ||
| ** This program is free software: you can redistribute it and/or modify | ||
| ** it under the terms of the GNU General Public License as published by | ||
| ** the Free Software Foundation, either version 3 of the License, or | ||
| ** (at your option) any later version. | ||
| ** | ||
| ** This program is distributed in the hope that it will be useful, | ||
| ** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| ** GNU General Public License for more details. | ||
| ** | ||
| ** You should have received a copy of the GNU General Public License | ||
| ** along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "Lib/BaseType.h" | ||
|
|
||
| #include <array> | ||
| #include <SDL3/SDL.h> | ||
|
|
||
| #include "GameClient/Mouse.h" | ||
|
|
||
| struct AnimatedCursor | ||
| { | ||
| SDL_Cursor* m_cursor; | ||
|
|
||
| AnimatedCursor() | ||
| : m_cursor(nullptr) | ||
| {} | ||
| ~AnimatedCursor() | ||
| { | ||
| if (m_cursor) | ||
| { | ||
| SDL_DestroyCursor(m_cursor); | ||
| m_cursor = nullptr; | ||
| } | ||
| } | ||
|
|
||
| SDL_Cursor* getCursor() const { return m_cursor; } | ||
| }; | ||
|
|
||
| class SDL3CursorManager | ||
| { | ||
| public: | ||
| static void init(); | ||
| static void shutdown(); | ||
|
|
||
| static SDL_Cursor* getCursor(Mouse::MouseCursor cursor, int direction); | ||
|
|
||
| // Internal loader used by Mouse implementation | ||
| static void initResources(Mouse* mouse); | ||
|
|
||
| private: | ||
| static AnimatedCursor* loadANI(const char* filepath); | ||
| static AnimatedCursor* m_cursorResources[Mouse::NUM_MOUSE_CURSORS][MAX_2D_CURSOR_DIRECTIONS]; | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.