From 0551cef4c64cbaaae08643c5cf91e6c9df4e4c17 Mon Sep 17 00:00:00 2001 From: shinra-electric <50119606+shinra-electric@users.noreply.github.com> Date: Mon, 19 Jan 2026 07:42:05 +0000 Subject: [PATCH 1/8] SwiftUI: Add buttons for switching modes (#93) * Add modes to toolbar * Some fiddling * Make adjustements to placement, add mode var to state object * Update isHandheldMode in the initialiser * Add didSet to isHandheldMode * Work around the issue with the Menu not updating * Remove the dividers from the toolbar items * Use the .toggle() function * Add tooltips to the new buttons --- src/frontend/swiftui/EmulationToolbarItems.swift | 14 ++++++++++++++ src/frontend/swiftui/GameListToolbarItems.swift | 12 ++++++------ src/frontend/swiftui/HydraApp.swift | 11 ++++++++++- src/frontend/swiftui/MenuCommands.swift | 13 ++----------- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/frontend/swiftui/EmulationToolbarItems.swift b/src/frontend/swiftui/EmulationToolbarItems.swift index 3d5d722d..37c0eac1 100644 --- a/src/frontend/swiftui/EmulationToolbarItems.swift +++ b/src/frontend/swiftui/EmulationToolbarItems.swift @@ -28,6 +28,20 @@ struct EmulationToolbarItems: ToolbarContent { isRunning = globalState.emulationContext!.isRunning() } } + + ToolbarItemGroup(placement: .confirmationAction) { + Button("Console Mode", systemImage: "inset.filled.tv") { + globalState.isHandheldMode.toggle() + } + .disabled(!globalState.isHandheldMode) + .help("Change to Console mode") + + Button("Handheld Mode", systemImage: "formfitting.gamecontroller.fill") { + globalState.isHandheldMode.toggle() + } + .disabled(globalState.isHandheldMode) + .help("Change to Handheld mode") + } #else // TODO: options ToolbarItemGroup(placement: .principal) {} diff --git a/src/frontend/swiftui/GameListToolbarItems.swift b/src/frontend/swiftui/GameListToolbarItems.swift index 982c2b03..d83c4910 100644 --- a/src/frontend/swiftui/GameListToolbarItems.swift +++ b/src/frontend/swiftui/GameListToolbarItems.swift @@ -25,16 +25,16 @@ struct GameListToolbarItems: ToolbarContent { var body: some ToolbarContent { #if os(macOS) - ToolbarItem(placement: .principal) { + ToolbarItemGroup(placement: .principal) { Button("List View", systemImage: "list.bullet") { viewMode = ViewMode.list.rawValue - }.disabled(ViewMode(rawValue: viewMode) == .list) - } - - ToolbarItem(placement: .principal) { + } + .disabled(ViewMode(rawValue: viewMode) == .list) + Button("Grid View", systemImage: "rectangle.grid.3x2.fill") { viewMode = ViewMode.grid.rawValue - }.disabled(ViewMode(rawValue: viewMode) == .grid) + } + .disabled(ViewMode(rawValue: viewMode) == .grid) } #endif diff --git a/src/frontend/swiftui/HydraApp.swift b/src/frontend/swiftui/HydraApp.swift index e0615a2c..935fe056 100644 --- a/src/frontend/swiftui/HydraApp.swift +++ b/src/frontend/swiftui/HydraApp.swift @@ -9,10 +9,19 @@ class GlobalState: ObservableObject { @Published var activeGame: Game? = nil @Published var emulationContext: HydraEmulationContext? = nil @Published var isStopping = false + @Published var isHandheldMode: Bool { + didSet { + hydraConfigGetHandheldMode().pointee = isHandheldMode + hydraConfigSerialize() + guard let emulationContext = emulationContext else { return } + emulationContext.notifyOperationModeChanged() + } + } init() { hydraLoaderPluginManagerRefresh() - + isHandheldMode = hydraConfigGetHandheldMode().pointee + let gamePathsOption = hydraConfigGetGamePaths() for i in 0.. Date: Sat, 31 Jan 2026 15:08:41 +0000 Subject: [PATCH 2/8] Initial test --- .github/workflows/ci.yml | 81 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a6c17df..0d182978 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,11 +83,86 @@ jobs: else mv build/bin/Hydra.app image/HydraSDL.app fi - hdiutil create -volname "Hydra" -srcfolder image Hydra-${{ matrix.suffix }} + hdiutil create -volname "Hydra" -srcfolder image Hydra-${{ matrix.suffix }}-arm - name: Upload Artifacts - ${{ matrix.suffix }} uses: actions/upload-artifact@v4 with: - name: Hydra-${{ matrix.suffix }} - path: Hydra-${{ matrix.suffix }}.dmg + name: Hydra-${{ matrix.suffix }}-arm + path: Hydra-${{ matrix.suffix }}-arm.dmg if-no-files-found: error + + macOS: + strategy: + fail-fast: false + matrix: + include: + - suffix: SwiftUI-Release + - suffix: SwiftUI-Debug + - suffix: SDL-Release + - suffix: SDL-Debug + + runs-on: macos-15-intel + + steps: + - name: Set Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + + - name: Checkout Hydra + uses: actions/checkout@v4 + with: + repository: SamoZ256/hydra + submodules: recursive + path: hydra + + - name: Install Dependencies + run: brew install boost fmt sdl3 dylibbundler + + - name: Verify CMake Version + run: cmake --version + + - name: Set Build Flags + run: | + if [[ ${{ matrix.suffix }} == *'Release'* ]]; then + echo "BUILD_MODE=Release" >> $GITHUB_ENV + else + echo "BUILD_MODE=Debug" >> $GITHUB_ENV + fi + if [[ ${{ matrix.suffix }} == *'SwiftUI'* ]]; then + echo "FRONTEND_MODE=SwiftUI" >> $GITHUB_ENV + else + echo "FRONTEND_MODE=SDL3" >> $GITHUB_ENV + fi + + - name: Build Hydra + run: | + cmake hydra -B build \ + -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} \ + -DFRONTEND=${{ env.FRONTEND_MODE }} \ + -DMACOS_BUNDLE=ON \ + -GNinja + ninja -C build + dylibbundler -of -cd -b -x build/bin/Hydra.app/Contents/MacOS/Hydra -d build/bin/Hydra.app/Contents/libs + while install_name_tool -delete_rpath @executable_path/../libs/ build/bin/Hydra.app/Contents/MacOS/Hydra 2>/dev/null; do :; done + install_name_tool -add_rpath @executable_path/../libs/ build/bin/Hydra.app/Contents/MacOS/Hydra + codesign --force --deep --preserve-metadata=entitlements,requirements,flags,runtime --sign - build/bin/Hydra.app/Contents/MacOS/Hydra + + - name: Create Archive + run: | + mkdir image + ln -s /Applications image/Applications + if [[ ${{ matrix.suffix }} == *'SwiftUI'* ]]; then + mv build/bin/Hydra.app image/Hydra.app + else + mv build/bin/Hydra.app image/HydraSDL.app + fi + hdiutil create -volname "Hydra" -srcfolder image Hydra-${{ matrix.suffix }}-x86 + + - name: Upload Artifacts - ${{ matrix.suffix }}-x86 + uses: actions/upload-artifact@v4 + with: + name: Hydra-${{ matrix.suffix }}-x86 + path: Hydra-${{ matrix.suffix }}-x86.dmg + if-no-files-found: error From cdbb4a6db89cc25e5926fcf0fa36b58d01a877ee Mon Sep 17 00:00:00 2001 From: shinra-electric <50119606+shinra-electric@users.noreply.github.com> Date: Sat, 31 Jan 2026 15:10:09 +0000 Subject: [PATCH 3/8] Fix job naming --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d182978..191f006b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ on: - "!**.md" jobs: - macOS: + macOS-arm: strategy: fail-fast: false matrix: @@ -92,7 +92,7 @@ jobs: path: Hydra-${{ matrix.suffix }}-arm.dmg if-no-files-found: error - macOS: + macOS-x86: strategy: fail-fast: false matrix: From da6e9a8ab5c23661aa2774ca858f15c9f6812108 Mon Sep 17 00:00:00 2001 From: shinra-electric <50119606+shinra-electric@users.noreply.github.com> Date: Sat, 31 Jan 2026 15:15:19 +0000 Subject: [PATCH 4/8] Stupid yaml --- .github/workflows/ci.yml | 146 +++++++++++++++++++-------------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 191f006b..fae64046 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,76 +93,76 @@ jobs: if-no-files-found: error macOS-x86: - strategy: - fail-fast: false - matrix: - include: - - suffix: SwiftUI-Release - - suffix: SwiftUI-Debug - - suffix: SDL-Release - - suffix: SDL-Debug - - runs-on: macos-15-intel - - steps: - - name: Set Xcode Version - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable - - - name: Checkout Hydra - uses: actions/checkout@v4 - with: - repository: SamoZ256/hydra - submodules: recursive - path: hydra - - - name: Install Dependencies - run: brew install boost fmt sdl3 dylibbundler - - - name: Verify CMake Version - run: cmake --version - - - name: Set Build Flags - run: | - if [[ ${{ matrix.suffix }} == *'Release'* ]]; then - echo "BUILD_MODE=Release" >> $GITHUB_ENV - else - echo "BUILD_MODE=Debug" >> $GITHUB_ENV - fi - if [[ ${{ matrix.suffix }} == *'SwiftUI'* ]]; then - echo "FRONTEND_MODE=SwiftUI" >> $GITHUB_ENV - else - echo "FRONTEND_MODE=SDL3" >> $GITHUB_ENV - fi - - - name: Build Hydra - run: | - cmake hydra -B build \ - -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} \ - -DFRONTEND=${{ env.FRONTEND_MODE }} \ - -DMACOS_BUNDLE=ON \ - -GNinja - ninja -C build - dylibbundler -of -cd -b -x build/bin/Hydra.app/Contents/MacOS/Hydra -d build/bin/Hydra.app/Contents/libs - while install_name_tool -delete_rpath @executable_path/../libs/ build/bin/Hydra.app/Contents/MacOS/Hydra 2>/dev/null; do :; done - install_name_tool -add_rpath @executable_path/../libs/ build/bin/Hydra.app/Contents/MacOS/Hydra - codesign --force --deep --preserve-metadata=entitlements,requirements,flags,runtime --sign - build/bin/Hydra.app/Contents/MacOS/Hydra - - - name: Create Archive - run: | - mkdir image - ln -s /Applications image/Applications - if [[ ${{ matrix.suffix }} == *'SwiftUI'* ]]; then - mv build/bin/Hydra.app image/Hydra.app - else - mv build/bin/Hydra.app image/HydraSDL.app - fi - hdiutil create -volname "Hydra" -srcfolder image Hydra-${{ matrix.suffix }}-x86 - - - name: Upload Artifacts - ${{ matrix.suffix }}-x86 - uses: actions/upload-artifact@v4 - with: - name: Hydra-${{ matrix.suffix }}-x86 - path: Hydra-${{ matrix.suffix }}-x86.dmg - if-no-files-found: error + strategy: + fail-fast: false + matrix: + include: + - suffix: SwiftUI-Release + - suffix: SwiftUI-Debug + - suffix: SDL-Release + - suffix: SDL-Debug + + runs-on: macos-15-intel + + steps: + - name: Set Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + + - name: Checkout Hydra + uses: actions/checkout@v4 + with: + repository: SamoZ256/hydra + submodules: recursive + path: hydra + + - name: Install Dependencies + run: brew install boost fmt sdl3 dylibbundler + + - name: Verify CMake Version + run: cmake --version + + - name: Set Build Flags + run: | + if [[ ${{ matrix.suffix }} == *'Release'* ]]; then + echo "BUILD_MODE=Release" >> $GITHUB_ENV + else + echo "BUILD_MODE=Debug" >> $GITHUB_ENV + fi + if [[ ${{ matrix.suffix }} == *'SwiftUI'* ]]; then + echo "FRONTEND_MODE=SwiftUI" >> $GITHUB_ENV + else + echo "FRONTEND_MODE=SDL3" >> $GITHUB_ENV + fi + + - name: Build Hydra + run: | + cmake hydra -B build \ + -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} \ + -DFRONTEND=${{ env.FRONTEND_MODE }} \ + -DMACOS_BUNDLE=ON \ + -GNinja + ninja -C build + dylibbundler -of -cd -b -x build/bin/Hydra.app/Contents/MacOS/Hydra -d build/bin/Hydra.app/Contents/libs + while install_name_tool -delete_rpath @executable_path/../libs/ build/bin/Hydra.app/Contents/MacOS/Hydra 2>/dev/null; do :; done + install_name_tool -add_rpath @executable_path/../libs/ build/bin/Hydra.app/Contents/MacOS/Hydra + codesign --force --deep --preserve-metadata=entitlements,requirements,flags,runtime --sign - build/bin/Hydra.app/Contents/MacOS/Hydra + + - name: Create Archive + run: | + mkdir image + ln -s /Applications image/Applications + if [[ ${{ matrix.suffix }} == *'SwiftUI'* ]]; then + mv build/bin/Hydra.app image/Hydra.app + else + mv build/bin/Hydra.app image/HydraSDL.app + fi + hdiutil create -volname "Hydra" -srcfolder image Hydra-${{ matrix.suffix }}-x86 + + - name: Upload Artifacts - ${{ matrix.suffix }} + uses: actions/upload-artifact@v4 + with: + name: Hydra-${{ matrix.suffix }}-x86 + path: Hydra-${{ matrix.suffix }}-x86.dmg + if-no-files-found: error \ No newline at end of file From 0ef71682266373b84727b29925d830d7c46412e2 Mon Sep 17 00:00:00 2001 From: shinra-electric <50119606+shinra-electric@users.noreply.github.com> Date: Sat, 31 Jan 2026 15:27:06 +0000 Subject: [PATCH 5/8] Cleanup --- .github/workflows/ci.yml | 99 +++++++--------------------------------- 1 file changed, 17 insertions(+), 82 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fae64046..3e45c6f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,10 +22,14 @@ jobs: fail-fast: false matrix: include: - - suffix: SwiftUI-Release - - suffix: SwiftUI-Debug - - suffix: SDL-Release - - suffix: SDL-Debug + - suffix: SwiftUI-Release-arm + - suffix: SwiftUI-Debug-arm + - suffix: SDL-Release-arm + - suffix: SDL-Debug-arm + - suffix: SwiftUI-Release-x86 + - suffix: SwiftUI-Debug-x86 + - suffix: SDL-Release-x86 + - suffix: SDL-Debug-x86 runs-on: macos-15 @@ -60,85 +64,16 @@ jobs: else echo "FRONTEND_MODE=SDL3" >> $GITHUB_ENV fi - - - name: Build Hydra - run: | - cmake hydra -B build \ - -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} \ - -DFRONTEND=${{ env.FRONTEND_MODE }} \ - -DMACOS_BUNDLE=ON \ - -GNinja - ninja -C build - dylibbundler -of -cd -b -x build/bin/Hydra.app/Contents/MacOS/Hydra -d build/bin/Hydra.app/Contents/libs - while install_name_tool -delete_rpath @executable_path/../libs/ build/bin/Hydra.app/Contents/MacOS/Hydra 2>/dev/null; do :; done - install_name_tool -add_rpath @executable_path/../libs/ build/bin/Hydra.app/Contents/MacOS/Hydra - codesign --force --deep --preserve-metadata=entitlements,requirements,flags,runtime --sign - build/bin/Hydra.app/Contents/MacOS/Hydra - - - name: Create Archive - run: | - mkdir image - ln -s /Applications image/Applications - if [[ ${{ matrix.suffix }} == *'SwiftUI'* ]]; then - mv build/bin/Hydra.app image/Hydra.app + if [[ ${{ matrix.suffix }} == *'x86'* ]]; then + echo "ARCH=x86_64" >> $GITHUB_ENV else - mv build/bin/Hydra.app image/HydraSDL.app + echo "ARCH=arm64" >> $GITHUB_ENV fi - hdiutil create -volname "Hydra" -srcfolder image Hydra-${{ matrix.suffix }}-arm - - - name: Upload Artifacts - ${{ matrix.suffix }} - uses: actions/upload-artifact@v4 - with: - name: Hydra-${{ matrix.suffix }}-arm - path: Hydra-${{ matrix.suffix }}-arm.dmg - if-no-files-found: error - macOS-x86: - strategy: - fail-fast: false - matrix: - include: - - suffix: SwiftUI-Release - - suffix: SwiftUI-Debug - - suffix: SDL-Release - - suffix: SDL-Debug - - runs-on: macos-15-intel - - steps: - - name: Set Xcode Version - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable - - - name: Checkout Hydra - uses: actions/checkout@v4 - with: - repository: SamoZ256/hydra - submodules: recursive - path: hydra - - - name: Install Dependencies - run: brew install boost fmt sdl3 dylibbundler - - - name: Verify CMake Version - run: cmake --version - - - name: Set Build Flags - run: | - if [[ ${{ matrix.suffix }} == *'Release'* ]]; then - echo "BUILD_MODE=Release" >> $GITHUB_ENV - else - echo "BUILD_MODE=Debug" >> $GITHUB_ENV - fi - if [[ ${{ matrix.suffix }} == *'SwiftUI'* ]]; then - echo "FRONTEND_MODE=SwiftUI" >> $GITHUB_ENV - else - echo "FRONTEND_MODE=SDL3" >> $GITHUB_ENV - fi - - name: Build Hydra run: | cmake hydra -B build \ + -DCMAKE_OSX_ARCHITECTURES=${{ env.ARCH }} \ -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} \ -DFRONTEND=${{ env.FRONTEND_MODE }} \ -DMACOS_BUNDLE=ON \ @@ -148,7 +83,7 @@ jobs: while install_name_tool -delete_rpath @executable_path/../libs/ build/bin/Hydra.app/Contents/MacOS/Hydra 2>/dev/null; do :; done install_name_tool -add_rpath @executable_path/../libs/ build/bin/Hydra.app/Contents/MacOS/Hydra codesign --force --deep --preserve-metadata=entitlements,requirements,flags,runtime --sign - build/bin/Hydra.app/Contents/MacOS/Hydra - + - name: Create Archive run: | mkdir image @@ -158,11 +93,11 @@ jobs: else mv build/bin/Hydra.app image/HydraSDL.app fi - hdiutil create -volname "Hydra" -srcfolder image Hydra-${{ matrix.suffix }}-x86 - + hdiutil create -volname "Hydra" -srcfolder image Hydra-${{ matrix.suffix }} + - name: Upload Artifacts - ${{ matrix.suffix }} uses: actions/upload-artifact@v4 with: - name: Hydra-${{ matrix.suffix }}-x86 - path: Hydra-${{ matrix.suffix }}-x86.dmg + name: Hydra-${{ matrix.suffix }} + path: Hydra-${{ matrix.suffix }}.dmg if-no-files-found: error \ No newline at end of file From 02187c57e891ae0a7dcc2124e769b8a37d8e771a Mon Sep 17 00:00:00 2001 From: shinra-electric <50119606+shinra-electric@users.noreply.github.com> Date: Sat, 31 Jan 2026 15:27:57 +0000 Subject: [PATCH 6/8] Revert job name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e45c6f2..f08bda9c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ on: - "!**.md" jobs: - macOS-arm: + macOS: strategy: fail-fast: false matrix: From 7041ad80eaca24ed8b207736b61ab9f244e7ee91 Mon Sep 17 00:00:00 2001 From: shinra-electric <50119606+shinra-electric@users.noreply.github.com> Date: Sat, 31 Jan 2026 15:32:14 +0000 Subject: [PATCH 7/8] Rename the matrices so they sort better --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f08bda9c..8149e1fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,14 +22,14 @@ jobs: fail-fast: false matrix: include: - - suffix: SwiftUI-Release-arm - - suffix: SwiftUI-Debug-arm - - suffix: SDL-Release-arm - - suffix: SDL-Debug-arm - - suffix: SwiftUI-Release-x86 - - suffix: SwiftUI-Debug-x86 - - suffix: SDL-Release-x86 - - suffix: SDL-Debug-x86 + - suffix: Arm-SwiftUI-Release + - suffix: Arm-SwiftUI-Debug + - suffix: Arm-SDL-Release + - suffix: Arm-SDL-Debug + - suffix: x86-SwiftUI-Release + - suffix: x86-SwiftUI-Debug + - suffix: x86-SDL-Release + - suffix: x86-SDL-Debug runs-on: macos-15 From 1042e17b5eca4de339cdbfe4fd6ba020d6c050ff Mon Sep 17 00:00:00 2001 From: shinra-electric <50119606+shinra-electric@users.noreply.github.com> Date: Sat, 31 Jan 2026 15:36:23 +0000 Subject: [PATCH 8/8] Small formatting fix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8149e1fa..303d86d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,4 +100,4 @@ jobs: with: name: Hydra-${{ matrix.suffix }} path: Hydra-${{ matrix.suffix }}.dmg - if-no-files-found: error \ No newline at end of file + if-no-files-found: error