From 3da33bdcbe42942d19e9ddfdaee42c2bf90f77f7 Mon Sep 17 00:00:00 2001 From: Spodi Date: Tue, 24 Oct 2023 03:10:32 +0200 Subject: [PATCH 1/5] Fix cropping on dpi >100% (#358) Was triggered by my keyboard resize fix. --- src/graphic/Fast3D/gfx_direct3d11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphic/Fast3D/gfx_direct3d11.cpp b/src/graphic/Fast3D/gfx_direct3d11.cpp index 3bcc78c84..9593b107b 100644 --- a/src/graphic/Fast3D/gfx_direct3d11.cpp +++ b/src/graphic/Fast3D/gfx_direct3d11.cpp @@ -891,7 +891,7 @@ static void gfx_d3d11_update_framebuffer_parameters(int fb_id, uint32_t width, u if (desc1.Width != width || desc1.Height != height) { fb.render_target_view.Reset(); tex.texture.Reset(); - ThrowIfFailed(swap_chain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, desc1.Flags)); + ThrowIfFailed(swap_chain->ResizeBuffers(0, width, height, DXGI_FORMAT_UNKNOWN, desc1.Flags)); } ThrowIfFailed( swap_chain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)tex.texture.ReleaseAndGetAddressOf())); From c75ff3653f699cb1a8c017b10e4b3986259d8cf0 Mon Sep 17 00:00:00 2001 From: Adam Bird Date: Mon, 6 Nov 2023 19:28:30 -0500 Subject: [PATCH 2/5] fix overflow in input window (#361) --- src/window/gui/InputEditorWindow.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/window/gui/InputEditorWindow.cpp b/src/window/gui/InputEditorWindow.cpp index 40292e883..c1be2bc30 100644 --- a/src/window/gui/InputEditorWindow.cpp +++ b/src/window/gui/InputEditorWindow.cpp @@ -377,15 +377,17 @@ void InputEditorWindow::DrawControllerSchema() { DrawButton("Left", BTN_CLEFT, mCurrentPort, &mBtnReading); DrawButton("Right", BTN_CRIGHT, mCurrentPort, &mBtnReading); ImGui::Dummy(ImVec2(0, 5)); + EndGroupPanel(0.0f); + + ImGui::SetCursorPosX(cursor.x); #ifdef __SWITCH__ - EndGroupPanel(isKeyboard ? 53.0f : 122.0f); + ImGui::SetCursorPosY(cursor.y + 167); +#elif defined(__WIIU__) + ImGui::SetCursorPosY(cursor.y + 120 * 2); #else - EndGroupPanel(isKeyboard ? 53.0f : 94.0f); + ImGui::SetCursorPosY(cursor.y + 120); #endif - ImGui::SetCursorPosX(cursor.x); - ImGui::SameLine(); - BeginGroupPanel("Options", ImVec2(158, 20)); float cursorX = ImGui::GetCursorPosX() + 5; ImGui::SetCursorPosX(cursorX); @@ -427,6 +429,7 @@ void InputEditorWindow::DrawControllerSchema() { "%s", "How near in degrees to a virtual notch angle you have to be for it to snap to nearest notch"); } + ImGui::SetCursorPosX(cursorX); if (ImGui::Checkbox("Stick Deadzones For Buttons", &profile->UseStickDeadzoneForButtons)) { Context::GetInstance()->GetControlDeck()->SaveSettings(); } @@ -455,10 +458,10 @@ void InputEditorWindow::DrawElement() { ImVec2 maxSize = ImVec2(2200, 505); #elif defined(__WIIU__) ImVec2 minSize = ImVec2(641 * 2, 250 * 2); - ImVec2 maxSize = ImVec2(1200 * 2, 330 * 2); + ImVec2 maxSize = ImVec2(1200 * 2, 360 * 2); #else ImVec2 minSize = ImVec2(641, 250); - ImVec2 maxSize = ImVec2(1200, 330); + ImVec2 maxSize = ImVec2(1200, 360); #endif ImGui::SetNextWindowSizeConstraints(minSize, maxSize); From c6ac929530198925eef0887e56b02157f79a896a Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Mon, 6 Nov 2023 18:56:05 -0800 Subject: [PATCH 3/5] Removes Pulse Audio. Config values will be migrated to sdl audio back end. (#356) (#362) * Removes Pulse Audio. Config values will be migrated to sdl audio backend. #311 * Removes PulseAudio.h from classes.h Co-authored-by: Kenix3 --- include/libultraship/classes.h | 4 +- src/CMakeLists.txt | 7 +- src/audio/Audio.cpp | 5 - src/audio/AudioPlayer.h | 2 - src/audio/PulseAudioPlayer.cpp | 191 --------------------------------- src/audio/PulseAudioPlayer.h | 28 ----- src/config/Config.cpp | 9 +- 7 files changed, 5 insertions(+), 241 deletions(-) delete mode 100644 src/audio/PulseAudioPlayer.cpp delete mode 100644 src/audio/PulseAudioPlayer.h diff --git a/include/libultraship/classes.h b/include/libultraship/classes.h index d4e51ff4e..1599a7d94 100644 --- a/include/libultraship/classes.h +++ b/include/libultraship/classes.h @@ -31,9 +31,7 @@ #include "utils/binarytools/BinaryWriter.h" #include "audio/Audio.h" #include "audio/AudioPlayer.h" -#if defined(__linux__) || defined(__BSD__) -#include "audio/PulseAudioPlayer.h" -#elif defined(_WIN32) +#if defined(_WIN32) #include "audio/WasapiAudioPlayer.h" #endif #include "audio/SDLAudioPlayer.h" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de362932b..bf0e31345 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,16 +29,11 @@ set(Source_Files__Audio ${CMAKE_CURRENT_SOURCE_DIR}/audio/AudioPlayer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/audio/SDLAudioPlayer.h ${CMAKE_CURRENT_SOURCE_DIR}/audio/SDLAudioPlayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/audio/PulseAudioPlayer.h - ${CMAKE_CURRENT_SOURCE_DIR}/audio/PulseAudioPlayer.cpp ) if (CMAKE_SYSTEM_NAME STREQUAL "Windows") list(APPEND Source_Files__Audio ${CMAKE_CURRENT_SOURCE_DIR}/audio/WasapiAudioPlayer.h) list(APPEND Source_Files__Audio ${CMAKE_CURRENT_SOURCE_DIR}/audio/WasapiAudioPlayer.cpp) -elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") - list(APPEND Source_Files__Audio ${CMAKE_CURRENT_SOURCE_DIR}/audio/PulseAudioPlayer.h) - list(APPEND Source_Files__Audio ${CMAKE_CURRENT_SOURCE_DIR}/audio/PulseAudioPlayer.cpp) endif() source_group("audio" FILES ${Source_Files__Audio}) @@ -127,7 +122,7 @@ set(Source_Files__Log ${CMAKE_CURRENT_SOURCE_DIR}/log/luslog.cpp ) -source_group("Log" FILES ${Source_Files__Log}) +source_group("log" FILES ${Source_Files__Log}) target_sources(libultraship PRIVATE ${Source_Files__Log} ${Source_Files__Log__SPDLog}) diff --git a/src/audio/Audio.cpp b/src/audio/Audio.cpp index 64fa82619..9fad4aff9 100644 --- a/src/audio/Audio.cpp +++ b/src/audio/Audio.cpp @@ -16,11 +16,6 @@ void Audio::InitAudioPlayer() { case AudioBackend::WASAPI: mAudioPlayer = std::make_shared(); break; -#endif -#if defined(__linux) - case AudioBackend::PULSE: - mAudioPlayer = std::make_shared(); - break; #endif default: mAudioPlayer = std::make_shared(); diff --git a/src/audio/AudioPlayer.h b/src/audio/AudioPlayer.h index d9d9f8e12..bab6e1c77 100644 --- a/src/audio/AudioPlayer.h +++ b/src/audio/AudioPlayer.h @@ -31,8 +31,6 @@ class AudioPlayer { #ifdef _WIN32 #include "WasapiAudioPlayer.h" -#elif defined(__linux) -#include "PulseAudioPlayer.h" #endif #include "SDLAudioPlayer.h" diff --git a/src/audio/PulseAudioPlayer.cpp b/src/audio/PulseAudioPlayer.cpp deleted file mode 100644 index 5ebc291c8..000000000 --- a/src/audio/PulseAudioPlayer.cpp +++ /dev/null @@ -1,191 +0,0 @@ -#if defined(__linux__) || defined(__BSD__) - -#include "PulseAudioPlayer.h" -#include "Context.h" -#include - -namespace LUS { -static void PasContextStateCb(pa_context* c, void* userData) { - switch (pa_context_get_state(c)) { - case PA_CONTEXT_READY: - case PA_CONTEXT_TERMINATED: - case PA_CONTEXT_FAILED: - *(bool*)userData = true; - break; - default: - break; - } -} - -static void PasStreamStateCb(pa_stream* s, void* userData) { - switch (pa_stream_get_state(s)) { - case PA_STREAM_READY: - case PA_STREAM_FAILED: - case PA_STREAM_TERMINATED: - *(bool*)userData = true; - break; - default: - break; - } -} - -static void PasStreamWriteCb(pa_stream* s, size_t length, void* userData) { -} - -static void PasUpdateComplete(pa_stream* stream, int success, void* userData) { - *(bool*)userData = true; -} - -static void PasWriteComplete(void* userData) { - *(bool*)userData = true; -} - -PulseAudioPlayer::PulseAudioPlayer() : AudioPlayer() { -} - -bool PulseAudioPlayer::DoInit() { - bool done = false; - const pa_buffer_attr* appliedAttr = nullptr; - - // Create mainloop - mMainLoop = pa_mainloop_new(); - if (mMainLoop == NULL) { - return false; - } - - // Create context and connect - mContext = - pa_context_new(pa_mainloop_get_api(mMainLoop), ("libultraship - " + Context::GetInstance()->GetName()).c_str()); - if (mContext == NULL) { - goto fail; - } - - pa_context_set_state_callback(mContext, PasContextStateCb, &done); - - if (pa_context_connect(mContext, NULL, PA_CONTEXT_NOFLAGS, NULL) < 0) { - goto fail; - } - - while (!done) { - pa_mainloop_iterate(mMainLoop, true, NULL); - } - pa_context_set_state_callback(mContext, NULL, NULL); - if (pa_context_get_state(mContext) != PA_CONTEXT_READY) { - goto fail; - } - - // Create stream - pa_sample_spec ss; - ss.format = PA_SAMPLE_S16LE; - ss.rate = this->GetSampleRate(); - ss.channels = 2; - -#define SAMPLES_HIGH 752 -#define SAMPLES_LOW 720 - - pa_buffer_attr attr; - // set the max length to the desired buffered level, plus - // 3x the high sample rate, which is what the n64 audio engine - // can output at one time, x2 to avoid overflow in case of the - // n64 audio engine running faster than pulseaudio, all multiplied - // by 4 because each sample is 4 bytes - attr.maxlength = (GetDesiredBuffered() + 3 * SAMPLES_HIGH * 2) * 4; - - // slightly more than one double audio update - attr.prebuf = SAMPLES_HIGH * 3 * 1.5 * 4; - - attr.minreq = 222 * 4; - attr.tlength = (GetSampleRate() / 20) * 4; - - // initialize to a value that is deemed sensible by the server - attr.fragsize = (uint32_t)-1; - - mStream = pa_stream_new(mContext, "zelda", &ss, NULL); - if (mStream == NULL) { - goto fail; - } - - done = false; - pa_stream_set_state_callback(mStream, PasStreamStateCb, &done); - pa_stream_set_write_callback(mStream, PasStreamWriteCb, NULL); - if (pa_stream_connect_playback(mStream, NULL, &attr, PA_STREAM_ADJUST_LATENCY, NULL, NULL) < 0) { - goto fail; - } - - while (!done) { - pa_mainloop_iterate(mMainLoop, true, NULL); - } - pa_stream_set_state_callback(mStream, NULL, NULL); - if (pa_stream_get_state(mStream) != PA_STREAM_READY) { - goto fail; - } - - appliedAttr = pa_stream_get_buffer_attr(mStream); - SPDLOG_TRACE("maxlength: {}\ntlength: {}\nprebuf: {}\nminreq: {}\nfragsize: {}\n", appliedAttr->maxlength, - appliedAttr->tlength, appliedAttr->prebuf, appliedAttr->minreq, appliedAttr->fragsize); - mAttr = *appliedAttr; - - return true; - -fail: - if (mStream != NULL) { - pa_stream_unref(mStream); - mStream = NULL; - } - if (mContext != NULL) { - pa_context_disconnect(mContext); - pa_context_unref(mContext); - mContext = NULL; - } - if (mMainLoop != NULL) { - pa_mainloop_free(mMainLoop); - mMainLoop = NULL; - } - - SPDLOG_ERROR("Failed to initialize PulseAudio stream!"); - return false; -} - -int PulseAudioPlayer::Buffered() { - if (mStream == NULL) { - return 0; - } - - bool done = false; - pa_stream_update_timing_info(mStream, PasUpdateComplete, &done); - while (!done) { - pa_mainloop_iterate(mMainLoop, true, NULL); - } - - const pa_timing_info* info = pa_stream_get_timing_info(mStream); - if (info == NULL) { - SPDLOG_ERROR("pa_stream_get_timing_info failed, state is %d\n", pa_stream_get_state(mStream)); - } - return (info->write_index - info->read_index) / 4; -} - -int PulseAudioPlayer::GetDesiredBuffered() { - return 2480; -} - -void PulseAudioPlayer::Play(const uint8_t* buff, size_t len) { - if (mStream == NULL || mContext == NULL || mMainLoop == NULL) { - return; - } - - size_t ws = mAttr.maxlength - Buffered() * 4; - if (ws < len) { - len = ws; - } - if (pa_stream_write_ext_free(mStream, buff, len, PasWriteComplete, &mWriteComplete, 0LL, PA_SEEK_RELATIVE) < 0) { - SPDLOG_ERROR("pa_stream_write failed"); - return; - } - while (!mWriteComplete) { - pa_mainloop_iterate(mMainLoop, true, NULL); - } - mWriteComplete = false; -} -} // namespace LUS - -#endif diff --git a/src/audio/PulseAudioPlayer.h b/src/audio/PulseAudioPlayer.h deleted file mode 100644 index 0870a7e41..000000000 --- a/src/audio/PulseAudioPlayer.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#if defined(__linux__) || defined(__BSD__) - -#include "AudioPlayer.h" -#include - -namespace LUS { -class PulseAudioPlayer : public AudioPlayer { - public: - PulseAudioPlayer(); - - int Buffered() override; - int GetDesiredBuffered() override; - void Play(const uint8_t* buff, size_t len) override; - - protected: - bool DoInit() override; - - private: - pa_context* mContext = nullptr; - pa_stream* mStream = nullptr; - pa_mainloop* mMainLoop = nullptr; - bool mWriteComplete = false; - pa_buffer_attr mAttr = { 0 }; -}; -} // namespace LUS -#endif diff --git a/src/config/Config.cpp b/src/config/Config.cpp index 2952b5155..e6072e856 100644 --- a/src/config/Config.cpp +++ b/src/config/Config.cpp @@ -178,8 +178,10 @@ AudioBackend Config::GetAudioBackend() { return AudioBackend::WASAPI; } + // Migrate pulse player in config to sdl if (backendName == "pulse") { - return AudioBackend::PULSE; + SetAudioBackend(AudioBackend::SDL); + return AudioBackend::SDL; } if (backendName == "sdl") { @@ -190,8 +192,6 @@ AudioBackend Config::GetAudioBackend() { backendName); #ifdef _WIN32 return AudioBackend::WASAPI; -#elif defined(__linux) - return AudioBackend::PULSE; #endif return AudioBackend::SDL; @@ -202,9 +202,6 @@ void Config::SetAudioBackend(AudioBackend backend) { case AudioBackend::WASAPI: SetString("Window.AudioBackend", "wasapi"); break; - case AudioBackend::PULSE: - SetString("Window.AudioBackend", "pulse"); - break; case AudioBackend::SDL: SetString("Window.AudioBackend", "sdl"); break; From 97e7a16bae14e164f85af82d4cbe64b93a7cf5b9 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Mon, 6 Nov 2023 19:05:17 -0800 Subject: [PATCH 4/5] Fix 32 bit (#359) (#363) Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com> --- CMakeLists.txt | 9 +++++++-- extern/ZAPDUtils/CMakeLists.txt | 5 +---- src/debug/CrashHandler.cpp | 14 +++++++------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0b689413..95a9c584b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,13 @@ include(cmake/Utils.cmake) if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND USE_AUTO_VCPKG) include(cmake/automate-vcpkg.cmake) - set(VCPKG_TRIPLET x64-windows-static) - set(VCPKG_TARGET_TRIPLET x64-windows-static) + if ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") + set(VCPKG_TRIPLET x86-windows-static) + set(VCPKG_TARGET_TRIPLET x86-windows-static) + elseif ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") + set(VCPKG_TRIPLET x64-windows-static) + set(VCPKG_TARGET_TRIPLET x64-windows-static) + endif() vcpkg_bootstrap() vcpkg_install_packages(zlib bzip2 sdl2 glew) diff --git a/extern/ZAPDUtils/CMakeLists.txt b/extern/ZAPDUtils/CMakeLists.txt index baf868f91..fcf00fe34 100644 --- a/extern/ZAPDUtils/CMakeLists.txt +++ b/extern/ZAPDUtils/CMakeLists.txt @@ -139,11 +139,8 @@ if(MSVC) ) elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") target_compile_options(${PROJECT_NAME} PRIVATE - $<$: - /O2; - /Ot - > $<$: + /Oi /Gy > /permissive-; diff --git a/src/debug/CrashHandler.cpp b/src/debug/CrashHandler.cpp index 47855e53b..2e9144544 100644 --- a/src/debug/CrashHandler.cpp +++ b/src/debug/CrashHandler.cpp @@ -6,7 +6,7 @@ #ifdef _WIN32 #include #include - +#include #include #include @@ -266,7 +266,7 @@ void CrashHandler::PrintRegisters(CONTEXT* ctx) { sprintf_s(regBuff, std::size(regBuff), "EFLAGS: 0x%08lX", ctx->EFlags); AppendLine(regBuff); -#elif WINDOWS_32_BIT +#elif defined(WINDOWS_32_BIT) sprintf_s(regBuff, std::size(regBuff), "EDI: 0x%08lX", ctx->Edi); AppendLine(regBuff); @@ -308,7 +308,7 @@ void CrashHandler::PrintStack(CONTEXT* ctx) { #if defined(_M_AMD64) STACKFRAME64 stack; memset(&stack, 0, sizeof(STACKFRAME64)); -#elif WINDOWS_32_BIT +#elif defined(WINDOWS_32_BIT) STACKFRAME stack; memset(&stack, 0, sizeof(STACKFRAME)); stack.AddrPC.Offset = (*ctx).Eip; @@ -338,7 +338,7 @@ void CrashHandler::PrintStack(CONTEXT* ctx) { constexpr DWORD machineType = #if defined(_M_AMD64) IMAGE_FILE_MACHINE_AMD64; -#elif WINDOWS_32_BIT +#elif defined(WINDOWS_32_BIT) IMAGE_FILE_MACHINE_I386; #endif @@ -355,7 +355,7 @@ void CrashHandler::PrintStack(CONTEXT* ctx) { #if defined(_M_AMD64) IMAGEHLP_LINE64 line; line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); -#elif WINDOWS_32_BIT +#elif defined(WINDOWS_32_BIT) IMAGEHLP_LINE line; line.SizeOfStruct = sizeof(IMAGEHLP_LINE); #endif @@ -389,7 +389,7 @@ void CrashHandler::PrintStack(CONTEXT* ctx) { spdlog::shutdown(); } -extern "C" LONG seh_filter(struct _EXCEPTION_POINTERS* ex) { +extern "C" LONG WINAPI seh_filter(PEXCEPTION_POINTERS ex) { char exceptionString[20]; std::shared_ptr crashHandler = LUS::Context::GetInstance()->GetCrashHandler(); @@ -428,7 +428,7 @@ CrashHandler::CrashHandler() { sigaction(SIGTERM, &shutdownAction, nullptr); sigaction(SIGQUIT, &shutdownAction, nullptr); sigaction(SIGKILL, &shutdownAction, nullptr); -#elif _WIN32 +#elif defined(_WIN32) SetUnhandledExceptionFilter(seh_filter); #endif } From 07fc296b056e477924d44bb3270d56e410690634 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Mon, 6 Nov 2023 19:13:52 -0800 Subject: [PATCH 5/5] ci: build on push to all branches (#364) --- .github/workflows/build-validation.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-validation.yml b/.github/workflows/build-validation.yml index bdb46dc5f..f858a735a 100644 --- a/.github/workflows/build-validation.yml +++ b/.github/workflows/build-validation.yml @@ -1,8 +1,6 @@ name: build-validation on: push: - branches: - - 'main' pull_request: concurrency: group: ${{ github.workflow }}-${{ github.ref }}