From 2ea377cba1ac0b79e4b52a9cde80cefdbc57e6f3 Mon Sep 17 00:00:00 2001 From: BearOso Date: Tue, 8 Aug 2023 16:15:49 -0500 Subject: [PATCH] Qt: More windows cleaning. --- port.h | 12 +++- qt/CMakeLists.txt | 89 ++++++++++++------------- qt/src/EmuApplication.cpp | 7 +- qt/src/resources/snes9x-qt.exe.manifest | 10 +++ qt/src/resources/snes9x_icon.rc | 1 - qt/src/resources/snes9x_win32.rc | 29 ++++++++ 6 files changed, 95 insertions(+), 53 deletions(-) create mode 100644 qt/src/resources/snes9x-qt.exe.manifest delete mode 100644 qt/src/resources/snes9x_icon.rc create mode 100644 qt/src/resources/snes9x_win32.rc diff --git a/port.h b/port.h index 25ae19f7..bdd18336 100644 --- a/port.h +++ b/port.h @@ -124,9 +124,15 @@ typedef size_t pint; #define S9xDisplayString DisplayStringFromBottom #ifdef __WIN32__ -#define snprintf _snprintf -#define strcasecmp stricmp -#define strncasecmp strnicmp +#ifndef snprintf + #define snprintf _snprintf +#endif +#ifndef strcasecmp + #define strcasecmp stricmp +#endif +#ifndef strncasecmp + #define strncasecmp strnicmp +#endif #endif // __WIN32__ #if defined(__DJGPP) || defined(__WIN32__) diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index c1c6c0d9..b54d6c2c 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -11,11 +11,6 @@ set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) set(CMAKE_GLOBAL_AUTOGEN_TARGET ON) - -if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") -set(CMAKE_PREFIX_PATH "../external/qt6-mingw-clang-bin") -endif() - set(DEFINES SNES9X_QT) set(SNES9X_CORE_SOURCES ../fxinst.cpp @@ -81,21 +76,55 @@ add_library(snes9x-core ${SNES9X_CORE_SOURCES}) target_include_directories(snes9x-core PRIVATE ../) target_compile_definitions(snes9x-core PRIVATE ZLIB HAVE_STDINT_H ALLOW_CPU_OVERCLOCK) - +if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + set(CMAKE_PREFIX_PATH "../external/qt6-mingw-clang-bin") +endif() find_package(Qt6 REQUIRED COMPONENTS Widgets Gui) +list(APPEND LIBS Qt6::Widgets Qt6::Gui) +list(APPEND INCLUDES ${Qt6Gui_PRIVATE_INCLUDE_DIRS}) + find_package(PkgConfig REQUIRED) pkg_check_modules(SDL REQUIRED sdl2) pkg_check_modules(ZLIB REQUIRED zlib) -list(APPEND LIBS Qt6::Widgets Qt6::Gui ${SDL_LIBRARIES} ${ZLIB_LIBRARIES}) -list(APPEND INCLUDES ${SDL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}${Qt6Gui_PRIVATE_INCLUDE_DIRS}) +list(APPEND INCLUDES ${SDL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}) list(APPEND FLAGS ${SDL_COMPILE_FLAGS} ${ZLIB_COMPILE_FLAGS}) -pkg_check_modules(PULSEAUDIO libpulse) -if(PULSEAUDIO_FOUND) - list(APPEND LIBS ${PULSEAUDIO_LIBRARIES}) - list(APPEND INCLUDES ${PULSEAUDIO_INCLUDE_DIRS}) - list(APPEND DEFINES "USE_PULSEAUDIO") - list(APPEND PLATFORM_SOURCES ../common/audio/s9x_sound_driver_pulse.cpp) +if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + list(APPEND LIBS opengl32 libSDL2.a libz.a libc++.a) + list(APPEND DEFINES SDL_MAIN_HANDLED) + list(APPEND PLATFORM_SOURCES + ../common/video/wgl_context.cpp + ../external/glad/src/wgl.c + src/resources/snes9x_win32.rc) +else() + + pkg_check_modules(WAYLAND REQUIRED wayland-client wayland-egl) + include(FindX11) + if(NOT X11_FOUND) + error() + endif() + + list(APPEND INCLUDES ${WAYLAND_INCLUDE_DIRS} ${X11_INCLUDE_DIRS}) + list(APPEND LIBS ${WAYLAND_LIBRARIES} ${X11_LIBRARIES} ${ZLIB_LIBRARIES ${SDL_LIBRARIES}}) + list(APPEND FLAGS ${WAYLAND_CFLAGS}) + + pkg_check_modules(PULSEAUDIO libpulse) + if(PULSEAUDIO_FOUND) + list(APPEND LIBS ${PULSEAUDIO_LIBRARIES}) + list(APPEND INCLUDES ${PULSEAUDIO_INCLUDE_DIRS}) + list(APPEND DEFINES "USE_PULSEAUDIO") + list(APPEND PLATFORM_SOURCES ../common/audio/s9x_sound_driver_pulse.cpp) + endif() + + list(APPEND PLATFORM_SOURCES + ../common/video/glx_context.cpp + ../common/video/wayland_egl_context.cpp + ../common/video/wayland_surface.cpp + ../common/video/fractional-scale-v1.c + ../common/video/viewporter-client-protocol.c + ../common/video/wayland-idle-inhibit-unstable-v1.c + ../external/glad/src/glx.c + ../external/glad/src/egl.c) endif() list(APPEND QT_GUI_SOURCES @@ -135,36 +164,6 @@ list(APPEND QT_GUI_SOURCES ../filter/snes_ntsc_impl.h ../filter/snes_ntsc.c) -if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - pkg_check_modules(WAYLAND REQUIRED wayland-client wayland-egl) - - include(FindX11) - if(NOT X11_FOUND) - error() - endif() - - list(APPEND INCLUDES ${WAYLAND_INCLUDE_DIRS} ${X11_INCLUDE_DIRS}) - list(APPEND LIBS ${WAYLAND_LIBRARIES} ${X11_LIBRARIES}) - list(APPEND FLAGS ${WAYLAND_CFLAGS}) - - list(APPEND PLATFORM_SOURCES - ../common/video/glx_context.cpp - ../common/video/wayland_egl_context.cpp - ../common/video/wayland_surface.cpp - ../common/video/fractional-scale-v1.c - ../common/video/viewporter-client-protocol.c - ../common/video/wayland-idle-inhibit-unstable-v1.c - ../external/glad/src/glx.c - ../external/glad/src/egl.c) -else() - list(APPEND PLATFORM_SOURCES - ../common/video/wgl_context.cpp - ../external/glad/src/wgl.c - src/resources/snes9x_icon.rc) - list(APPEND LIBS opengl32) - list(APPEND DEFINES SDL_MAIN_HANDLED) -endif() - set(QT_UI_FILES src/GeneralPanel.ui src/ControllerPanel.ui @@ -266,7 +265,7 @@ list(APPEND INCLUDES ../external/imgui) add_executable(snes9x-qt ${QT_GUI_SOURCES} ${SOURCES} ${PLATFORM_SOURCES} src/resources/snes9x.qrc) if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") -set_target_properties(snes9x-qt PROPERTIES WIN32_EXECUTABLE True) + set_target_properties(snes9x-qt PROPERTIES WIN32_EXECUTABLE True) endif() target_link_libraries(snes9x-qt snes9x-core ${LIBS}) target_compile_definitions(snes9x-qt PRIVATE ${DEFINES}) diff --git a/qt/src/EmuApplication.cpp b/qt/src/EmuApplication.cpp index 123c1561..99f832a2 100644 --- a/qt/src/EmuApplication.cpp +++ b/qt/src/EmuApplication.cpp @@ -4,16 +4,15 @@ #include "Snes9xController.hpp" #include "common/audio/s9x_sound_driver_sdl.hpp" #include "common/audio/s9x_sound_driver_cubeb.hpp" -#include -#include #ifdef USE_PULSEAUDIO #include "common/audio/s9x_sound_driver_pulse.hpp" #endif + #include #include -#include -#include #include +#include +#include using namespace std::chrono_literals; #undef SOUND_BUFFER_WINDOW diff --git a/qt/src/resources/snes9x-qt.exe.manifest b/qt/src/resources/snes9x-qt.exe.manifest new file mode 100644 index 00000000..d442601e --- /dev/null +++ b/qt/src/resources/snes9x-qt.exe.manifest @@ -0,0 +1,10 @@ + + + + + UTF-8 + PerMonitorV2 + true + + + diff --git a/qt/src/resources/snes9x_icon.rc b/qt/src/resources/snes9x_icon.rc deleted file mode 100644 index dce3d274..00000000 --- a/qt/src/resources/snes9x_icon.rc +++ /dev/null @@ -1 +0,0 @@ -IDI_ICON1 ICON "snes9x.ico" diff --git a/qt/src/resources/snes9x_win32.rc b/qt/src/resources/snes9x_win32.rc new file mode 100644 index 00000000..d214cd5e --- /dev/null +++ b/qt/src/resources/snes9x_win32.rc @@ -0,0 +1,29 @@ +1 24 snes9x-qt.exe.manifest +IDI_ICON1 ICON "snes9x.ico" + +#include +VS_VERSION_INFO VERSIONINFO +FILEVERSION 1,62,3,0 +PRODUCTVERSION 1,62,3,0 +FILEFLAGSMASK 0x3fL +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "http://www.snes9x.com" + VALUE "FileDescription", "Snes9x" + VALUE "FileVersion", "1.62.3" + VALUE "InternalName", "Snes9x" + VALUE "LegalCopyright", "Copyright (C) 1996-2023" + VALUE "OriginalFilename", "snes9x-qt.exe" + VALUE "ProductName", "Snes9x Qt Interface" + VALUE "ProductVersion", "1.62.3" + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 65001 + END +END