diff --git a/.github/workflows/switch.yml b/.github/workflows/switch.yml index 3dec1be14c..2d7d340637 100644 --- a/.github/workflows/switch.yml +++ b/.github/workflows/switch.yml @@ -6,7 +6,7 @@ jobs: build: name: ${{ matrix.config.name }} runs-on: ubuntu-latest - container: devkitpro/devkita64:20220128 + container: devkitpro/devkita64:latest strategy: matrix: diff --git a/core/linux/common.cpp b/core/linux/common.cpp index c8af1387c1..7f0e74a227 100644 --- a/core/linux/common.cpp +++ b/core/linux/common.cpp @@ -127,7 +127,7 @@ double os_GetSeconds() return a.tv_sec-tvs_base+a.tv_usec/1000000.0; } -#if !defined(__unix__) && !defined(LIBRETRO) +#if !defined(__unix__) && !defined(LIBRETRO) && !defined(__SWITCH__) [[noreturn]] void os_DebugBreak() { __builtin_trap(); diff --git a/core/linux/libnx_vmem.cpp b/core/linux/libnx_vmem.cpp index 944386049f..0cbfa5cbc6 100644 --- a/core/linux/libnx_vmem.cpp +++ b/core/linux/libnx_vmem.cpp @@ -335,4 +335,11 @@ void __libnx_exception_handler(ThreadExceptionDump *ctx) } } #endif // TARGET_NO_EXCEPTIONS + +#ifndef LIBRETRO +[[noreturn]] void os_DebugBreak() +{ + diagAbortWithResult(MAKERESULT(350, 1)); +} +#endif #endif // __SWITCH__ diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 1cf361c8d5..b78f199078 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -198,7 +198,7 @@ void gui_initFonts() ImGui::GetStyle().TabRounding = 0; ImGui::GetStyle().ItemSpacing = ImVec2(8, 8); // from 8,4 ImGui::GetStyle().ItemInnerSpacing = ImVec2(4, 6); // from 4,4 -#if defined(__ANDROID__) || defined(TARGET_IPHONE) +#if defined(__ANDROID__) || defined(TARGET_IPHONE) || defined(__SWITCH__) ImGui::GetStyle().TouchExtraPadding = ImVec2(1, 1); // from 0,0 #endif if (settings.display.uiScale > 1) @@ -378,7 +378,7 @@ static void gui_newFrame() else io.AddMousePosEvent(mouseX, mouseY); static bool delayTouch; -#if defined(__ANDROID__) || defined(TARGET_IPHONE) +#if defined(__ANDROID__) || defined(TARGET_IPHONE) || defined(__SWITCH__) // Delay touch by one frame to allow widgets to be hovered before click // This is required for widgets using ImGuiButtonFlags_AllowItemOverlap such as TabItem's if (!delayTouch && (mouseButtons & (1 << 0)) != 0 && !io.MouseDown[ImGuiMouseButton_Left]) @@ -2798,7 +2798,7 @@ static void gui_display_content() ImGui::Unindent(10 * settings.display.uiScale); static ImGuiTextFilter filter; -#if !defined(__ANDROID__) && !defined(TARGET_IPHONE) && !defined(TARGET_UWP) +#if !defined(__ANDROID__) && !defined(TARGET_IPHONE) && !defined(TARGET_UWP) && !defined(__SWITCH__) ImGui::SameLine(0, 32 * settings.display.uiScale); filter.Draw("Filter"); #endif @@ -2806,10 +2806,17 @@ static void gui_display_content() { #ifdef TARGET_UWP void gui_load_game(); - ImGui::SameLine(ImGui::GetContentRegionMax().x - ImGui::CalcTextSize("Settings").x - ImGui::GetStyle().FramePadding.x * 4.0f - ImGui::GetStyle().ItemSpacing.x - ImGui::CalcTextSize("Load...").x); + ImGui::SameLine(ImGui::GetContentRegionMax().x - ImGui::CalcTextSize("Settings").x + - ImGui::GetStyle().FramePadding.x * 4.0f - ImGui::GetStyle().ItemSpacing.x - ImGui::CalcTextSize("Load...").x); if (ImGui::Button("Load...")) gui_load_game(); ImGui::SameLine(); +#elif defined(__SWITCH__) + ImGui::SameLine(ImGui::GetContentRegionMax().x - ImGui::CalcTextSize("Settings").x + - ImGui::GetStyle().FramePadding.x * 4.0f - ImGui::GetStyle().ItemSpacing.x - ImGui::CalcTextSize("Exit").x); + if (ImGui::Button("Exit")) + dc_exit(); + ImGui::SameLine(); #else ImGui::SameLine(ImGui::GetContentRegionMax().x - ImGui::CalcTextSize("Settings").x - ImGui::GetStyle().FramePadding.x * 2.0f); #endif diff --git a/core/sdl/sdl.cpp b/core/sdl/sdl.cpp index d32a478a66..e65383575f 100644 --- a/core/sdl/sdl.cpp +++ b/core/sdl/sdl.cpp @@ -471,6 +471,38 @@ void input_sdl_handle() case SDL_DROPFILE: gui_start_game(event.drop.file); break; + + // Switch touchscreen support + case SDL_FINGERDOWN: + case SDL_FINGERMOTION: + { + int x = event.tfinger.x * settings.display.width; + int y = event.tfinger.y * settings.display.height; + gui_set_mouse_position(x, y); + if (mouseCaptured && gameRunning && event.type == SDL_FINGERMOTION) + { + int dx = event.tfinger.dx * settings.display.width; + int dy = event.tfinger.dy * settings.display.height; + sdl_mouse->setRelPos(dx, dy); + } + else + sdl_mouse->setAbsPos(x, y); + if (event.type == SDL_FINGERDOWN) { + sdl_mouse->setButton(Mouse::LEFT_BUTTON, true); + gui_set_mouse_button(0, true); + } + } + break; + case SDL_FINGERUP: + { + int x = event.tfinger.x * settings.display.width; + int y = event.tfinger.y * settings.display.height; + gui_set_mouse_position(x, y); + gui_set_mouse_button(0, false); + sdl_mouse->setAbsPos(x, y); + sdl_mouse->setButton(Mouse::LEFT_BUTTON, false); + } + break; } } }