Add SDL3Swift wrappers for OpenGL, keyboard, mouse, and misc APIs#13
Merged
Conversation
Wraps SDL_GL_CreateContext/MakeCurrent/DestroyContext/SwapWindow and the attribute get/set + swap interval APIs, which had no coverage before.
Wraps SDL_GetKeyboardState/SDL_GetScancodeName and adds ~50 named Scancode constants for keybinding use cases.
Wraps SDL_GetMouseState/GetRelativeMouseState and window relative-mouse-mode and mouse-grab setters.
Adds SDL_GetGamepadName/Properties/RumbleGamepad/SetGamepadPlayerIndex, axis/button string lookups, and the mapping-file/isGamepad helpers.
Adds SDL_SetWindowFullscreen, SDL_GetWindowPosition, and SDL_SyncWindow.
Needed as the return type for the new display bounds accessors.
Adds SDL_GetDisplayBounds/GetDisplayUsableBounds/GetDisplayForWindow and SDL_GetCurrentVideoDriver.
Wraps SDL_GetTicks/SDL_Delay (millisecond variants, alongside SDL's existing nanosecond wrappers) and SDL_GetCurrentTime/SDL_TimeToDateTime.
SDL's logging functions are C-variadic and unavailable in Swift, so this routes through SDL_LogMessageV via withVaList with a fixed "%s" format.
Wraps SDL_ShowSimpleMessageBox.
Wraps SDL_GetBooleanProperty, used by Gamepad.hasRumble.
Wraps SDL_GetJoysticks/SDL_GetJoystickNameForID, distinct from the higher-level Gamepad API.
Adds SDL_EVENT_MOUSE_WHEEL, SDL_EVENT_TEXT_INPUT, and SDL_EVENT_WINDOW_CLOSE_REQUESTED cases, previously falling through to .unknown.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
OpenGL.swiftwrapping SDL3's GL context management (SDL_GL_CreateContext/MakeCurrent/SwapWindow/attributes/swap interval), previously uncovered.Keyboard.swiftandMouse.swiftfor polled input state (SDL_GetKeyboardState,SDL_GetMouseState, relative mouse mode, mouse grab).Time.swift,Log.swift,MessageBox.swift,Rect.swift,Properties.swift,Joystick.swift.Gamepad.swift(name, rumble, player index, mapping files),Window.swift(fullscreen, position, sync),VideoDisplay.swift(bounds, usable bounds, per-window display, current video driver), andEvent.swift(mouse wheel, text input, window close requested).Test plan
swift build(whole package) succeedsswift test --filter SDL3Testspasses