Classes | |
| class | IWindowBackend |
| Abstract window backend interface. More... | |
| struct | PatchInfo |
| class | SDL2WindowBackend |
| SDL2 implementation of the window backend interface. More... | |
| class | WasmPatchExport |
| class | WindowBackendFactory |
| Factory for creating window backends. More... | |
| struct | WindowConfig |
| Window configuration parameters. More... | |
| struct | WindowEvent |
| Platform-agnostic window event data. More... | |
| struct | WindowStatus |
| Window backend status information. More... | |
Typedefs | |
| using | KeyboardState = const Uint8* |
| using | GamepadHandle = SDL_GameController* |
| using | GamepadButton = SDL_GameControllerButton |
| using | GamepadAxis = SDL_GameControllerAxis |
Enumerations | |
| enum class | WindowEventType { None , Close , Resize , Minimized , Maximized , Restored , Shown , Hidden , Exposed , FocusGained , FocusLost , KeyDown , KeyUp , MouseMotion , MouseButtonDown , MouseButtonUp , MouseWheel , Quit , DropFile } |
| Window event types (platform-agnostic) More... | |
| enum class | WindowBackendType { SDL2 , SDL3 , Auto } |
| Backend type enumeration for factory. More... | |
Functions | |
| SDL_Keycode | GetKeyFromEvent (const SDL_Event &event) |
| Get keyboard state from SDL event. | |
| SDL_Scancode | GetScancodeFromKey (SDL_Keycode key) |
| Get scancode from keycode. | |
| bool | IsKeyPressed (KeyboardState state, SDL_Scancode scancode) |
| Check if a key is pressed using the keyboard state. | |
| GamepadHandle | OpenGamepad (int index) |
| void | CloseGamepad (GamepadHandle gamepad) |
| bool | GetGamepadButton (GamepadHandle gamepad, SDL_GameControllerButton button) |
| int16_t | GetGamepadAxis (GamepadHandle gamepad, SDL_GameControllerAxis axis) |
| bool | IsGamepadConnected (int index) |
| SDL_Renderer * | CreateRenderer (SDL_Window *window) |
| Create a renderer with default settings. | |
| void | SetRenderVSync (SDL_Renderer *renderer, int interval) |
| Set vertical sync for the renderer. | |
| bool | RenderTexture (SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_Rect *dstrect) |
| Render a texture to the current render target. | |
| void | FreeSurface (SDL_Surface *surface) |
| Free/destroy a surface. | |
| SDL_Surface * | ConvertSurfaceFormat (SDL_Surface *surface, uint32_t format, uint32_t flags=0) |
| Convert a surface to a specific pixel format. | |
| SDL_Palette * | GetSurfacePalette (SDL_Surface *surface) |
| Get the palette attached to a surface. | |
| Uint32 | GetSurfaceFormat (SDL_Surface *surface) |
| Get the pixel format of a surface as Uint32. | |
| Uint32 | MapRGB (SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b) |
| Map an RGB color to the surface's pixel format. | |
| SDL_Surface * | CreateSurface (int width, int height, int depth, uint32_t format) |
| Create a surface using the appropriate API. | |
| int | GetSurfaceBitsPerPixel (SDL_Surface *surface) |
| Get bits per pixel from a surface. | |
| bool | EnsureSurfacePalette256 (SDL_Surface *surface) |
| Ensure the surface has a proper 256-color palette for indexed formats. | |
| int | GetSurfaceBytesPerPixel (SDL_Surface *surface) |
| Get bytes per pixel from a surface. | |
| bool | IsWindowCloseEvent (const SDL_Event &event) |
| Check if an event is a window close event Works correctly for both SDL2 (nested) and SDL3 (individual) events. | |
| bool | IsWindowResizeEvent (const SDL_Event &event) |
| Check if an event is a window resize event. | |
| bool | IsWindowMinimizedEvent (const SDL_Event &event) |
| Check if an event is a window minimize event. | |
| bool | IsWindowRestoredEvent (const SDL_Event &event) |
| Check if an event is a window restore event. | |
| int | GetWindowEventWidth (const SDL_Event &event) |
| Get window width from resize event data. | |
| int | GetWindowEventHeight (const SDL_Event &event) |
| Get window height from resize event data. | |
| bool | InitSucceeded (int result) |
| Check if SDL initialization succeeded. | |
| uint32_t | GetDefaultInitFlags () |
| Get recommended init flags. | |
| SDL_Surface * | CreateRGBSurface (Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) |
| Create an RGB surface. | |
| void | DestroySurface (SDL_Surface *surface) |
| Destroy a surface. | |
| int | GetRendererOutputSize (SDL_Renderer *renderer, int *w, int *h) |
| Get renderer output size. | |
| SDL_Surface * | ReadPixelsToSurface (SDL_Renderer *renderer, int width, int height, const SDL_Rect *rect) |
| Read pixels from renderer to a surface. | |
| SDL_Surface * | LoadBMP (const char *file) |
| Load a BMP file. | |
Variables | |
| constexpr auto | kEventKeyDown = SDL_KEYDOWN |
| constexpr auto | kEventKeyUp = SDL_KEYUP |
| constexpr auto | kEventMouseMotion = SDL_MOUSEMOTION |
| constexpr auto | kEventMouseButtonDown = SDL_MOUSEBUTTONDOWN |
| constexpr auto | kEventMouseButtonUp = SDL_MOUSEBUTTONUP |
| constexpr auto | kEventMouseWheel = SDL_MOUSEWHEEL |
| constexpr auto | kEventQuit = SDL_QUIT |
| constexpr auto | kEventDropFile = SDL_DROPFILE |
| constexpr auto | kEventWindowEvent = SDL_WINDOWEVENT |
| constexpr auto | kEventControllerDeviceAdded = SDL_CONTROLLERDEVICEADDED |
| constexpr auto | kEventControllerDeviceRemoved = SDL_CONTROLLERDEVICEREMOVED |
| constexpr auto | kKeyA = SDLK_a |
| constexpr auto | kKeyB = SDLK_b |
| constexpr auto | kKeyC = SDLK_c |
| constexpr auto | kKeyD = SDLK_d |
| constexpr auto | kKeyS = SDLK_s |
| constexpr auto | kKeyX = SDLK_x |
| constexpr auto | kKeyY = SDLK_y |
| constexpr auto | kKeyZ = SDLK_z |
| constexpr auto | kKeyReturn = SDLK_RETURN |
| constexpr auto | kKeyRShift = SDLK_RSHIFT |
| constexpr auto | kKeyUp = SDLK_UP |
| constexpr auto | kKeyDown = SDLK_DOWN |
| constexpr auto | kKeyLeft = SDLK_LEFT |
| constexpr auto | kKeyRight = SDLK_RIGHT |
| constexpr auto | kGamepadButtonA = SDL_CONTROLLER_BUTTON_A |
| constexpr auto | kGamepadButtonB = SDL_CONTROLLER_BUTTON_B |
| constexpr auto | kGamepadButtonX = SDL_CONTROLLER_BUTTON_X |
| constexpr auto | kGamepadButtonY = SDL_CONTROLLER_BUTTON_Y |
| constexpr auto | kGamepadButtonBack = SDL_CONTROLLER_BUTTON_BACK |
| constexpr auto | kGamepadButtonStart = SDL_CONTROLLER_BUTTON_START |
| constexpr auto | kGamepadButtonLeftShoulder = SDL_CONTROLLER_BUTTON_LEFTSHOULDER |
| constexpr auto | kGamepadButtonRightShoulder = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER |
| constexpr auto | kGamepadButtonDpadUp = SDL_CONTROLLER_BUTTON_DPAD_UP |
| constexpr auto | kGamepadButtonDpadDown = SDL_CONTROLLER_BUTTON_DPAD_DOWN |
| constexpr auto | kGamepadButtonDpadLeft = SDL_CONTROLLER_BUTTON_DPAD_LEFT |
| constexpr auto | kGamepadButtonDpadRight = SDL_CONTROLLER_BUTTON_DPAD_RIGHT |
| constexpr auto | kGamepadAxisLeftX = SDL_CONTROLLER_AXIS_LEFTX |
| constexpr auto | kGamepadAxisLeftY = SDL_CONTROLLER_AXIS_LEFTY |
| using yaze::platform::KeyboardState = const Uint8* |
Definition at line 32 of file sdl_compat.h.
| using yaze::platform::GamepadHandle = SDL_GameController* |
Definition at line 193 of file sdl_compat.h.
| using yaze::platform::GamepadButton = SDL_GameControllerButton |
Definition at line 245 of file sdl_compat.h.
| using yaze::platform::GamepadAxis = SDL_GameControllerAxis |
Definition at line 246 of file sdl_compat.h.
|
strong |
|
strong |
|
inline |
Get keyboard state from SDL event.
| event | The SDL event |
Definition at line 115 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL2InputBackend::ProcessEvent(), yaze::emu::input::SDL3InputBackend::ProcessEvent(), and yaze::emu::ui::RenderKeyboardConfig().
|
inline |
Get scancode from keycode.
| key | The keycode |
Definition at line 128 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL2InputBackend::Poll().
|
inline |
Check if a key is pressed using the keyboard state.
| state | The keyboard state from SDL_GetKeyboardState |
| scancode | The scancode to check |
Definition at line 142 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::Poll(), and yaze::emu::ui::RenderEmulatorInterface().
|
inline |
Definition at line 195 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::HandleGamepadEvent(), yaze::emu::input::SDL3InputBackend::Initialize(), and yaze::emu::input::SDL3InputBackend::SetConfig().
|
inline |
Definition at line 202 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::HandleGamepadEvent(), yaze::emu::input::SDL3InputBackend::SetConfig(), and yaze::emu::input::SDL3InputBackend::Shutdown().
|
inline |
Definition at line 206 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
inline |
Definition at line 211 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
inline |
Definition at line 216 of file sdl_compat.h.
|
inline |
Create a renderer with default settings.
SDL2: SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED) SDL3: SDL_CreateRenderer(window, nullptr)
Definition at line 275 of file sdl_compat.h.
Referenced by yaze::gfx::SDL2Renderer::Initialize().
|
inline |
Set vertical sync for the renderer.
SDL2: VSync is set at renderer creation time via flags SDL3: SDL_SetRenderVSync(renderer, interval)
Definition at line 289 of file sdl_compat.h.
Referenced by yaze::gfx::SDL2Renderer::Initialize().
|
inline |
Render a texture to the current render target.
SDL2: SDL_RenderCopy(renderer, texture, srcrect, dstrect) SDL3: SDL_RenderTexture(renderer, texture, srcrect, dstrect)
Note: This version handles the int to float conversion for SDL3.
Definition at line 307 of file sdl_compat.h.
Referenced by yaze::gfx::SDL2Renderer::RenderCopy().
|
inline |
Free/destroy a surface.
SDL2: SDL_FreeSurface(surface) SDL3: SDL_DestroySurface(surface)
Definition at line 346 of file sdl_compat.h.
|
inline |
Convert a surface to a specific pixel format.
SDL2: SDL_ConvertSurfaceFormat(surface, format, flags) SDL3: SDL_ConvertSurface(surface, format)
Definition at line 361 of file sdl_compat.h.
Referenced by yaze::gfx::SDL2Renderer::UpdateTexture().
|
inline |
Get the palette attached to a surface.
Definition at line 375 of file sdl_compat.h.
Referenced by yaze::gfx::Bitmap::ApplyStoredPalette(), EnsureSurfacePalette256(), yaze::zelda3::PaletteDebugger::LogSurfaceState(), yaze::gfx::Arena::ProcessTextureQueue(), yaze::zelda3::Room::RenderRoomGraphics(), yaze::zelda3::PaletteDebugger::SamplePixelAt(), yaze::gfx::Bitmap::SetPalette(), and yaze::gfx::Bitmap::SetPaletteWithTransparent().
|
inline |
Get the pixel format of a surface as Uint32.
Note: SDL2 uses Uint32 for pixel format, SDL3 uses SDL_PixelFormat enum. This function returns Uint32 for cross-version compatibility.
Definition at line 390 of file sdl_compat.h.
Referenced by yaze::zelda3::PaletteDebugger::LogSurfaceState().
|
inline |
Map an RGB color to the surface's pixel format.
Definition at line 402 of file sdl_compat.h.
Referenced by yaze::gfx::Bitmap::WriteColor().
|
inline |
Create a surface using the appropriate API.
Definition at line 418 of file sdl_compat.h.
Referenced by yaze::gfx::Arena::AllocateSurface().
|
inline |
Get bits per pixel from a surface.
SDL2: surface->format->BitsPerPixel SDL3: SDL_GetPixelFormatDetails(surface->format)->bits_per_pixel
Definition at line 434 of file sdl_compat.h.
Referenced by EnsureSurfacePalette256(), and yaze::gui::CanvasContextMenu::RenderBitmapOperationsMenu().
|
inline |
Ensure the surface has a proper 256-color palette for indexed formats.
For 8-bit indexed surfaces, this creates and attaches a 256-color palette if one doesn't exist or if the existing palette is too small.
| surface | The surface to check/fix |
Definition at line 454 of file sdl_compat.h.
References GetSurfaceBitsPerPixel(), and GetSurfacePalette().
Referenced by yaze::gfx::Bitmap::Create(), and yaze::gfx::Bitmap::SetPalette().

