Nintendo Switch port (using AI Claude) - #12
Conversation
This workflow verifies that builds for different platforms still succeed, including desktop, PS2, and Portmaster.
Added syntax check for modified files without requiring WACKI.EXE.
Merging main repo
Replaced fatSync with POSIX sync for flushing writes.
Removed unnecessary sync() call for libfat and updated comments regarding flushing behavior.
mszula
left a comment
There was a problem hiding this comment.
Ogólnie wygląda spoko. Nie mam przekonania do niektórych rozwiązań.
Port Wii wywal.
Do tego brakuje dokumentacji i zmian na ./website
| @@ -0,0 +1,31 @@ | |||
| name: Wii build | |||
There was a problem hiding this comment.
Okładka niezgodna z resztą portu, popraw pls
| * labelled); every other SDL target asks SDL_GameControllerGetType(), which | ||
| * also catches a Joy-Con/Pro Controller plugged into a PC or paired to a | ||
| * PortMaster handheld. */ | ||
| static int is_nintendo_layout(SDL_GameController *pad) |
There was a problem hiding this comment.
Pomyśl nad tym żeby to wydzielić do osobnego hal. Mam obawy bo ten plik puchnie
There was a problem hiding this comment.
Przeniose to chyba do switch.c albo osobno do "nintendo.c" aby w przyszłości nie kopiować kodu do detekcji pada (gra rozpoznaje czy podłączony jest pad od nintendo - jeśli tak to zamienia miejscami funkcje A/B - w padach od nintendo A jest po prawo, B od dołu - a nadal akceptuje się A).
| static SDL_FingerID s_touch_rel_id = 0; | ||
| static float s_touch_rel_last_x = 0.0f, s_touch_rel_last_y = 0.0f; | ||
|
|
||
| static void handle_finger_relative(const SDL_Event *ev) |
There was a problem hiding this comment.
Co to za zmiana pod Androida? Naprawia jakiś błąd? Z czego wynika?
There was a problem hiding this comment.
To nowa funkcjonalność dla Switcha (i przyszłych portów z panelem dotykowym, np. PS Vita, Wii U): tryb 'relative' sprawia, że cały ekran dotykowy zachowuje się jak touchpad laptopa — przesuwanie palca przesuwa kursor o deltę, bez kliknięcia. Guard #ifndef ANDROID jest tam dlatego, że Android ma własny mechanizm dotyku (android_touch.h) i ten kod nie powinien tam działać. Blok #ifdef ANDROID powyżej w tym samym pliku już to obsługuje. Nie jest to fix błędu — to nowa opcja konfiguracyjna (touch_mode=relative w wacki.cfg).
|
Wii przeniose chyba do soobnego brancha - powinno być lepiej. Wróce jutro do tematu jak naprawie to co popsułem ;) |
Nintendo Switch homebrew port
Adds
TARGET=switch— a devkitA64/libnx homebrew build that producesa
.nrolaunchable from hbmenu/Atmosphère. Tested on hardware (handheldand docked mode).
Closes #
How to build
./tools/build-switch.sh # requires Dockeror via the new GitHub Actions workflow (
Switch build).The player copies
Dane_*.dta+ their ownWACKI.EXEtosdmc:/switch/wacki/data/and runswacki.nrofrom hbmenu.New files (Switch-only)
mk/switch.mkpkg-config,elf2nropackagingtools/build-switch.shbuild-ps2.sh).github/workflows/switch.ymldist/wacki.nrosrc/platform/switch/switch.csrc/platform/switch/storage_switch.cplat_save_read/writewithfsdevCommitDevice("sdmc")src/platform/switch/data_root_switch.csdmc:/switch/wacki/…)src/platform/switch/embedded_wacki_pe_stub.cassets/icons/wacki-switch.jpg.nroChanges to shared files
All changes are backwards-compatible and benefit other platforms too.
src/platform/sdl/system_sdl.c— added#ifdef __SWITCH__block(mirrors the existing
#ifdef __ANDROID__block):mkdir+chdirtosdmc:/switch/wacki/beforeConfigLoad(). hbmenu/nx-hbloader does notguarantee a consistent
cwdacross launches (unlike a desktop shell or ahandheld launcher script that
cds into the ROM folder), so without thisWacki.savandwacki.cfgland in a different place every relaunch.src/platform/sdl/gamepad_sdl.c— two generic additions:SDL_GameControllerGetType():automatically swaps A/B and X/Y constants to match Nintendo's physical
diamond (where SDL's
BUTTON_A= south position = physical B on aJoy-Con). Works for any Nintendo pad on any SDL target (Pro Controller
paired to a PortMaster device over Bluetooth gets the same correct
mapping). On
__SWITCH__always active without a type query.X(west) →platform_video_toggle_aspect_mode(),BACK/MINUS→platform_touch_cycle_mode(). Both are no-ops ontargets where they don't apply.
src/platform/sdl/video_sdl.c—g_aspect_mode("stretch"/"4:3"): in"4:3"mode SDL gets logical size 640×480 andletterboxes automatically on a non-4:3 output. In
"stretch"modeSDL_RenderSetLogicalSizeis disabled (0, 0) and the texture isblitted with an explicit full-window
SDL_Rect— SDL'sRenderSetLogicalSizealways preserves AR (per its own docs), sodisproportionate fill requires bypassing it. Mouse coordinates are
manually scaled in stretch mode so the engine's hit-tests still work.
src/platform/sdl/platform_sdl.c—g_touch_mode(
"absolute"/"relative"/"off"):"absolute"(default): SDL's built-inHINT_TOUCH_MOUSE_EVENTSON —tap = click + position, two-finger tap = RMB. Zero extra code.
"relative":HINT_TOUCH_MOUSE_EVENTSOFF, whole panel as a laptoptouchpad — delta between samples moves the cursor, touch never clicks.
Designed to be reusable for future touch-capable ports (PS Vita, Wii U).
"off": ignoresSDL_FINGER*entirely.Cycled at runtime (MINUS/BACK on pad, F8 on desktop), persisted in
wacki.cfg.src/config.c— two new keys:aspect_mode=stretch|4:3andtouch_mode=absolute|relative|off.wacki.cfgis now createdautomatically on first launch on every platform (previously only the
desktop first-run picker path called
ConfigSave(); handheld targetsnever showed that picker so the file never materialised).
Makefile— three small changes:EMBEDDED_PE_SRC ?=+ifeqguard around the codegen rule — letsmk/switch.mkoverride it with the empty stub without triggering adata/WACKI.EXE missingbuild failure..DEFAULT_GOAL := all— without this,make TARGET=switchsilentlybuilt only the empty
dist/directory (because$(DIST):is definedbefore
all:in the file) and exited with code 0.switchtarget registered in.PHONY+./tools/build-switch.shwrapper.
Button mapping (Joy-Con / Pro Controller)
Why WACKI.EXE is loaded at runtime
The public repo and CI cannot embed the copyrighted
.rdata/.datasections from
WACKI.EXE.src/pe_loader.c'sPeLoaderReadalreadychecks a dynamically-loaded image (set by
PeLoaderInit) before fallingback to the embedded slice table, so the hooks provider
(
src/platform/switch/switch.c) simply callsPeLoaderInit()with theplayer's own file from the SD card — the rest of the engine is completely
unmodified.