diff --git a/.gitignore b/.gitignore
index c55a27cea..754d03e88 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,9 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+# macOS
+.DS_Store
+
# User-specific files
*.rsuser
*.suo
@@ -360,4 +363,4 @@ codewarrior/reVC_Data/
codewarrior/Release/
codewarrior/Debug/
-src/extras/GitSHA1.cpp
\ No newline at end of file
+src/extras/GitSHA1.cpp
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5d29a8346..6fa3221ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,29 @@ cmake_minimum_required(VERSION 3.14)
set(EXECUTABLE reVC)
set(PROJECT REVC)
+if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
+ if(CMAKE_GENERATOR STREQUAL "Xcode")
+ set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "macOS architectures")
+ if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING
+ "Minimum macOS version" FORCE)
+ endif()
+ if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "11.0")
+ set("CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET[arch=arm64]" "11.0")
+ endif()
+ elseif(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
+ if(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64" OR
+ (NOT CMAKE_OSX_ARCHITECTURES AND
+ CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64"))
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING
+ "Minimum macOS version" FORCE)
+ else()
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING
+ "Minimum macOS version" FORCE)
+ endif()
+ endif()
+endif()
+
project(${EXECUTABLE} C CXX)
set(${PROJECT}_AUTHOR "${PROJECT} Team")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
@@ -11,6 +34,117 @@ include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1 "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR")
message(STATUS "Building ${CMAKE_PROJECT_NAME} GIT SHA1: ${GIT_SHA1}")
+if(APPLE)
+ macro(reVC_define_macos_dependency key alias formula library filename)
+ list(APPEND ${PROJECT}_MACOS_DEPENDENCIES "${key}")
+ set(${PROJECT}_MACOS_${key}_ALIAS "${alias}")
+ set(${PROJECT}_MACOS_${key}_FORMULA "${formula}")
+ set(${PROJECT}_MACOS_${key}_LIBRARY "${library}")
+ set(${PROJECT}_MACOS_${key}_FILENAME "${filename}")
+ endmacro()
+
+ reVC_define_macos_dependency(OPENAL OpenAL::OpenAL
+ openal-soft openal libopenal.1.dylib)
+ reVC_define_macos_dependency(MPG123 MPG123::libmpg123
+ mpg123 mpg123 libmpg123.0.dylib)
+ reVC_define_macos_dependency(GLFW glfw
+ glfw glfw libglfw.3.dylib)
+
+ if(CMAKE_GENERATOR STREQUAL "Xcode")
+ set(${PROJECT}_HOMEBREW_ARM64_PREFIX "/opt/homebrew" CACHE PATH "arm64 Homebrew prefix")
+ set(${PROJECT}_HOMEBREW_X86_64_PREFIX "/usr/local" CACHE PATH "x86_64 Homebrew prefix")
+
+ function(reVC_macos_dependency target alias dylibs formula library filename)
+ if(EXISTS "/opt/local/lib/${filename}")
+ add_library(${target} INTERFACE)
+ add_library(${alias} ALIAS ${target})
+ target_include_directories(${target} INTERFACE "/opt/local/include")
+ target_link_libraries(${target} INTERFACE "/opt/local/lib/${filename}")
+ set(${dylibs} "/opt/local/lib/${filename}" PARENT_SCOPE)
+ return()
+ endif()
+
+ set(include_prefix)
+ set(link_options)
+ set(dependency_dylibs)
+ foreach(architecture arm64 x86_64)
+ if(architecture IN_LIST CMAKE_OSX_ARCHITECTURES)
+ string(TOUPPER "${architecture}" architecture_upper)
+ set(prefix "${${PROJECT}_HOMEBREW_${architecture_upper}_PREFIX}")
+ set(dylib "${prefix}/opt/${formula}/lib/${filename}")
+ if(NOT EXISTS "${dylib}")
+ message(FATAL_ERROR
+ "${architecture} ${formula} was not found under ${prefix}"
+ )
+ endif()
+ if(NOT include_prefix)
+ set(include_prefix "${prefix}")
+ endif()
+ list(APPEND dependency_dylibs "${dylib}")
+ list(APPEND link_options
+ "SHELL:-Xarch_${architecture} -L${prefix}/opt/${formula}/lib"
+ )
+ endif()
+ endforeach()
+
+ add_library(${target} INTERFACE)
+ add_library(${alias} ALIAS ${target})
+ target_include_directories(${target} INTERFACE
+ "${include_prefix}/opt/${formula}/include"
+ )
+ target_link_options(${target} INTERFACE ${link_options} "-l${library}")
+ set(${dylibs} "${dependency_dylibs}" PARENT_SCOPE)
+ endfunction()
+
+ if("arm64" IN_LIST CMAKE_OSX_ARCHITECTURES OR
+ "x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES)
+ foreach(dependency IN LISTS ${PROJECT}_MACOS_DEPENDENCIES)
+ string(TOLOWER "${dependency}" dependency_lower)
+ reVC_macos_dependency(${PROJECT}_macos_${dependency_lower}
+ ${${PROJECT}_MACOS_${dependency}_ALIAS}
+ ${PROJECT}_MACOS_${dependency}_DYLIBS
+ ${${PROJECT}_MACOS_${dependency}_FORMULA}
+ ${${PROJECT}_MACOS_${dependency}_LIBRARY}
+ ${${PROJECT}_MACOS_${dependency}_FILENAME})
+ endforeach()
+ endif()
+ else()
+ function(reVC_macos_dependency_dylib output formula filename)
+ set(prefix "$ENV{HOMEBREW_PREFIX}")
+ set(candidates "/opt/local/lib/${filename}")
+ if(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64" OR
+ (NOT CMAKE_OSX_ARCHITECTURES AND
+ CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"))
+ list(APPEND candidates
+ "/usr/local/opt/${formula}/lib/${filename}"
+ )
+ else()
+ if(prefix)
+ list(APPEND candidates "${prefix}/opt/${formula}/lib/${filename}")
+ endif()
+ list(APPEND candidates
+ "/opt/homebrew/opt/${formula}/lib/${filename}"
+ "/usr/local/opt/${formula}/lib/${filename}"
+ )
+ endif()
+ list(REMOVE_DUPLICATES candidates)
+ foreach(candidate IN LISTS candidates)
+ if(EXISTS "${candidate}")
+ set(${output} "${candidate}" PARENT_SCOPE)
+ return()
+ endif()
+ endforeach()
+ endfunction()
+
+ foreach(dependency IN LISTS ${PROJECT}_MACOS_DEPENDENCIES)
+ reVC_macos_dependency_dylib(
+ ${PROJECT}_MACOS_${dependency}_DYLIBS
+ ${${PROJECT}_MACOS_${dependency}_FORMULA}
+ ${${PROJECT}_MACOS_${dependency}_FILENAME})
+ endforeach()
+ endif()
+endif()
+
if(NINTENDO_SWITCH)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/nx")
@@ -42,6 +176,9 @@ endif()
option(${PROJECT}_VENDORED_LIBRW "Use vendored librw" ON)
if(${PROJECT}_VENDORED_LIBRW)
+ if(NOT DEFINED LIBRW_PLATFORM AND NOT PS2)
+ set(LIBRW_PLATFORM "GL3" CACHE STRING "librw platform")
+ endif()
add_subdirectory(vendor/librw)
else()
find_package(librw REQUIRED)
diff --git a/cmake/Findmpg123.cmake b/cmake/Findmpg123.cmake
index aa59ad826..c2e477744 100644
--- a/cmake/Findmpg123.cmake
+++ b/cmake/Findmpg123.cmake
@@ -9,7 +9,7 @@
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
- pkg_search_module(PKG_MPG123 mpg123)
+ pkg_search_module(PKG_MPG123 libmpg123)
endif()
find_path(mpg123_INCLUDE_DIR mpg123.h
@@ -19,7 +19,7 @@ find_path(mpg123_INCLUDE_DIR mpg123.h
)
find_library(mpg123_LIBRARIES NAMES mpg123 mpg123-0 libmpg123-0
- HINTS ${PKG_MPG123_LIBRARIES}
+ HINTS ${PKG_MPG123_LIBRARY_DIRS}
PATHS "${mpg123_DIR}"
PATH_SUFFIXES lib
)
diff --git a/premake5.lua b/premake5.lua
index 30c1a40c7..69426532f 100644
--- a/premake5.lua
+++ b/premake5.lua
@@ -68,6 +68,126 @@ function getarch(a)
return a
end
+local function dependencyincludedirs(paths)
+ if _ACTION == "xcode4" then
+ externalincludedirs(paths)
+ else
+ includedirs(paths)
+ end
+end
+
+local macosxHomebrewPrefix = os.getenv("HOMEBREW_PREFIX")
+if not macosxHomebrewPrefix or macosxHomebrewPrefix == "" then
+ macosxHomebrewPrefix = os.host() == "macosx" and os.hostarch() == "ARM64" and "/opt/homebrew" or "/usr/local"
+end
+
+local function resolveMacosxDependencyDylib(formula, filename, homebrewPrefix)
+ local candidates = {
+ path.join("/opt/local/lib", filename),
+ path.join(homebrewPrefix, "opt", formula, "lib", filename),
+ }
+
+ for _, candidate in ipairs(candidates) do
+ if os.isfile(candidate) then
+ return candidate
+ end
+ end
+ return candidates[2]
+end
+
+local macosxDependencies = {
+ { formula = "openal-soft", filename = "libopenal.1.dylib" },
+ { formula = "mpg123", filename = "libmpg123.0.dylib" },
+ { formula = "glfw", filename = "libglfw.3.dylib" },
+}
+
+local function resolveMacosxDependencyDylibs(homebrewPrefix)
+ local dylibs = {}
+ for _, dependency in ipairs(macosxDependencies) do
+ table.insert(dylibs, {
+ filename = dependency.filename,
+ path = resolveMacosxDependencyDylib(dependency.formula, dependency.filename, homebrewPrefix),
+ })
+ end
+ return dylibs
+end
+
+local macosxDependencyDylibs = resolveMacosxDependencyDylibs(macosxHomebrewPrefix)
+local macosxArm64HomebrewPrefix = os.hostarch() == "ARM64" and macosxHomebrewPrefix or "/opt/homebrew"
+local macosxAmd64HomebrewPrefix = os.hostarch() == "ARM64" and "/usr/local" or macosxHomebrewPrefix
+local macosxArm64DependencyDylibs = resolveMacosxDependencyDylibs(macosxArm64HomebrewPrefix)
+local macosxAmd64DependencyDylibs = resolveMacosxDependencyDylibs(macosxAmd64HomebrewPrefix)
+
+local function existingDirectories(directories)
+ local existing = {}
+ for _, directory in ipairs(directories) do
+ if os.isdir(directory) then
+ table.insert(existing, directory)
+ end
+ end
+ return existing
+end
+
+local function existingXcodeSearchPaths(directories)
+ local existing = existingDirectories(directories)
+ table.insert(existing, 1, "$(inherited)")
+ return existing
+end
+
+local macosxXcodeArchitectures = _OPTIONS["arch"]
+if not macosxXcodeArchitectures or macosxXcodeArchitectures == "universal" then
+ macosxXcodeArchitectures = "$(ARCHS_STANDARD)"
+end
+
+local macosxXcodeDeploymentTarget = macosxXcodeArchitectures == "x86_64" and "10.12" or "11.0"
+local macosxXcodeBuildSettings = {
+ ["ARCHS"] = { macosxXcodeArchitectures },
+ ["MACOSX_DEPLOYMENT_TARGET"] = { macosxXcodeDeploymentTarget },
+ ["ONLY_ACTIVE_ARCH"] = { "YES" },
+}
+if macosxXcodeArchitectures == "$(ARCHS_STANDARD)" then
+ macosxXcodeBuildSettings["MACOSX_DEPLOYMENT_TARGET[arch=x86_64]"] = { "10.12" }
+end
+
+local function macosxDependencyPaths(dylibs)
+ local paths = {}
+ for _, dylib in ipairs(dylibs) do
+ table.insert(paths, dylib.path)
+ end
+ return paths
+end
+
+local function macosxDependencyFilenames(dylibs)
+ local filenames = {}
+ for _, dylib in ipairs(dylibs) do
+ table.insert(filenames, dylib.filename)
+ end
+ return filenames
+end
+
+local function macosxInstallNameCommands(dylibs, executable)
+ local commands = {}
+ for _, dylib in ipairs(dylibs) do
+ table.insert(commands, 'install_name_tool -change "' .. dylib.path .. '" "@rpath/' .. dylib.filename .. '" "' .. executable .. '"')
+ end
+ return commands
+end
+
+local function macosxGmakeBundleCommands(dylibs)
+ local commands = {}
+ for _, dylib in ipairs(dylibs) do
+ table.insert(commands, '{COPYFILE} "' .. dylib.path .. '" "%{cfg.targetdir}/reVC.app/Contents/Frameworks/' .. dylib.filename .. '"')
+ end
+ for _, command in ipairs(macosxInstallNameCommands(dylibs, "%{cfg.targetdir}/reVC.app/Contents/MacOS/reVC")) do
+ table.insert(commands, command)
+ end
+ for _, dylib in ipairs(dylibs) do
+ table.insert(commands, 'codesign --force --sign - "%{cfg.targetdir}/reVC.app/Contents/Frameworks/' .. dylib.filename .. '"')
+ end
+ table.insert(commands, 'codesign --force --sign - "%{cfg.targetdir}/reVC.app"')
+ return commands
+end
+
workspace "reVC"
language "C++"
configurations { "Debug", "Release" }
@@ -110,11 +230,16 @@ workspace "reVC"
"bsd-arm64-librw_gl3_glfw-oal"
}
- filter { "system:macosx" }
- platforms {
- "macosx-arm64-librw_gl3_glfw-oal",
- "macosx-amd64-librw_gl3_glfw-oal",
- }
+ filter { "system:macosx" }
+ cppdialect "gnu++14"
+ if _ACTION == "xcode4" then
+ platforms { "macosx-librw_gl3_glfw-oal" }
+ else
+ platforms {
+ "macosx-arm64-librw_gl3_glfw-oal",
+ "macosx-amd64-librw_gl3_glfw-oal",
+ }
+ end
filter "configurations:Debug"
defines { "DEBUG" }
@@ -144,20 +269,22 @@ workspace "reVC"
filter { "platforms:*amd64*" }
architecture "amd64"
- filter { "platforms:*arm*" }
+ filter { "platforms:*arm-*" }
architecture "ARM"
- filter { "platforms:macosx-arm64-*", "files:**.cpp"}
- buildoptions { "-target", "arm64-apple-macos11", "-std=gnu++14" }
-
- filter { "platforms:macosx-arm64-*", "files:**.c"}
- buildoptions { "-target", "arm64-apple-macos11" }
-
- filter { "platforms:macosx-amd64-*", "files:**.cpp"}
- buildoptions { "-target", "x86_64-apple-macos10.12", "-std=gnu++14" }
-
- filter { "platforms:macosx-amd64-*", "files:**.c"}
- buildoptions { "-target", "x86_64-apple-macos10.12" }
+ filter { "platforms:*arm64*" }
+ architecture "ARM64"
+
+ filter { "platforms:macosx-arm64-*", "action:not xcode4" }
+ buildoptions { "-target", "arm64-apple-macos11" }
+ linkoptions { "-target", "arm64-apple-macos11" }
+
+ filter { "platforms:macosx-amd64-*", "action:not xcode4" }
+ buildoptions { "-target", "x86_64-apple-macos10.12" }
+ linkoptions { "-target", "x86_64-apple-macos10.12" }
+
+ filter { "system:macosx", "action:xcode4" }
+ xcodebuildsettings(macosxXcodeBuildSettings)
filter { "platforms:*librw_d3d9*" }
defines { "RW_D3D9" }
@@ -195,11 +322,19 @@ workspace "reVC"
end
if(_OPTIONS["with-librw"]) then
-project "librw"
- kind "StaticLib"
- targetname "rw"
- targetdir(path.join(Librw, "lib/%{cfg.platform}/%{cfg.buildcfg}"))
- files { path.join(Librw, "src/*.*") }
+project "librw"
+ kind "StaticLib"
+ targetname "rw"
+ if _ACTION == "xcode4" then
+ targetdir "${BUILD_DIR}/%{cfg.buildcfg}"
+ xcodebuildsettings {
+ ["SKIP_INSTALL"] = "YES",
+ }
+ else
+ targetdir(path.join(Librw, "lib/%{cfg.platform}/%{cfg.buildcfg}"))
+ end
+
+ files { path.join(Librw, "src/*.*") }
files { path.join(Librw, "src/*/*.*") }
files { path.join(Librw, "src/gl/*/*.*") }
@@ -218,19 +353,22 @@ project "librw"
includedirs { "/usr/local/include" }
libdirs { "/usr/local/lib" }
- -- Support MacPorts and Homebrew
- filter "platforms:macosx-arm64-*"
- includedirs { "/opt/local/include" }
- includedirs {"/opt/homebrew/include" }
- libdirs { "/opt/local/lib" }
- libdirs { "/opt/homebrew/lib" }
-
- filter "platforms:macosx-amd64-*"
- includedirs { "/opt/local/include" }
- includedirs {"/usr/local/include" }
- libdirs { "/opt/local/lib" }
- libdirs { "/usr/local/lib" }
-
+ -- Support MacPorts and Homebrew
+ filter "platforms:macosx-arm64-*"
+ dependencyincludedirs { "/opt/local/include", "/opt/homebrew/include" }
+ libdirs { "/opt/local/lib", "/opt/homebrew/lib" }
+
+ filter "platforms:macosx-amd64-*"
+ dependencyincludedirs { "/opt/local/include", "/usr/local/include" }
+ libdirs { "/opt/local/lib", "/usr/local/lib" }
+
+ filter { "system:macosx", "action:xcode4" }
+ dependencyincludedirs { "/opt/local/include", "/opt/homebrew/include", "/usr/local/include" }
+ xcodebuildsettings {
+ ["LIBRARY_SEARCH_PATHS[arch=arm64]"] = { "$(inherited)", "/opt/local/lib", "/opt/homebrew/lib" },
+ ["LIBRARY_SEARCH_PATHS[arch=x86_64]"] = { "$(inherited)", "/opt/local/lib", "/usr/local/lib" },
+ }
+
filter "platforms:*gl3_glfw*"
staticruntime "off"
@@ -243,11 +381,66 @@ local function addSrcFiles( prefix )
return prefix .. "/*cpp", prefix .. "/*.h", prefix .. "/*.c", prefix .. "/*.ico", prefix .. "/*.rc"
end
-project "reVC"
- kind "WindowedApp"
- targetname "reVC"
- targetdir "bin/%{cfg.platform}/%{cfg.buildcfg}"
-
+project "reVC"
+ kind "WindowedApp"
+ targetname "reVC"
+ if _ACTION == "xcode4" then
+ targetdir "${BUILD_DIR}/%{cfg.buildcfg}"
+ else
+ targetdir "bin/%{cfg.platform}/%{cfg.buildcfg}"
+ end
+
+ filter { "system:macosx" }
+ files { "res/images/reVC.icns", "res/macos/Info.plist", "res/macos/ThirdPartyNotices.txt" }
+
+ filter { "system:macosx", "action:xcode4" }
+ xcodebuildresources { "res/macos/ThirdPartyNotices.txt" }
+ xcodebuildsettings {
+ ["PRODUCT_BUNDLE_IDENTIFIER"] = "io.github.mrxenginner.reVC",
+ ["INSTALL_PATH"] = "$(LOCAL_APPS_DIR)",
+ ["CODE_SIGN_STYLE"] = "Automatic",
+ ["LD_RUNPATH_SEARCH_PATHS"] = "$(inherited) @executable_path/../Frameworks",
+ }
+ links(macosxDependencyPaths(macosxDependencyDylibs))
+ links { "pthread" }
+ embedAndSign(macosxDependencyFilenames(macosxDependencyDylibs))
+ postbuildcommands {
+ '{MKDIR} "%{cfg.targetdir}/reVC.app/Contents/Resources"',
+ '{COPYFILE} "%{prj.location}/../LICENSE.md" "%{cfg.targetdir}/reVC.app/Contents/Resources/LICENSE"',
+ '{RMDIR} "%{cfg.targetdir}/reVC.app/Contents/Resources/gamefiles"',
+ '{COPYDIR} "%{prj.location}/../gamefiles" "%{cfg.targetdir}/reVC.app/Contents/Resources"',
+ }
+ postbuildcommands(macosxInstallNameCommands(macosxDependencyDylibs, "${TARGET_BUILD_DIR}/${EXECUTABLE_PATH}"))
+
+ filter { "system:macosx", "action:xcode4", "configurations:Release" }
+ xcodebuildsettings {
+ ["CODE_SIGN_IDENTITY"] = "Apple Development",
+ ["ENABLE_HARDENED_RUNTIME"] = "YES",
+ }
+
+ filter { "system:macosx", "action:gmake*" }
+ linkoptions { "-Wl,-rpath,@executable_path/../Frameworks" }
+ postbuildcommands {
+ '{MKDIR} "%{cfg.targetdir}/reVC.app/Contents/MacOS"',
+ '{MKDIR} "%{cfg.targetdir}/reVC.app/Contents/Frameworks"',
+ '{MKDIR} "%{cfg.targetdir}/reVC.app/Contents/Resources"',
+ '{COPYFILE} "%{cfg.buildtarget.abspath}" "%{cfg.targetdir}/reVC.app/Contents/MacOS/reVC"',
+ '{COPYFILE} "%{prj.location}/../res/images/reVC.icns" "%{cfg.targetdir}/reVC.app/Contents/Resources/reVC.icns"',
+ '{COPYFILE} "%{prj.location}/../res/macos/ThirdPartyNotices.txt" "%{cfg.targetdir}/reVC.app/Contents/Resources/ThirdPartyNotices.txt"',
+ '{COPYFILE} "%{prj.location}/../LICENSE.md" "%{cfg.targetdir}/reVC.app/Contents/Resources/LICENSE"',
+ '{COPYFILE} "%{prj.location}/../res/macos/Info.plist" "%{cfg.targetdir}/reVC.app/Contents/Info.plist"',
+ '{RMDIR} "%{cfg.targetdir}/reVC.app/Contents/Resources/gamefiles"',
+ '{COPYDIR} "%{prj.location}/../gamefiles" "%{cfg.targetdir}/reVC.app/Contents/Resources"',
+ }
+
+ filter { "action:gmake*", "platforms:macosx-arm64-*" }
+ postbuildcommands(macosxGmakeBundleCommands(macosxArm64DependencyDylibs))
+
+ filter { "action:gmake*", "platforms:macosx-amd64-*" }
+ postbuildcommands(macosxGmakeBundleCommands(macosxAmd64DependencyDylibs))
+
+ filter {}
+
if(_OPTIONS["with-librw"]) then
dependson "librw"
end
@@ -304,6 +497,11 @@ project "reVC"
includedirs { "src/vehicles" }
includedirs { "src/weapons" }
includedirs { "src/extras" }
+
+ filter "action:xcode4"
+ externalincludedirs { "src/audio/eax", "src/fakerw", Librw }
+
+ filter {}
if(not _OPTIONS["no-git-hash"]) then
defines { "USE_OUR_VERSIONING" }
@@ -396,23 +594,23 @@ project "reVC"
libdirs { "vendor/openal-soft/libs/Win64" }
filter "platforms:linux*oal"
- links { "openal", "mpg123", "sndfile", "pthread" }
+ links { "openal", "mpg123", "pthread" }
filter "platforms:bsd*oal"
- links { "openal", "mpg123", "sndfile", "pthread" }
-
- filter "platforms:macosx*oal"
- links { "openal", "mpg123", "sndfile", "pthread" }
-
- filter "platforms:macosx-arm64-*oal"
- includedirs { "/opt/homebrew/opt/openal-soft/include" }
- libdirs { "/opt/homebrew/opt/openal-soft/lib" }
-
- filter "platforms:macosx-amd64-*oal"
- includedirs { "/usr/local/opt/openal-soft/include" }
- libdirs { "/usr/local/opt/openal-soft/lib" }
-
- if _OPTIONS["with-opus"] then
+ links { "openal", "mpg123", "pthread" }
+
+ filter { "platforms:macosx*oal", "action:not xcode4" }
+ links { "openal", "mpg123", "pthread" }
+
+ filter "platforms:macosx-arm64-*oal"
+ dependencyincludedirs(existingDirectories { "/opt/homebrew/opt/openal-soft/include" })
+ libdirs(existingDirectories { "/opt/homebrew/opt/openal-soft/lib" })
+
+ filter "platforms:macosx-amd64-*oal"
+ dependencyincludedirs(existingDirectories { "/usr/local/opt/openal-soft/include" })
+ libdirs(existingDirectories { "/usr/local/opt/openal-soft/lib" })
+
+ if _OPTIONS["with-opus"] then
filter {}
links { "libogg" }
links { "opus" }
@@ -431,12 +629,12 @@ project "reVC"
files { addSrcFiles("src/fakerw") }
includedirs { "src/fakerw" }
includedirs { Librw }
- if(_OPTIONS["with-librw"]) then
+ if(_OPTIONS["with-librw"] and _ACTION ~= "xcode4") then
libdirs { "vendor/librw/lib/%{cfg.platform}/%{cfg.buildcfg}" }
- end
- links { "rw" }
-
- filter "platforms:*d3d9*"
+ end
+ links { "rw" }
+
+ filter "platforms:*d3d9*"
defines { "USE_D3D9" }
links { "d3d9" }
@@ -460,18 +658,28 @@ project "reVC"
includedirs { "/usr/local/include" }
libdirs { "/usr/local/lib" }
- filter "platforms:macosx-arm64-*gl3_glfw*"
- links { "glfw" }
- linkoptions { "-framework OpenGL" }
- includedirs { "/opt/local/include" }
- includedirs {"/opt/homebrew/include" }
- libdirs { "/opt/local/lib" }
- libdirs { "/opt/homebrew/lib" }
-
- filter "platforms:macosx-amd64-*gl3_glfw*"
- links { "glfw" }
- linkoptions { "-framework OpenGL" }
- includedirs { "/opt/local/include" }
- includedirs {"/usr/local/include" }
- libdirs { "/opt/local/lib" }
- libdirs { "/usr/local/lib" }
+ filter { "platforms:macosx*gl3_glfw*", "action:not xcode4" }
+ links { "glfw" }
+ linkoptions { "-framework OpenGL" }
+
+ filter "platforms:macosx-arm64-*gl3_glfw*"
+ dependencyincludedirs { "/opt/local/include", "/opt/homebrew/include" }
+ libdirs { "/opt/local/lib", "/opt/homebrew/lib" }
+
+ filter "platforms:macosx-amd64-*gl3_glfw*"
+ dependencyincludedirs { "/opt/local/include", "/usr/local/include" }
+ libdirs { "/opt/local/lib", "/usr/local/lib" }
+
+ filter { "system:macosx", "action:xcode4" }
+ links { "OpenGL.framework" }
+ dependencyincludedirs(existingDirectories {
+ "/opt/local/include",
+ "/opt/homebrew/include",
+ "/usr/local/include",
+ "/opt/homebrew/opt/openal-soft/include",
+ "/usr/local/opt/openal-soft/include",
+ })
+ xcodebuildsettings {
+ ["LIBRARY_SEARCH_PATHS[arch=arm64]"] = existingXcodeSearchPaths { "/opt/local/lib", "/opt/homebrew/lib", "/opt/homebrew/opt/openal-soft/lib" },
+ ["LIBRARY_SEARCH_PATHS[arch=x86_64]"] = existingXcodeSearchPaths { "/opt/local/lib", "/usr/local/lib", "/usr/local/opt/openal-soft/lib" },
+ }
diff --git a/res/images/reVC.icns b/res/images/reVC.icns
new file mode 100644
index 000000000..604b7a99d
Binary files /dev/null and b/res/images/reVC.icns differ
diff --git a/res/macos/Info.plist b/res/macos/Info.plist
new file mode 100644
index 000000000..4a6d99c20
--- /dev/null
+++ b/res/macos/Info.plist
@@ -0,0 +1,37 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleExecutable
+ reVC
+ CFBundleIconFile
+ reVC.icns
+ CFBundleIdentifier
+ io.github.mrxenginner.reVC
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ reVC
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ 1.0
+ CFBundleVersion
+ 1
+ LSMinimumSystemVersion
+ 10.12
+ LSMinimumSystemVersionByArchitecture
+
+ arm64
+ 11.0
+ x86_64
+ 10.12
+
+ NSHighResolutionCapable
+
+ LSApplicationCategoryType
+ public.app-category.games
+
+
diff --git a/res/macos/ThirdPartyNotices.txt b/res/macos/ThirdPartyNotices.txt
new file mode 100644
index 000000000..49a4d1292
--- /dev/null
+++ b/res/macos/ThirdPartyNotices.txt
@@ -0,0 +1,1319 @@
+Third-party software bundled with reVC for macOS
+
+OpenAL Soft
+Source: https://github.com/kcat/openal-soft
+License: GNU Library General Public License 2.0 or later
+
+mpg123
+Copyright (c) 1995-2020 by Michael Hipp and others
+Source: https://www.mpg123.de/
+License: GNU Lesser General Public License 2.1 only
+
+GLFW
+Copyright (c) 2002-2006 Marcus Geelnard
+Copyright (c) 2006-2019 Camilla Löwy
+Source: https://github.com/glfw/glfw
+License: zlib License
+
+OpenAL Soft also incorporates {fmt} and Microsoft GSL code under the
+license notices reproduced below.
+
+========================================================================
+OpenAL Soft license
+========================================================================
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL. It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it. You can use it for
+your libraries, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library. If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software. To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+ Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs. This
+license, the GNU Library General Public License, applies to certain
+designated libraries. This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+ The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it. Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program. However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+ Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries. We
+concluded that weaker conditions might promote sharing better.
+
+ However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves. This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them. (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.) The hope is that this
+will lead to faster development of free libraries.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+ Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License"). Each licensee is
+addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ c) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ d) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+========================================================================
+mpg123 notice and license
+========================================================================
+This is the file that contains the terms of use, copying, etc. for the mpg123 distribution package.
+
+Main message, to include in "About ..." boxes, etc:
+
+ Copyright (c) 1995-2020 by Michael Hipp and others,
+ free software under the terms of the LGPL v2.1
+
+There is an attempt to cover the actual list of authors in the AUTHORS file.
+Project maintainer since 2006 is Thomas Orgis and many people have contributed
+since the Michael Hipp era, but he stays the initial source and it would
+be impractical to count them all individually, so it's "and others".
+Source files contain the phrase "the mpg123 project" to the same effect
+in their license boilerplate; especially those that were added after
+maintainership changed. The person mainly responsible for the first version
+is usually named in the phrase "initially written by ...".
+
+All files in the distribution that don't carry a license note on their own are
+licensed under the terms of the LGPL 2.1; exceptions may apply, especially to
+files not in the official distribution but in the revision control repository.
+
+The formal license text follows.
+
+=======================
+1. The LGPL version 2.1
+=======================
+
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+
+====================
+2. The GPL version 2
+====================
+
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+========================================================================
+GLFW license
+========================================================================
+Copyright (c) 2002-2006 Marcus Geelnard
+
+Copyright (c) 2006-2019 Camilla Löwy
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would
+ be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and must not
+ be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+ distribution.
+
+
+========================================================================
+{fmt} license (incorporated by OpenAL Soft)
+========================================================================
+Copyright (c) 2012 - present, Victor Zverovich and {fmt} contributors
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+--- Optional exception to the license ---
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into a machine-executable object form of such
+source code, you may redistribute such embedded portions in such object form
+without including the above copyright and permission notices.
+
+========================================================================
+Microsoft GSL license (incorporated by OpenAL Soft)
+========================================================================
+Copyright (c) 2015 Microsoft Corporation. All rights reserved.
+
+This code is licensed under the MIT License (MIT).
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 91d3b8f69..39174f63f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,6 +2,7 @@ find_package(Threads REQUIRED)
set(THREADS_PREFER_PTHREAD_FLAG ON)
file(GLOB_RECURSE ${PROJECT}_SOURCES "*.cpp" "*.h" "*.rc")
+list(REMOVE_ITEM ${PROJECT}_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/extras/GitSHA1.cpp")
function(header_directories RETURN_LIST)
file(GLOB_RECURSE ALL_SRCS *.h *.cpp *.c)
@@ -84,7 +85,18 @@ else()
endif()
if(${PROJECT}_AUDIO STREQUAL "OAL")
- find_package(OpenAL REQUIRED)
+ if(NOT TARGET OpenAL::OpenAL)
+ if(APPLE)
+ find_package(OpenAL CONFIG QUIET
+ PATHS
+ "/opt/homebrew/opt/openal-soft"
+ "/usr/local/opt/openal-soft"
+ )
+ endif()
+ if(NOT TARGET OpenAL::OpenAL)
+ find_package(OpenAL REQUIRED)
+ endif()
+ endif()
if(TARGET OpenAL::OpenAL)
target_link_libraries(${EXECUTABLE} PRIVATE OpenAL::OpenAL)
else()
@@ -99,7 +111,9 @@ elseif(${PROJECT}_AUDIO STREQUAL "MSS")
target_link_libraries(${EXECUTABLE} PRIVATE MilesSDK::MilesSDK)
endif()
-find_package(mpg123 REQUIRED)
+if(NOT TARGET MPG123::libmpg123)
+ find_package(mpg123 REQUIRED)
+endif()
target_link_libraries(${EXECUTABLE} PRIVATE
MPG123::libmpg123
)
@@ -213,10 +227,120 @@ set_target_properties(${EXECUTABLE}
CXX_STANDARD_REQUIRED ON
)
+if(APPLE AND NOT ANDROID)
+ set(${PROJECT}_MACOS_ICON "${PROJECT_SOURCE_DIR}/res/images/reVC.icns")
+ set(${PROJECT}_MACOS_NOTICES "${PROJECT_SOURCE_DIR}/res/macos/ThirdPartyNotices.txt")
+ target_sources(${EXECUTABLE} PRIVATE
+ "${${PROJECT}_MACOS_ICON}"
+ "${${PROJECT}_MACOS_NOTICES}"
+ )
+ set_source_files_properties(
+ "${${PROJECT}_MACOS_ICON}"
+ "${${PROJECT}_MACOS_NOTICES}"
+ PROPERTIES
+ MACOSX_PACKAGE_LOCATION "Resources"
+ )
+ set_target_properties(${EXECUTABLE} PROPERTIES
+ MACOSX_BUNDLE TRUE
+ MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/res/macos/Info.plist"
+ BUILD_WITH_INSTALL_RPATH TRUE
+ INSTALL_RPATH "@executable_path/../Frameworks"
+ INSTALL_RPATH_USE_LINK_PATH FALSE
+ XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "io.github.mrxenginner.reVC"
+ XCODE_ATTRIBUTE_CODE_SIGN_STYLE "$<$:Automatic>"
+ XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "$<$:Apple Development>"
+ "XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME[sdk=macosx*]" "$,NO,YES>"
+ "XCODE_ATTRIBUTE_INSTALL_PATH[sdk=macosx*]" "$(LOCAL_APPS_DIR)"
+ XCODE_ATTRIBUTE_SKIP_INSTALL "NO"
+ )
+ add_custom_command(TARGET ${EXECUTABLE} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ "${PROJECT_SOURCE_DIR}/LICENSE.md"
+ "$/Resources/LICENSE"
+ COMMAND ${CMAKE_COMMAND} -E remove_directory
+ "$/Resources/gamefiles"
+ COMMAND ${CMAKE_COMMAND} -E copy_directory
+ "${PROJECT_SOURCE_DIR}/gamefiles"
+ "$/Resources/gamefiles"
+ COMMENT "Copying gamefiles into the app bundle"
+ )
+
+ set(macos_dependency_dylibs_available TRUE)
+ foreach(dependency IN LISTS ${PROJECT}_MACOS_DEPENDENCIES)
+ if(NOT DEFINED ${PROJECT}_MACOS_${dependency}_DYLIBS)
+ set(macos_dependency_dylibs_available FALSE)
+ break()
+ endif()
+ endforeach()
+ if(macos_dependency_dylibs_available)
+ set(shell_dollar "$")
+ set(codesign_command
+ "identity=${shell_dollar}EXPANDED_CODE_SIGN_IDENTITY; test -n \"${shell_dollar}identity\" || identity=-; /usr/bin/codesign --force --sign \"${shell_dollar}identity\" \"${shell_dollar}1\""
+ )
+ set(app_codesign_command
+ "identity=${shell_dollar}EXPANDED_CODE_SIGN_IDENTITY; test -n \"${shell_dollar}identity\" || identity=-; if test \"${shell_dollar}2\" = YES; then /usr/bin/codesign --force --sign \"${shell_dollar}identity\" --options runtime \"${shell_dollar}1\"; else /usr/bin/codesign --force --sign \"${shell_dollar}identity\" \"${shell_dollar}1\"; fi"
+ )
+ if(CMAKE_GENERATOR STREQUAL "Xcode")
+ set(app_hardened "$,NO,YES>")
+ else()
+ set(app_hardened NO)
+ endif()
+ add_custom_command(TARGET ${EXECUTABLE} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E make_directory
+ "$/Frameworks"
+ )
+
+ function(reVC_bundle_macos_dylib target filename)
+ set(destination
+ "$/Frameworks/${filename}"
+ )
+ list(LENGTH ARGN source_count)
+ if(source_count GREATER 1)
+ add_custom_command(TARGET ${target} POST_BUILD
+ COMMAND /usr/bin/lipo -create ${ARGN} -output "${destination}"
+ )
+ else()
+ list(GET ARGN 0 source)
+ add_custom_command(TARGET ${target} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ "${source}" "${destination}"
+ )
+ endif()
+ foreach(source IN LISTS ARGN)
+ add_custom_command(TARGET ${target} POST_BUILD
+ COMMAND install_name_tool -change
+ "${source}" "@rpath/${filename}" "$"
+ )
+ endforeach()
+ add_custom_command(TARGET ${target} POST_BUILD
+ COMMAND /bin/sh -c
+ "${codesign_command}"
+ codesign "${destination}"
+ VERBATIM
+ )
+ endfunction()
+
+ foreach(dependency IN LISTS ${PROJECT}_MACOS_DEPENDENCIES)
+ reVC_bundle_macos_dylib(${EXECUTABLE}
+ ${${PROJECT}_MACOS_${dependency}_FILENAME}
+ ${${PROJECT}_MACOS_${dependency}_DYLIBS})
+ endforeach()
+ add_custom_command(TARGET ${EXECUTABLE} POST_BUILD
+ COMMAND /bin/sh -c
+ "${app_codesign_command}"
+ codesign "$"
+ "${app_hardened}"
+ COMMENT "Bundling macOS dependencies"
+ VERBATIM
+ )
+ endif()
+endif()
+
if(${PROJECT}_INSTALL)
install(
TARGETS ${EXECUTABLE}
EXPORT ${EXECUTABLE}-targets
+ BUNDLE DESTINATION "."
RUNTIME DESTINATION "."
)
if(MSVC)
diff --git a/src/audio/oal/stream.h b/src/audio/oal/stream.h
index d472c603f..522d13d41 100644
--- a/src/audio/oal/stream.h
+++ b/src/audio/oal/stream.h
@@ -3,6 +3,7 @@
#ifdef AUDIO_OAL
#include
+#include "crossplatform.h"
#define NUM_STREAMBUFFERS 8
@@ -116,7 +117,7 @@ template class tsQueue
#endif
class CStream
{
- char m_aFilename[128];
+ char m_aFilename[MAX_PATH];
ALuint *m_pAlSources;
ALuint (&m_alBuffers)[NUM_STREAMBUFFERS];
diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp
index 124423529..7eaeb32fc 100644
--- a/src/core/FileMgr.cpp
+++ b/src/core/FileMgr.cpp
@@ -3,6 +3,10 @@
#ifdef _WIN32
#include
#endif
+#ifdef __APPLE__
+#include
+#include
+#endif
#include "common.h"
#include "crossplatform.h"
@@ -61,12 +65,162 @@ void mychdir(char const *path)
#define mychdir chdir
#endif
+#ifdef __APPLE__
+static char bundledGameFilesDir[FILEMGR_PATH_SIZE] = {'\0'};
+
+static bool
+GameFileExists(const char *root, const char *name)
+{
+ char path[FILEMGR_PATH_SIZE];
+ int length = snprintf(path, sizeof(path), "%s%s%s", root,
+ root[0] != '\0' && root[strlen(root) - 1] == '/' ? "" : "/", name);
+ if(length < 0 || length >= (int)sizeof(path))
+ return false;
+
+ FILE *file = fcaseopen(path, "rb");
+ if(file == nil)
+ return false;
+ fclose(file);
+ return true;
+}
+
+static bool
+SetGameRoot(const char *root, char *path, size_t pathSize)
+{
+ char realRoot[FILEMGR_PATH_SIZE];
+ if(realpath(root, realRoot) == nil ||
+ !GameFileExists(realRoot, "data/gta_vc.dat") ||
+ !GameFileExists(realRoot, "models/gta3.img"))
+ return false;
+
+ int length = snprintf(path, pathSize, "%s/", realRoot);
+ return length >= 0 && length < (int)pathSize;
+}
+
+static bool
+GetExecutableDir(char *path, size_t pathSize)
+{
+ char executable[FILEMGR_PATH_SIZE];
+ uint32 size = sizeof(executable);
+ if(_NSGetExecutablePath(executable, &size) != 0)
+ return false;
+
+ char *slash = strrchr(executable, '/');
+ if(slash == nil)
+ return false;
+ *slash = '\0';
+
+ char realPath[FILEMGR_PATH_SIZE];
+ const char *dir = realpath(executable, realPath) == nil ? executable : realPath;
+ int length = snprintf(path, pathSize, "%s", dir);
+ return length >= 0 && length < (int)pathSize;
+}
+
+static bool
+FindBundledGameFiles(char *path, size_t pathSize)
+{
+ char executableDir[FILEMGR_PATH_SIZE];
+ if(!GetExecutableDir(executableDir, sizeof(executableDir)))
+ return false;
+
+ char bundleDir[FILEMGR_PATH_SIZE];
+ int length = snprintf(bundleDir, sizeof(bundleDir),
+ "%s/../Resources/gamefiles", executableDir);
+ if(length < 0 || length >= (int)sizeof(bundleDir))
+ return false;
+
+ char realBundleDir[FILEMGR_PATH_SIZE];
+ struct stat status;
+ if(realpath(bundleDir, realBundleDir) == nil ||
+ stat(realBundleDir, &status) != 0 || !S_ISDIR(status.st_mode))
+ return false;
+
+ length = snprintf(path, pathSize, "%s", realBundleDir);
+ return length >= 0 && length < (int)pathSize;
+}
+
+static bool
+ReadGameRoot(char *path, size_t pathSize)
+{
+ char root[FILEMGR_PATH_SIZE];
+ if(!ReadGamePathFromINI(root, sizeof(root)))
+ return false;
+ return SetGameRoot(root, path, pathSize);
+}
+
+static void
+WriteGameRoot(const char *root)
+{
+ WriteGamePathToINI(root);
+}
+
+static bool
+ChooseGameRoot(char *path, size_t pathSize)
+{
+ bool retry = false;
+ for(;;){
+ const char *prompt = retry ?
+ "That folder is not a GTA Vice City installation. Choose the folder containing the data and models folders." :
+ "Choose the GTA Vice City installation folder.";
+ char command[512];
+ snprintf(command, sizeof(command),
+ "/usr/bin/osascript -e 'POSIX path of (choose folder with prompt \"%s\")' 2>/dev/null", prompt);
+
+ FILE *pipe = popen(command, "r");
+ if(pipe == nil)
+ return false;
+
+ char root[FILEMGR_PATH_SIZE];
+ bool found = fgets(root, sizeof(root), pipe) != nil;
+ int status = pclose(pipe);
+ if(!found || status != 0)
+ return false;
+
+ root[strcspn(root, "\r\n")] = '\0';
+ if(SetGameRoot(root, path, pathSize)){
+ WriteGameRoot(path);
+ return true;
+ }
+ retry = true;
+ }
+}
+
+static bool
+FindGameRoot(char *path, size_t pathSize)
+{
+ char executableDir[FILEMGR_PATH_SIZE];
+ if(GetExecutableDir(executableDir, sizeof(executableDir))){
+ if(SetGameRoot(executableDir, path, pathSize))
+ return true;
+
+ char defaultRoot[FILEMGR_PATH_SIZE];
+ int length = snprintf(defaultRoot, sizeof(defaultRoot), "%s/../../..", executableDir);
+ if(length >= 0 && length < (int)sizeof(defaultRoot) &&
+ SetGameRoot(defaultRoot, path, pathSize))
+ return true;
+ }
+
+ char cwd[FILEMGR_PATH_SIZE];
+ if(_getcwd(cwd, sizeof(cwd)) != nil && SetGameRoot(cwd, path, pathSize))
+ return true;
+
+ return ReadGameRoot(path, pathSize) || ChooseGameRoot(path, pathSize);
+}
+#endif
+
/* Force file to open as binary but remember if it was text mode */
static int
myfopen(const char *filename, const char *mode)
{
int fd;
char realmode[10], *p;
+ const char *openPath = filename;
+#ifdef __APPLE__
+ char bundledPath[FILEMGR_PATH_SIZE];
+ if(mode[0] == 'r' && strchr(mode, '+') == nil &&
+ CFileMgr::ResolveBundledGameFile(filename, bundledPath, sizeof(bundledPath)))
+ openPath = bundledPath;
+#endif
for(fd = 1; fd < NUMFILES; fd++)
if(myfiles[fd].file == nil)
@@ -83,7 +237,7 @@ myfopen(const char *filename, const char *mode)
*p++ = 'b';
*p = '\0';
- myfiles[fd].file = fcaseopen(filename, realmode);
+ myfiles[fd].file = fcaseopen(openPath, realmode);
if(myfiles[fd].file == nil)
return 0;
return fd;
@@ -206,8 +360,8 @@ myfeof(int fd)
}
-char CFileMgr::ms_rootDirName[128] = {'\0'};
-char CFileMgr::ms_dirName[128];
+char CFileMgr::ms_rootDirName[FILEMGR_PATH_SIZE] = {'\0'};
+char CFileMgr::ms_dirName[FILEMGR_PATH_SIZE];
void
CFileMgr::Initialise(void)
@@ -218,12 +372,64 @@ CFileMgr::Initialise(void)
strcat(ms_rootDirName, "/");
debug("Android: Root Dir: %s\n", ms_rootDirName);
}
+#elif defined(__APPLE__)
+ FindBundledGameFiles(bundledGameFilesDir, sizeof(bundledGameFilesDir));
+ if(ms_rootDirName[0] == '\0' && !FindGameRoot(ms_rootDirName, sizeof(ms_rootDirName)))
+ _exit(0);
+ strcpy(ms_dirName, ms_rootDirName);
+ mychdir(ms_rootDirName);
#else
- _getcwd(ms_rootDirName, 128);
+ _getcwd(ms_rootDirName, sizeof(ms_rootDirName));
strcat(ms_rootDirName, "\\");
#endif
}
+bool
+CFileMgr::ResolveBundledGameFile(const char *file, char *path, size_t pathSize)
+{
+#ifdef __APPLE__
+ const char *rootDir = CFileMgr::GetRootDirName();
+ if(bundledGameFilesDir[0] == '\0' || rootDir[0] == '\0' ||
+ file[0] == '\0' || file[0] == '/' || file[0] == '\\')
+ return false;
+
+ char cwd[FILEMGR_PATH_SIZE];
+ if(_getcwd(cwd, sizeof(cwd)) == nil)
+ return false;
+
+ size_t rootLength = strlen(rootDir);
+ while(rootLength > 0 && rootDir[rootLength - 1] == '/')
+ rootLength--;
+ if(strncmp(cwd, rootDir, rootLength) != 0 ||
+ (cwd[rootLength] != '\0' && cwd[rootLength] != '/'))
+ return false;
+
+ char candidate[FILEMGR_PATH_SIZE];
+ int length = snprintf(candidate, sizeof(candidate), "%s%s/%s",
+ bundledGameFilesDir, cwd + rootLength, file);
+ if(length < 0 || length >= (int)sizeof(candidate))
+ return false;
+
+ char *realPath = casepath(candidate);
+ const char *resolvedPath = realPath == nil ? candidate : realPath;
+ FILE *bundleFile = fopen(resolvedPath, "rb");
+ if(bundleFile == nil){
+ free(realPath);
+ return false;
+ }
+ fclose(bundleFile);
+
+ length = snprintf(path, pathSize, "%s", resolvedPath);
+ free(realPath);
+ return length >= 0 && length < (int)pathSize;
+#else
+ (void)file;
+ (void)path;
+ (void)pathSize;
+ return false;
+#endif
+}
+
void
CFileMgr::ChangeDir(const char *dir)
{
diff --git a/src/core/FileMgr.h b/src/core/FileMgr.h
index a3a392850..745b44b1d 100644
--- a/src/core/FileMgr.h
+++ b/src/core/FileMgr.h
@@ -1,10 +1,12 @@
#ifndef __GTA_FILEMGR_H__
#define __GTA_FILEMGR_H__
+#define FILEMGR_PATH_SIZE 1024
+
class CFileMgr
{
- static char ms_rootDirName[128];
- static char ms_dirName[128];
+ static char ms_rootDirName[FILEMGR_PATH_SIZE];
+ static char ms_dirName[FILEMGR_PATH_SIZE];
public:
static void Initialise(void);
static void ChangeDir(const char *dir);
@@ -20,7 +22,13 @@ class CFileMgr
static bool ReadLine(int fd, char *buf, int len);
static int CloseFile(int fd);
static int GetErrorReadWrite(int fd);
+ static bool ResolveBundledGameFile(const char *file, char *path, size_t pathSize);
static char *GetRootDirName() { return ms_rootDirName; }
};
+#ifdef __APPLE__
+bool ReadGamePathFromINI(char *path, size_t pathSize);
+void WriteGamePathToINI(const char *path);
+#endif
+
#endif // __GTA_FILEMGR_H__
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 35b746312..fe015f412 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -627,19 +627,8 @@ void
CMenuManager::CentreMousePointer()
{
if (SCREEN_WIDTH * 0.5f != 0.0f && 0.0f != SCREEN_HEIGHT * 0.5f) {
-#if defined RW_D3D9 || defined RWLIBS
- tagPOINT Point;
- Point.x = SCREEN_WIDTH / 2;
- Point.y = SCREEN_HEIGHT / 2;
- ClientToScreen(PSGLOBAL(window), &Point);
- SetCursorPos(Point.x, Point.y);
-#elif defined RW_GL3 && !defined(LIBRW_SDL2)
- glfwSetCursorPos(PSGLOBAL(window), SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
-#elif defined(RW_GL3) && defined(LIBRW_SDL2)
- SDL_WarpMouseInWindow(PSGLOBAL(window), SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
-#endif
- PSGLOBAL(lastMousePos.x) = SCREEN_WIDTH / 2;
- PSGLOBAL(lastMousePos.y) = SCREEN_HEIGHT / 2;
+ RwV2d pos = { SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 };
+ RsMouseSetPos(&pos);
}
}
@@ -4866,7 +4855,6 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u
DMAudio.Service();
CentreMousePointer();
m_bShowMouse = true;
- m_nCurrOption = 5; // TODO(Miami): Because selected option is resetted after res. change. We'll need to revisit that.
m_nOptionHighlightTransitionBlend = 0;
SaveSettings();
}
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 39fc146c3..4248f14ae 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -191,6 +191,7 @@ void ReplaceAtomicPipeCallback();
bool
CGame::InitialiseRenderWare(void)
{
+ CFileMgr::SetDir("");
ValidateVersion();
#ifdef USE_TEXTURE_POOL
_TexturePoolsInitialise();
diff --git a/src/core/main.cpp b/src/core/main.cpp
index 7cfb29cf5..a412a9864 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -332,7 +332,7 @@ DoFade(void)
bool
RwGrabScreen(RwCamera *camera, RwChar *filename)
{
- char temp[255];
+ char temp[FILEMGR_PATH_SIZE + 255];
RwImage *pImage = RsGrabScreen(camera);
bool result = true;
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index 901d36afb..d16088fbe 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -197,9 +197,47 @@ CustomFrontendOptionsPopulate(void)
#define MINI_CASE_SENSITIVE
#include "ini.h"
+#ifdef __APPLE__
+static const char *
+GetINIFilePath()
+{
+ static char path[PATH_MAX];
+ int length = snprintf(path, sizeof(path), "%s/reVC.ini", GetMacOSUserFilesFolder());
+ return length >= 0 && length < (int)sizeof(path) ? path : "reVC.ini";
+}
+
+mINI::INIFile ini(GetINIFilePath());
+#else
mINI::INIFile ini("reVC.ini");
+#endif
mINI::INIStructure cfg;
+#ifdef __APPLE__
+bool
+ReadGamePathFromINI(char *path, size_t pathSize)
+{
+ mINI::INIStructure settings;
+ if(!ini.read(settings))
+ return false;
+
+ mINI::INIMap general = settings.get("General");
+ if(!general.has("GamePath"))
+ return false;
+
+ int length = snprintf(path, pathSize, "%s", general.get("GamePath").c_str());
+ return length >= 0 && length < (int)pathSize;
+}
+
+void
+WriteGamePathToINI(const char *path)
+{
+ mINI::INIStructure settings;
+ ini.read(settings);
+ settings["General"]["GamePath"] = path;
+ ini.write(settings);
+}
+#endif
+
bool ReadIniIfExists(const char *cat, const char *key, uint32 *out)
{
mINI::INIMap section = cfg.get(cat);
diff --git a/src/fakerw/fake.cpp b/src/fakerw/fake.cpp
index ee779788d..208c9343f 100644
--- a/src/fakerw/fake.cpp
+++ b/src/fakerw/fake.cpp
@@ -1,15 +1,13 @@
#define _CRT_SECURE_NO_WARNINGS
#define WITH_D3D // not WITHD3D, so it's librw define
-#include
-#include
+#include "common.h"
#include
-#include
-#include
#include
#include
#ifndef _WIN32
#include "crossplatform.h"
#endif
+#include "FileMgr.h"
using namespace rw;
@@ -347,6 +345,7 @@ RwStream *RwStreamOpen(RwStreamType type, RwStreamAccessType accessType, const v
StreamMemory *mem;
RwMemory *memargs;
const char *mode;
+ char bundledPath[FILEMGR_PATH_SIZE];
switch(accessType){
case rwSTREAMREAD: mode = "rb"; break;
@@ -358,6 +357,9 @@ RwStream *RwStreamOpen(RwStreamType type, RwStreamAccessType accessType, const v
// oh god this is horrible. librw streams really need fixing
switch(type){
case rwSTREAMFILENAME:{
+ if(accessType == rwSTREAMREAD &&
+ CFileMgr::ResolveBundledGameFile((const char*)pData, bundledPath, sizeof(bundledPath)))
+ pData = bundledPath;
StreamFile fakefile;
file = rwNewT(StreamFile, 1, 0);
memcpy(file, &fakefile, sizeof(StreamFile));
diff --git a/src/save/PCSave.cpp b/src/save/PCSave.cpp
index 9fc0b2d87..8e6b9d3d6 100644
--- a/src/save/PCSave.cpp
+++ b/src/save/PCSave.cpp
@@ -19,9 +19,11 @@ C_PcSave PcSaveHelper;
void
C_PcSave::SetSaveDirectory(const char *path)
{
-#if defined ANDROID
+#if defined ANDROID || defined __APPLE__
sprintf(DefaultPCSaveFileName, "%s/%s", path, "GTAVCsf");
+#if defined ANDROID
debug("SetSaveDirectory: %s", DefaultPCSaveFileName);
+#endif
#else
sprintf(DefaultPCSaveFileName, "%s\\%s", path, "GTAVCsf");
#endif
diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp
index 99ec599d2..5af59d817 100644
--- a/src/skel/crossplatform.cpp
+++ b/src/skel/crossplatform.cpp
@@ -2,6 +2,62 @@
#include "crossplatform.h"
#include "FileMgr.h"
+#ifdef __APPLE__
+#include
+#include
+#include
+#include
+
+static bool
+CreateDirectoryTree(const char *path)
+{
+ char current[PATH_MAX];
+ int length = snprintf(current, sizeof(current), "%s", path);
+ if(length < 0 || length >= (int)sizeof(current))
+ return false;
+
+ for(char *separator = current + 1; *separator != '\0'; separator++){
+ if(*separator != '/')
+ continue;
+
+ *separator = '\0';
+ if(mkdir(current, 0755) != 0 && errno != EEXIST){
+ *separator = '/';
+ return false;
+ }
+ *separator = '/';
+ }
+
+ return mkdir(current, 0755) == 0 || errno == EEXIST;
+}
+
+const char *
+GetMacOSUserFilesFolder()
+{
+ static char path[PATH_MAX];
+ const char *home = getenv("HOME");
+ if(home == nil || home[0] == '\0'){
+ struct passwd *user = getpwuid(getuid());
+ home = user == nil ? nil : user->pw_dir;
+ }
+ if(home == nil || home[0] == '\0')
+ return "userfiles";
+
+#ifdef USE_MY_DOCUMENTS
+ const char *relativePath = "Library/Application Support/Grand Theft Auto - Vice City/p_drive/Documents/GTA Vice City User Files";
+#else
+ const char *relativePath = "Library/Application Support/reVC";
+#endif
+ int length = snprintf(path, sizeof(path), "%s/%s", home, relativePath);
+ if(length < 0 || length >= (int)sizeof(path))
+ return "userfiles";
+
+ if(!CreateDirectoryTree(path))
+ debug("Couldn't create macOS user files directory: %s\n", path);
+ return path;
+}
+#endif
+
// Codes compatible with Windows and Linux
#ifndef _WIN32
diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h
index e48d3b2c4..8b617b598 100644
--- a/src/skel/crossplatform.h
+++ b/src/skel/crossplatform.h
@@ -1,3 +1,6 @@
+#ifndef __GTA_CROSSPLATFORM_H__
+#define __GTA_CROSSPLATFORM_H__
+
#ifndef GTA_PS2
#include
@@ -110,6 +113,10 @@ extern RwUInt32 gGameState;
RwBool IsForegroundApp();
+#ifdef __APPLE__
+const char *GetMacOSUserFilesFolder();
+#endif
+
#ifndef MAX_PATH
#if !defined _WIN32 || defined __MINGW32__
#define MAX_PATH PATH_MAX
@@ -199,3 +206,5 @@ void GetDateFormat(int, int, SYSTEMTIME*, int, char*, int);
#endif
#endif
+
+#endif // __GTA_CROSSPLATFORM_H__
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index 906318411..9cbfc759e 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -78,6 +78,7 @@ static RwBool RwInitialised = FALSE;
static RwSubSystemInfo GsubSysInfo[MAX_SUBSYSTEMS];
static RwInt32 GnumSubSystems = 0;
static RwInt32 GcurSel = 0, GcurSelVM = 0;
+static RwInt32 desktopWidth = 0, desktopHeight = 0;
static RwBool useDefault;
@@ -167,6 +168,8 @@ const char *_psGetUserFilesFolder()
strcpy(szUserFiles, "data");
return szUserFiles;
+#elif defined __APPLE__
+ return GetMacOSUserFilesFolder();
#else
static char szUserFiles[256];
strcpy(szUserFiles, "userfiles");
@@ -276,8 +279,20 @@ psTimer(void)
void
psMouseSetPos(RwV2d *pos)
{
- glfwSetCursorPos(PSGLOBAL(window), pos->x, pos->y);
-
+ int winw, winh;
+ glfwGetWindowSize(PSGLOBAL(window), &winw, &winh);
+ glfwSetCursorPos(PSGLOBAL(window),
+ pos->x * (double)winw / RsGlobal.maximumWidth,
+ pos->y * (double)winh / RsGlobal.maximumHeight);
+ FrontEndMenuManager.m_nMouseTempPosX = pos->x;
+ FrontEndMenuManager.m_nMouseTempPosY = pos->y;
+ FrontEndMenuManager.m_nMousePosX = pos->x;
+ FrontEndMenuManager.m_nMousePosY = pos->y;
+ FrontEndMenuManager.m_nMouseOldPosX = pos->x;
+ FrontEndMenuManager.m_nMouseOldPosY = pos->y;
+ if (glfwGetWindowAttrib(PSGLOBAL(window), GLFW_FOCUSED))
+ PSGLOBAL(cursorIsInWindow) = true;
+
PSGLOBAL(lastMousePos.x) = (RwInt32)pos->x;
PSGLOBAL(lastMousePos.y) = (RwInt32)pos->y;
@@ -745,7 +760,12 @@ psSelectDevice()
RwVideoMode vm;
RwInt32 subSysNum;
RwInt32 AutoRenderer = 0;
-
+
+ const GLFWvidmode *desktopMode = glfwGetVideoMode(glfwGetPrimaryMonitor());
+ if (desktopMode) {
+ desktopWidth = desktopMode->width;
+ desktopHeight = desktopMode->height;
+ }
RwBool modeFound = FALSE;
@@ -834,16 +854,16 @@ psSelectDevice()
if(FrontEndMenuManager.m_nPrefsWidth == 0 ||
FrontEndMenuManager.m_nPrefsHeight == 0 ||
FrontEndMenuManager.m_nPrefsDepth == 0){
- // Defaults if nothing specified
const GLFWvidmode *mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
FrontEndMenuManager.m_nPrefsWidth = mode->width;
FrontEndMenuManager.m_nPrefsHeight = mode->height;
FrontEndMenuManager.m_nPrefsDepth = 32;
- FrontEndMenuManager.m_nPrefsWindowed = 0;
}
// Find the videomode that best fits what we got from the settings file
+ bestWndMode = -1;
RwInt32 bestFsMode = -1;
+ RwInt32 firstFsMode = -1;
RwInt32 bestWidth = -1;
RwInt32 bestHeight = -1;
RwInt32 bestDepth = -1;
@@ -853,6 +873,8 @@ psSelectDevice()
if (!(vm.flags & rwVIDEOMODEEXCLUSIVE)){
bestWndMode = GcurSelVM;
} else {
+ if(firstFsMode < 0)
+ firstFsMode = GcurSelVM;
// try the largest one that isn't larger than what we wanted
if(vm.width >= bestWidth && vm.width <= FrontEndMenuManager.m_nPrefsWidth &&
vm.height >= bestHeight && vm.height <= FrontEndMenuManager.m_nPrefsHeight &&
@@ -865,33 +887,47 @@ psSelectDevice()
}
}
- if(bestFsMode < 0){
+ RwInt32 selectedFsMode = bestFsMode >= 0 ? bestFsMode : firstFsMode;
+ GcurSelVM = selectedFsMode;
+ if(GcurSelVM < 0 && FrontEndMenuManager.m_nPrefsWindowed)
+ GcurSelVM = bestWndMode;
+ if(GcurSelVM < 0){
printf("WARNING: Cannot find desired video mode, selecting device cancelled\n");
return FALSE;
}
- GcurSelVM = bestFsMode;
- FrontEndMenuManager.m_nDisplayVideoMode = GcurSelVM;
- FrontEndMenuManager.m_nPrefsVideoMode = FrontEndMenuManager.m_nDisplayVideoMode;
+ if(selectedFsMode >= 0){
+ FrontEndMenuManager.m_nDisplayVideoMode = selectedFsMode;
+ FrontEndMenuManager.m_nPrefsVideoMode = FrontEndMenuManager.m_nDisplayVideoMode;
+ }
FrontEndMenuManager.m_nSelectedScreenMode = FrontEndMenuManager.m_nPrefsWindowed;
}
#endif
+#ifdef IMPROVED_VIDEOMODE
+ if (FrontEndMenuManager.m_nPrefsWindowed && bestWndMode < 0){
+ printf("WARNING: Cannot find windowed video mode, selecting device cancelled\n");
+ return FALSE;
+ }
+#endif
+
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
#ifdef IMPROVED_VIDEOMODE
+ if ((!FrontEndMenuManager.m_nPrefsWindowed || (vm.flags & rwVIDEOMODEEXCLUSIVE)) &&
+ vm.width > 0 && vm.height > 0 && vm.depth > 0) {
+ FrontEndMenuManager.m_nPrefsWidth = vm.width;
+ FrontEndMenuManager.m_nPrefsHeight = vm.height;
+ FrontEndMenuManager.m_nPrefsDepth = vm.depth;
+ }
if (FrontEndMenuManager.m_nPrefsWindowed)
GcurSelVM = bestWndMode;
-
- // Now GcurSelVM is 0 but vm has sizes(and fullscreen flag) of the video mode we want, that's why we changed the rwVIDEOMODEEXCLUSIVE conditions below
- FrontEndMenuManager.m_nPrefsWidth = vm.width;
- FrontEndMenuManager.m_nPrefsHeight = vm.height;
- FrontEndMenuManager.m_nPrefsDepth = vm.depth;
#endif
#ifndef PS2_MENU
- FrontEndMenuManager.m_nCurrOption = 0;
+ if (!useDefault)
+ FrontEndMenuManager.m_nCurrOption = 0;
#endif
/* Set up the video mode and set the apps window
@@ -975,8 +1011,11 @@ void _InputInitialiseJoys()
PSGLOBAL(joy2id) = -1;
// Load our gamepad mappings.
-#define SDL_GAMEPAD_DB_PATH "gamecontrollerdb.txt"
- FILE *f = fopen(SDL_GAMEPAD_DB_PATH, "rb");
+ char bundledPath[FILEMGR_PATH_SIZE];
+ const char *gamepadDbPath = CFileMgr::ResolveBundledGameFile(
+ "gamecontrollerdb.txt", bundledPath, sizeof(bundledPath)) ?
+ bundledPath : "gamecontrollerdb.txt";
+ FILE *f = fcaseopen(gamepadDbPath, "rb");
if (f) {
fseek(f, 0, SEEK_END);
size_t fsize = ftell(f);
@@ -987,16 +1026,14 @@ void _InputInitialiseJoys()
db[fsize] = '\0';
if (glfwUpdateGamepadMappings(db) == GLFW_FALSE)
- Error("glfwUpdateGamepadMappings didn't succeed, check " SDL_GAMEPAD_DB_PATH ".\n");
+ Error("glfwUpdateGamepadMappings didn't succeed, check %s.\n", gamepadDbPath);
} else
- Error("fread on " SDL_GAMEPAD_DB_PATH " wasn't successful.\n");
+ Error("fread on %s wasn't successful.\n", gamepadDbPath);
free(db);
fclose(f);
} else
- printf("You don't seem to have copied " SDL_GAMEPAD_DB_PATH " file from reVC/gamefiles to GTA: Vice City directory. Some gamepads may not be recognized.\n");
-
-#undef SDL_GAMEPAD_DB_PATH
+ printf("You don't seem to have copied %s file from reVC/gamefiles to GTA: Vice City directory. Some gamepads may not be recognized.\n", gamepadDbPath);
// But always overwrite it with the one in SDL_GAMECONTROLLERCONFIG.
char const* EnvControlConfig = getenv("SDL_GAMECONTROLLERCONFIG");
@@ -1031,12 +1068,22 @@ long _InputInitialiseMouse(bool exclusive)
// Disabled = keep cursor centered and hide
lastCursorMode = exclusive ? GLFW_CURSOR_DISABLED : GLFW_CURSOR_HIDDEN;
glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, lastCursorMode);
+ if (exclusive && glfwGetWindowAttrib(PSGLOBAL(window), GLFW_FOCUSED))
+ PSGLOBAL(cursorIsInWindow) = true;
return 0;
}
void _InputShutdownMouse()
{
- // Not needed
+ lastCursorMode = GLFW_CURSOR_NORMAL;
+ glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, lastCursorMode);
+}
+
+static void
+centreMouseForDesktop()
+{
+ if (desktopWidth > 0 && desktopHeight > 0)
+ glfwSetCursorPos(PSGLOBAL(window), desktopWidth * 0.5, desktopHeight * 0.5);
}
// Not "needs exclusive" on GLFW, but more like "needs to change mode"
@@ -1087,7 +1134,9 @@ void psPostRWinit(void)
RwBool _psSetVideoMode(RwInt32 subSystem, RwInt32 videoMode)
{
RwInitialised = FALSE;
-
+
+ _InputShutdownMouse();
+ centreMouseForDesktop();
RsEventHandler(rsRWTERMINATE, nil);
GcurSel = subSystem;
@@ -1845,8 +1894,8 @@ cursorCB(GLFWwindow* window, double xpos, double ypos) {
int winw, winh;
glfwGetWindowSize(PSGLOBAL(window), &winw, &winh);
- FrontEndMenuManager.m_nMouseTempPosX = xpos * (RsGlobal.maximumWidth / winw);
- FrontEndMenuManager.m_nMouseTempPosY = ypos * (RsGlobal.maximumHeight / winh);
+ FrontEndMenuManager.m_nMouseTempPosX = xpos * ((double)RsGlobal.maximumWidth / winw);
+ FrontEndMenuManager.m_nMouseTempPosY = ypos * ((double)RsGlobal.maximumHeight / winh);
}
void
@@ -1857,6 +1906,10 @@ cursorEnterCB(GLFWwindow* window, int entered) {
void
windowFocusCB(GLFWwindow* window, int focused) {
WindowFocused = !!focused;
+ if (!focused)
+ PSGLOBAL(cursorIsInWindow) = false;
+ else if (lastCursorMode == GLFW_CURSOR_DISABLED || glfwGetWindowAttrib(window, GLFW_HOVERED))
+ PSGLOBAL(cursorIsInWindow) = true;
}
void
@@ -2445,6 +2498,8 @@ main(int argc, char *argv[])
/*
* Tidy up the 3D (RenderWare) components of the application...
*/
+ _InputShutdownMouse();
+ centreMouseForDesktop();
RsEventHandler(rsRWTERMINATE, nil);
/*
diff --git a/src/skel/sdl2/sdl2.cpp b/src/skel/sdl2/sdl2.cpp
index 47b943f39..6fe71c790 100644
--- a/src/skel/sdl2/sdl2.cpp
+++ b/src/skel/sdl2/sdl2.cpp
@@ -106,10 +106,14 @@ void _psCreateFolder(const char *path)
*/
const char *_psGetUserFilesFolder()
{
+#ifdef __APPLE__
+ return GetMacOSUserFilesFolder();
+#else
static char szUserFiles[256];
strcpy(szUserFiles, "userfiles");
_psCreateFolder(szUserFiles);
return szUserFiles;
+#endif
}
/*
@@ -617,7 +621,8 @@ psSelectDevice()
#endif
#ifndef PS2_MENU
- FrontEndMenuManager.m_nCurrOption = 0;
+ if (!useDefault)
+ FrontEndMenuManager.m_nCurrOption = 0;
#endif
/* Set up the video mode and set the apps window
@@ -703,7 +708,10 @@ void _InputInitialiseJoys()
char SDL_GAMEPAD_DB_PATH[MAX_PATH];
snprintf(SDL_GAMEPAD_DB_PATH, sizeof(SDL_GAMEPAD_DB_PATH), "%s%s", pathRoot, "gamecontrollerdb.txt");
#else
- const char* SDL_GAMEPAD_DB_PATH = "gamecontrollerdb.txt";
+ char bundledPath[FILEMGR_PATH_SIZE];
+ const char* SDL_GAMEPAD_DB_PATH = CFileMgr::ResolveBundledGameFile(
+ "gamecontrollerdb.txt", bundledPath, sizeof(bundledPath)) ?
+ bundledPath : "gamecontrollerdb.txt";
#endif
if (SDL_GameControllerAddMappingsFromFile(SDL_GAMEPAD_DB_PATH) <= 0) {
debug ("You don't seem to have copied %s file from reVC/gamefiles "
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index c49f0ab96..3e7a26c4e 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -1566,7 +1566,8 @@ psSelectDevice()
#endif
#ifndef PS2_MENU
- FrontEndMenuManager.m_nCurrOption = 0;
+ if (!useDefault)
+ FrontEndMenuManager.m_nCurrOption = 0;
#endif
/* Set up the video mode and set the apps window