|
inline |
Get bytes per pixel from a surface.
SDL2: surface->format->BytesPerPixel SDL3: SDL_GetPixelFormatDetails(surface->format)->bytes_per_pixel
Definition at line 507 of file sdl_compat.h.
Referenced by yaze::gui::CanvasContextMenu::RenderBitmapOperationsMenu().
|
inline |
Check if an event is a window close event Works correctly for both SDL2 (nested) and SDL3 (individual) events.
Definition at line 577 of file sdl_compat.h.
|
inline |
Check if an event is a window resize event.
Definition at line 589 of file sdl_compat.h.
|
inline |
Check if an event is a window minimize event.
Definition at line 603 of file sdl_compat.h.
|
inline |
Check if an event is a window restore event.
Definition at line 615 of file sdl_compat.h.
|
inline |
Get window width from resize event data.
Definition at line 627 of file sdl_compat.h.
|
inline |
Get window height from resize event data.
Definition at line 634 of file sdl_compat.h.
|
inline |
Check if SDL initialization succeeded.
SDL2: Returns 0 on success SDL3: Returns true (non-zero) on success
Definition at line 648 of file sdl_compat.h.
|
inline |
Get recommended init flags.
SDL3 removed SDL_INIT_TIMER (timer is always available).
Definition at line 663 of file sdl_compat.h.
|
inline |
Create an RGB surface.
Definition at line 678 of file sdl_compat.h.
|
inline |
Destroy a surface.
Definition at line 694 of file sdl_compat.h.
|
inline |
Get renderer output size.
Definition at line 709 of file sdl_compat.h.
|
inline |
Read pixels from renderer to a surface.
SDL3: Returns a new surface SDL2: We manually create surface and read into it to match SDL3 behavior
Definition at line 723 of file sdl_compat.h.
|
inline |
Load a BMP file.
Definition at line 747 of file sdl_compat.h.
|
constexpr |
Definition at line 53 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL2InputBackend::ProcessEvent(), yaze::emu::input::SDL3InputBackend::ProcessEvent(), and yaze::emu::ui::RenderKeyboardConfig().
|
constexpr |
Definition at line 54 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL2InputBackend::ProcessEvent(), and yaze::emu::input::SDL3InputBackend::ProcessEvent().
|
constexpr |
Definition at line 55 of file sdl_compat.h.
|
constexpr |
Definition at line 56 of file sdl_compat.h.
|
constexpr |
Definition at line 57 of file sdl_compat.h.
|
constexpr |
Definition at line 58 of file sdl_compat.h.
|
constexpr |
Definition at line 59 of file sdl_compat.h.
|
constexpr |
Definition at line 60 of file sdl_compat.h.
|
constexpr |
Definition at line 63 of file sdl_compat.h.
|
constexpr |
Definition at line 64 of file sdl_compat.h.
|
constexpr |
Definition at line 65 of file sdl_compat.h.
|
constexpr |
Definition at line 90 of file sdl_compat.h.
Referenced by yaze::emu::input::ApplyDefaultKeyBindings().
|
constexpr |
Definition at line 91 of file sdl_compat.h.
|
constexpr |
Definition at line 92 of file sdl_compat.h.
Referenced by yaze::emu::input::ApplyDefaultKeyBindings().
|
constexpr |
Definition at line 93 of file sdl_compat.h.
Referenced by yaze::emu::input::ApplyDefaultKeyBindings().
|
constexpr |
Definition at line 94 of file sdl_compat.h.
Referenced by yaze::emu::input::ApplyDefaultKeyBindings().
|
constexpr |
Definition at line 95 of file sdl_compat.h.
Referenced by yaze::emu::input::ApplyDefaultKeyBindings().
|
constexpr |
Definition at line 96 of file sdl_compat.h.
|
constexpr |
Definition at line 97 of file sdl_compat.h.
Referenced by yaze::emu::input::ApplyDefaultKeyBindings().
|
constexpr |
Definition at line 98 of file sdl_compat.h.
Referenced by yaze::emu::input::ApplyDefaultKeyBindings().
|
constexpr |
Definition at line 99 of file sdl_compat.h.
Referenced by yaze::emu::input::ApplyDefaultKeyBindings().
|
constexpr |
Definition at line 100 of file sdl_compat.h.
Referenced by yaze::emu::input::ApplyDefaultKeyBindings().
|
constexpr |
Definition at line 101 of file sdl_compat.h.
Referenced by yaze::emu::input::ApplyDefaultKeyBindings().
|
constexpr |
Definition at line 102 of file sdl_compat.h.
Referenced by yaze::emu::input::ApplyDefaultKeyBindings().
|
constexpr |
Definition at line 103 of file sdl_compat.h.
Referenced by yaze::emu::input::ApplyDefaultKeyBindings().
|
constexpr |
Definition at line 248 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
constexpr |
Definition at line 249 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
constexpr |
Definition at line 250 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
constexpr |
Definition at line 251 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
constexpr |
Definition at line 252 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
constexpr |
Definition at line 253 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
constexpr |
Definition at line 254 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
constexpr |
Definition at line 255 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
constexpr |
Definition at line 256 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
constexpr |
Definition at line 257 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
constexpr |
Definition at line 258 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
constexpr |
Definition at line 259 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
constexpr |
Definition at line 261 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().
|
constexpr |
Definition at line 262 of file sdl_compat.h.
Referenced by yaze::emu::input::SDL3InputBackend::PollGamepad().