Skip to content

Add fullscreen display and SDL gamepad support to emulator - #1

Merged
maxvdec merged 1 commit into
mainfrom
feature/make-emulator-full-screen-and-add-controller-support
Jul 12, 2026
Merged

Add fullscreen display and SDL gamepad support to emulator#1
maxvdec merged 1 commit into
mainfrom
feature/make-emulator-full-screen-and-add-controller-support

Conversation

@maxvdec

@maxvdec maxvdec commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • Provide a fullscreen emulator window while preserving the 320x180 logical presentation so games render with correct aspect/letterboxing.
  • Add real controller support so players can use gamepads (including analog sticks and D-pad) mapped to the emulator's input bits and enable two-player controllers via hotplug.

Description

  • Open the SDL window with SDL_WINDOW_FULLSCREEN and keep the existing logical presentation using SDL_SetRenderLogicalPresentation so the 320x180 framebuffer is letterboxed.
  • Add a GamepadSlot struct, a gamepads vector, and lifecycle methods openAvailableGamepads, openGamepad, closeGamepad, closeAllGamepads, and gamepadPad to SdlHost in emulator/include/e16/sdl_host.h.
  • Implement gamepadButtons to map analog sticks (with a dead zone), D-pad, face buttons (South/East/West/North), start/back/shoulder buttons to E16 pad bits, and wire hotplug handling and input combination in emulator/src/sdl_host.cpp.
  • Update the controls dialog and README.md to document fullscreen behavior and controller button/stick mappings.

Testing

  • Ran code formatting (clang-format -i) over the changed files without error.
  • Attempted to configure and build the emulator with cmake -S emulator -B emulator/build && cmake --build emulator/build, but configuration failed because the environment is missing the sdl3 development package (pkg-config sdl3 not found), so a full build could not be completed.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 253c941303

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread emulator/src/sdl_host.cpp
SDL_CloseGamepad(slot.gamepad);
return true;
});
gamepads.erase(removed, gamepads.end());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve gamepad player slots on disconnect

When the first of two connected gamepads is unplugged, this erase compacts the vector, while gamepadPad() treats vector index 0/1 as player 1/2. In a two-player session with a transient disconnect of player 1's controller, the remaining player 2 controller starts driving player 1 and player 2 reads as disconnected; replugging the original controller then assigns it to player 2. Keep fixed slots or replace the removed slot with an empty entry so hotplugging does not silently swap player assignments.

Useful? React with 👍 / 👎.

@maxvdec
maxvdec merged commit 896130a into main Jul 12, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant