diff --git a/.github/linux/appimage.sh b/.github/linux/appimage.sh index c50074d..807b1f7 100755 --- a/.github/linux/appimage.sh +++ b/.github/linux/appimage.sh @@ -20,6 +20,7 @@ chmod a+x linuxdeploy* mkdir -p AppDir/usr/bin cp Zelda64Recompiled AppDir/usr/bin/ cp -r assets/ AppDir/usr/bin/ +cp gamecontrollerdb.txt AppDir/usr/bin/ cp icons/512.png AppDir/Zelda64Recompiled.png cp .github/linux/Zelda64Recompiled.desktop AppDir/ diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 9c9d8fc..6d77e7c 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -85,7 +85,7 @@ jobs: run: | mv cmake-build/Zelda64Recompiled Zelda64Recompiled rm -rf assets/scss - tar -czf Zelda64Recompiled.tar.gz Zelda64Recompiled assets/ + tar -czf Zelda64Recompiled.tar.gz Zelda64Recompiled assets/ gamecontrollerdb.txt - name: Archive Zelda64Recomp uses: actions/upload-artifact@v3 with: @@ -174,7 +174,7 @@ jobs: run: | mv cmake-build/Zelda64Recompiled Zelda64Recompiled rm -rf assets/scss - tar -czf Zelda64Recompiled.tar.gz Zelda64Recompiled assets/ + tar -czf Zelda64Recompiled.tar.gz Zelda64Recompiled assets/ gamecontrollerdb.txt - name: Archive Zelda64Recomp uses: actions/upload-artifact@v4 with: @@ -267,3 +267,4 @@ jobs: dxil.dll SDL2.dll assets/ + gamecontrollerdb.txt diff --git a/.gitignore b/.gitignore index a718c25..6ff3307 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,6 @@ node_modules/ # Recompiler Linux binary N64Recomp .DS_Store + +# Controller mappings file +gamecontrollerdb.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 26bd27f..daee551 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,8 +115,19 @@ add_custom_command(OUTPUT DEPENDS ${CMAKE_SOURCE_DIR}/patches/patches.bin ) +# Download controller db file for controller support via SDL2 +set(GAMECONTROLLERDB_COMMIT "b1e4090b3d4266e55feb0793efa35792e05faf66") +set(GAMECONTROLLERDB_URL "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/${GAMECONTROLLERDB_COMMIT}/gamecontrollerdb.txt") + +file(DOWNLOAD ${GAMECONTROLLERDB_URL} ${CMAKE_SOURCE_DIR}/gamecontrollerdb.txt + TLS_VERIFY ON) + +add_custom_target(DownloadGameControllerDB + DEPENDS ${CMAKE_SOURCE_DIR}/gamecontrollerdb.txt) + # Main executable add_executable(Zelda64Recompiled) +add_dependencies(Zelda64Recompiled DownloadGameControllerDB) # Generate mm_shader_cache.c from the MM shader cache if it exists if (EXISTS ${CMAKE_SOURCE_DIR}/shadercache/mm_shader_cache.bin) @@ -312,7 +323,7 @@ else() endif() build_vertex_shader(Zelda64Recompiled "shaders/InterfaceVS.hlsl" "shaders/InterfaceVS.hlsl") -build_pixel_shader (Zelda64Recompiled "shaders/InterfacePS.hlsl" "shaders/InterfacePS.hlsl") +build_pixel_shader(Zelda64Recompiled "shaders/InterfacePS.hlsl" "shaders/InterfacePS.hlsl") target_sources(Zelda64Recompiled PRIVATE ${SOURCES}) diff --git a/src/main/main.cpp b/src/main/main.cpp index b28f19c..bea39a4 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -375,6 +375,11 @@ int main(int argc, char** argv) { SDL_InitSubSystem(SDL_INIT_AUDIO); reset_audio(48000); + // Source controller mappings file + if (SDL_GameControllerAddMappingsFromFile("gamecontrollerdb.txt") < 0) { + fprintf(stderr, "Failed to load controller mappings: %s\n", SDL_GetError()); + } + // Register supported games and patches for (const auto& game : supported_games) { recomp::register_game(game);