Various updates to make the application compile on macOS.

This commit is contained in:
Leon Styhre 2020-08-17 19:15:05 +02:00
parent 6dd1078e09
commit ad960b28ac
19 changed files with 165 additions and 110 deletions

View file

@ -12,12 +12,12 @@
include(FindPkgMacros) include(FindPkgMacros)
if (NOT WIN32) if (NOT WIN32)
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(PUGIXML REQUIRED pugixml>=1.09) pkg_check_modules(PUGIXML REQUIRED pugixml>=1.09)
endif (NOT WIN32) endif (NOT WIN32)
if (WIN32) if (WIN32)
find_path(PUGIXML_INCLUDE_DIR pugixml.hpp) find_path(PUGIXML_INCLUDE_DIR pugixml.hpp)
# Support the REQUIRED and QUIET arguments, and set PUGIXML_FOUND if found. # Support the REQUIRED and QUIET arguments, and set PUGIXML_FOUND if found.
include (FindPackageHandleStandardArgs) include (FindPackageHandleStandardArgs)

View file

@ -14,7 +14,7 @@ if (NOT WIN32)
endif (NOT WIN32) endif (NOT WIN32)
if (WIN32) if (WIN32)
find_path(RAPIDJSON_INCLUDE_DIR rapidjson/rapidjson.h) find_path(RAPIDJSON_INCLUDE_DIR rapidjson/rapidjson.h)
# Support the REQUIRED and QUIET arguments, and set RAPIDJSON_FOUND if found. # Support the REQUIRED and QUIET arguments, and set RAPIDJSON_FOUND if found.
include (FindPackageHandleStandardArgs) include (FindPackageHandleStandardArgs)
@ -22,7 +22,7 @@ include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(RAPIDJSON DEFAULT_MSG RAPIDJSON_INCLUDE_DIR) find_package_handle_standard_args(RAPIDJSON DEFAULT_MSG RAPIDJSON_INCLUDE_DIR)
if (NOT RAPIDJSON_INCLUDE_DIR) if (NOT RAPIDJSON_INCLUDE_DIR)
message(FATAL_ERROR "RapidJSON include files not found!") message(FATAL_ERROR "RapidJSON include files not found!")
endif() endif()
endif (WIN32) endif (WIN32)

View file

@ -15,45 +15,43 @@
# #
if(VLC_INCLUDE_DIR AND VLC_LIBRARIES) if(VLC_INCLUDE_DIR AND VLC_LIBRARIES)
# in cache already # In cache already
set(VLC_FIND_QUIETLY TRUE) set(VLC_FIND_QUIETLY TRUE)
endif(VLC_INCLUDE_DIR AND VLC_LIBRARIES) endif(VLC_INCLUDE_DIR AND VLC_LIBRARIES)
# use pkg-config to get the directories and then use these values # use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls # in the FIND_PATH() and FIND_LIBRARY() calls
if(NOT WIN32) if(NOT WIN32 AND NOT APPLE)
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(VLC REQUIRED libvlc>=3.0.0) pkg_check_modules(VLC REQUIRED libvlc>=3.0.0)
set(VLC_DEFINITIONS ${VLC_CFLAGS}) set(VLC_DEFINITIONS ${VLC_CFLAGS})
set(VLC_LIBRARIES ${VLC_LDFLAGS}) set(VLC_LIBRARIES ${VLC_LDFLAGS})
endif(NOT WIN32) endif(NOT WIN32 AND NOT APPLE)
if (WIN32) if(WIN32)
# TODO add argument support to pass version on find_package
include(MacroEnsureVersion)
macro_ensure_version(3.0.0 ${VLC_VERSION} VLC_VERSION_OK)
if(VLC_VERSION_OK)
set(VLC_FOUND TRUE)
message(STATUS "VLC library found")
else(VLC_VERSION_OK)
set(VLC_FOUND FALSE)
message(FATAL_ERROR "VLC library not found")
endif(VLC_VERSION_OK)
# TODO add argument support to pass version on find_package find_path(VLC_INCLUDE_DIR
include(MacroEnsureVersion) NAMES vlc.h
macro_ensure_version(3.0.0 ${VLC_VERSION} VLC_VERSION_OK) PATHS ${VLC_INCLUDE_DIRS}
if(VLC_VERSION_OK) PATH_SUFFIXES vlc)
set(VLC_FOUND TRUE)
message(STATUS "VLC library found")
else(VLC_VERSION_OK)
set(VLC_FOUND FALSE)
message(FATAL_ERROR "VLC library not found")
endif(VLC_VERSION_OK)
find_path(VLC_INCLUDE_DIR find_library(VLC_LIBRARIES
NAMES vlc.h NAMES vlc
PATHS ${VLC_INCLUDE_DIRS} PATHS ${VLC_LIBRARY_DIRS})
PATH_SUFFIXES vlc)
find_library(VLC_LIBRARIES include(FindPackageHandleStandardArgs)
NAMES vlc find_package_handle_standard_args(VLC DEFAULT_MSG VLC_INCLUDE_DIR VLC_LIBRARIES)
PATHS ${VLC_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(VLC DEFAULT_MSG VLC_INCLUDE_DIR VLC_LIBRARIES)
# show the VLC_INCLUDE_DIR and VLC_LIBRARIES variables only in the advanced view
mark_as_advanced(VLC_INCLUDE_DIR VLC_LIBRARIES)
# show the VLC_INCLUDE_DIR and VLC_LIBRARIES variables only in the advanced view
mark_as_advanced(VLC_INCLUDE_DIR VLC_LIBRARIES)
endif (WIN32) endif (WIN32)

View file

@ -62,12 +62,18 @@ if(NOT WIN32)
find_package(CURL REQUIRED) find_package(CURL REQUIRED)
find_package(FreeImage REQUIRED) find_package(FreeImage REQUIRED)
find_package(Freetype REQUIRED) find_package(Freetype REQUIRED)
find_package(Pugixml REQUIRED)
find_package(RapidJSON REQUIRED) find_package(RapidJSON REQUIRED)
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
find_package(VLC REQUIRED) find_package(VLC REQUIRED)
endif() endif()
if(APPLE)
# For some strange reason, macOS complains about an uppercase 'P' in Pugixml.
find_package(pugixml REQUIRED)
elseif(UNIX)
find_package(Pugixml REQUIRED)
endif()
# Add libCEC support. # Add libCEC support.
if(CEC) if(CEC)
find_package(libCEC REQUIRED) find_package(libCEC REQUIRED)
@ -96,8 +102,8 @@ endif()
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
message("-- Compiler is Clang/LLVM") message("-- Compiler is Clang/LLVM")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION) execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION)
if(CLANG_VERSION VERSION_LESS 6.0.0) if(CLANG_VERSION VERSION_LESS 4.2.1)
message(SEND_ERROR "You need at least Clang 6.0.0 to compile EmulationStation-DE!") message(SEND_ERROR "You need at least Clang 4.2.1 to compile EmulationStation-DE!")
endif() endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message("-- Compiler is GNU/GCC") message("-- Compiler is GNU/GCC")
@ -118,30 +124,39 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O0") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O0")
# If using Clang, then add additional debug data needed by GDB. # If using Clang, then add additional debug data needed by GDB.
# Comment this out if you're using LLDB for debugging as this flag makes # Comment this out if you're using LLDB for debugging as this flag makes the binary
# the binary much larger and the application much slower. # much larger and the application much slower. On macoOS this setting is never enabled
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # as LLDB is the default debugger on this OS.
if(NOT APPLE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_DEBUG") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_DEBUG")
endif() endif()
else() else()
# Enable the C++11 standard and enable optimizations as it's a release build. # Enable the C++11 standard and enable optimizations as it's a release build.
# Also disable the assert() macros and strip the binary. # This will also disable all assert() macros. Strip the binary as well.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -DNDEBUG") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -DNDEBUG")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2 -s") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2 -s")
endif() endif()
# This removes half of the ranlib warnings on macOS regarding no symbols for files that
# are #ifdef'ed away. There must be a way to remove the other half as well?
if(APPLE)
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
SET(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
endif()
if(${GLSystem} MATCHES "Desktop OpenGL") if(${GLSystem} MATCHES "Desktop OpenGL")
add_definitions(-DUSE_OPENGL_21) add_definitions(-DUSE_OPENGL_21)
else() else()
add_definitions(-DUSE_OPENGLES_10) add_definitions(-DUSE_OPENGLES_10)
endif() endif()
# For Unix systems, assign the installation prefix to local $ES_INSTALL_PREFIX variable. # For Unix systems (except for macOS), assign the installation prefix to the local
if(NOT WIN32) # $ES_INSTALL_PREFIX variable.
if(NOT WIN32 AND NOT APPLE)
add_definitions(-DES_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}") add_definitions(-DES_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
endif() endif()
# Handle additional (required) include files for dependency packages. # Handle additional (required) include files for dependency packages on Windows.
if(WIN32) if(WIN32)
set(WIN32_INCLUDE_DIR "NOT_DEFINED" CACHE FILEPATH "") set(WIN32_INCLUDE_DIR "NOT_DEFINED" CACHE FILEPATH "")
if(NOT EXISTS ${WIN32_INCLUDE_DIR}) if(NOT EXISTS ${WIN32_INCLUDE_DIR})
@ -163,6 +178,12 @@ set(COMMON_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/external
${CMAKE_CURRENT_SOURCE_DIR}/es-core/src) ${CMAKE_CURRENT_SOURCE_DIR}/es-core/src)
# Temporary solution until the VLC find module has been updated to work properly on macOS.
if(APPLE)
set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS}
"/Applications/VLC.app/Contents/MacOS/include")
endif()
if(WIN32) if(WIN32)
set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS} ${WIN32_INCLUDE_DIR}) set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS} ${WIN32_INCLUDE_DIR})
endif() endif()
@ -226,6 +247,12 @@ elseif(WIN32)
"nanosvg") "nanosvg")
endif() endif()
# Temporary solution until the VLC find module has been updated to work properly on macOS.
if (APPLE)
set(COMMON_LIBRARIES ${COMMON_LIBRARIES}
"/Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib")
endif()
# Add libCEC libraries. # Add libCEC libraries.
if(DEFINED libCEC_FOUND) if(DEFINED libCEC_FOUND)
if(DEFINED BCMHOST) if(DEFINED BCMHOST)

View file

@ -8,6 +8,10 @@
#ifndef ES_APP_FILE_FILTER_INDEX_H #ifndef ES_APP_FILE_FILTER_INDEX_H
#define ES_APP_FILE_FILTER_INDEX_H #define ES_APP_FILE_FILTER_INDEX_H
#if defined(__APPLE__)
#include <sstream>
#endif
#include <map> #include <map>
#include <vector> #include <vector>

View file

@ -9,6 +9,10 @@
#ifndef ES_APP_META_DATA_H #ifndef ES_APP_META_DATA_H
#define ES_APP_META_DATA_H #define ES_APP_META_DATA_H
#if defined(__APPLE__)
#include <sstream>
#endif
#include <map> #include <map>
#include <vector> #include <vector>

View file

@ -365,7 +365,7 @@ bool SystemData::copyConfigTemplate(const std::string& path)
#if defined (_WIN64) #if defined (_WIN64)
systemsTemplateFile = ResourceManager::getInstance()-> systemsTemplateFile = ResourceManager::getInstance()->
getResourcePath(":/templates/es_systems.cfg_windows"); getResourcePath(":/templates/es_systems.cfg_windows");
#elif defined(__unix__) #elif defined(__unix__) || defined (__APPLE__)
systemsTemplateFile = ResourceManager::getInstance()-> systemsTemplateFile = ResourceManager::getInstance()->
getResourcePath(":/templates/es_systems.cfg_unix"); getResourcePath(":/templates/es_systems.cfg_unix");
#endif #endif

View file

@ -9,11 +9,11 @@
#include "math/Misc.h" #include "math/Misc.h"
#include "Log.h" #include "Log.h"
#ifdef _RPI_ #if defined(_RPI_)
#include "Settings.h" #include "Settings.h"
#endif #endif
#ifdef _WIN64 #if defined(_WIN64)
#include <mmdeviceapi.h> #include <mmdeviceapi.h>
#endif #endif
@ -40,8 +40,8 @@ std::weak_ptr<VolumeControl> VolumeControl::sInstance;
VolumeControl::VolumeControl() VolumeControl::VolumeControl()
: originalVolume(0), : originalVolume(0),
internalVolume(0) internalVolume(0)
#if defined (__APPLE__) #if defined(__APPLE__)
#error TODO: Not implemented for MacOS yet!!! // #error TODO: Not implemented for MacOS yet!!!
#elif defined(__linux__) #elif defined(__linux__)
, mixerIndex(0), , mixerIndex(0),
mixerHandle(nullptr), mixerHandle(nullptr),
@ -62,8 +62,8 @@ VolumeControl::VolumeControl(
const VolumeControl & right): const VolumeControl & right):
originalVolume(0), originalVolume(0),
internalVolume(0) internalVolume(0)
#if defined (__APPLE__) #if defined(__APPLE__)
#error TODO: Not implemented for MacOS yet!!! // #error TODO: Not implemented for MacOS yet!!!
#elif defined(__linux__) #elif defined(__linux__)
, mixerIndex(0), , mixerIndex(0),
mixerHandle(nullptr), mixerHandle(nullptr),
@ -108,8 +108,8 @@ std::shared_ptr<VolumeControl> & VolumeControl::getInstance()
void VolumeControl::init() void VolumeControl::init()
{ {
// Initialize audio mixer interface. // Initialize audio mixer interface.
#if defined (__APPLE__) #if defined(__APPLE__)
#error TODO: Not implemented for MacOS yet!!! // #error TODO: Not implemented for MacOS yet!!!
#elif defined(__linux__) #elif defined(__linux__)
// Try to open mixer device. // Try to open mixer device.
if (mixerHandle == nullptr) { if (mixerHandle == nullptr) {
@ -248,8 +248,8 @@ void VolumeControl::init()
void VolumeControl::deinit() void VolumeControl::deinit()
{ {
// Deinitialize audio mixer interface. // Deinitialize audio mixer interface.
#if defined (__APPLE__) #if defined(__APPLE__)
#error TODO: Not implemented for MacOS yet!!! // #error TODO: Not implemented for MacOS yet!!!
#elif defined(__linux__) #elif defined(__linux__)
if (mixerHandle != nullptr) { if (mixerHandle != nullptr) {
snd_mixer_detach(mixerHandle, mixerCard); snd_mixer_detach(mixerHandle, mixerCard);
@ -275,8 +275,8 @@ int VolumeControl::getVolume() const
{ {
int volume = 0; int volume = 0;
#if defined (__APPLE__) #if defined(__APPLE__)
#error TODO: Not implemented for MacOS yet!!! // #error TODO: Not implemented for MacOS yet!!!
#elif defined(__linux__) #elif defined(__linux__)
if (mixerElem != nullptr) { if (mixerElem != nullptr) {
// Get volume range. // Get volume range.
@ -352,8 +352,8 @@ void VolumeControl::setVolume(int volume)
// Store values in internal variables. // Store values in internal variables.
internalVolume = volume; internalVolume = volume;
#if defined (__APPLE__) #if defined(__APPLE__)
#error TODO: Not implemented for MacOS yet!!! // #error TODO: Not implemented for MacOS yet!!!
#elif defined(__linux__) #elif defined(__linux__)
if (mixerElem != nullptr) { if (mixerElem != nullptr) {
// Get volume range. // Get volume range.

View file

@ -10,8 +10,8 @@
#include <memory> #include <memory>
#if defined (__APPLE__) #if defined(__APPLE__)
#error TODO: Not implemented for MacOS yet!!! //#error TODO: Not implemented for MacOS yet!!!
#elif defined(__linux__) #elif defined(__linux__)
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
@ -25,8 +25,8 @@
// Singleton pattern. Call getInstance() to get an object. // Singleton pattern. Call getInstance() to get an object.
class VolumeControl class VolumeControl
{ {
#if defined (__APPLE__) #if defined(__APPLE__)
#error TODO: Not implemented for MacOS yet!!! // #error TODO: Not implemented for MacOS yet!!!
#elif defined(__linux__) #elif defined(__linux__)
static const char * mixerName; static const char * mixerName;
static const char * mixerCard; static const char * mixerCard;

View file

@ -33,7 +33,7 @@
#include "SystemData.h" #include "SystemData.h"
#include "SystemScreenSaver.h" #include "SystemScreenSaver.h"
#ifdef _WIN64 #if defined(_WIN64)
#include <cstring> #include <cstring>
#include <windows.h> #include <windows.h>
#endif #endif
@ -597,7 +597,7 @@ int main(int argc, char* argv[])
// Check if the media directory exists, and if not, log a warning. // Check if the media directory exists, and if not, log a warning.
if (!Utils::FileSystem::isDirectory(FileData::getMediaDirectory()) || if (!Utils::FileSystem::isDirectory(FileData::getMediaDirectory()) ||
Utils::FileSystem::isSymlink(FileData::getMediaDirectory())) { Utils::FileSystem::isSymlink(FileData::getMediaDirectory())) {
LOG(LogWarning) << "Games media directory does not exist " LOG(LogWarning) << "Game media directory does not exist "
"(or is not a directory or a symlink):"; "(or is not a directory or a symlink):";
LOG(LogWarning) << FileData::getMediaDirectory(); LOG(LogWarning) << FileData::getMediaDirectory();
} }

View file

@ -248,11 +248,11 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
// It's one of these... // It's one of these...
float endPos = target; // Directly. float endPos = target; // Directly.
float dist = abs(endPos - startPos); float dist = fabs(endPos - startPos);
if (abs(target + posMax - startPos - mScrollVelocity) < dist) if (fabs(target + posMax - startPos - mScrollVelocity) < dist)
endPos = target + posMax; // Loop around the end (0 -> max). endPos = target + posMax; // Loop around the end (0 -> max).
if (abs(target - posMax - startPos - mScrollVelocity) < dist) if (fabs(target - posMax - startPos - mScrollVelocity) < dist)
endPos = target - posMax; // Loop around the start (max - 1 -> -1). endPos = target - posMax; // Loop around the start (max - 1 -> -1).
// Animate mSystemInfo's opacity (fade out, wait, fade back in). // Animate mSystemInfo's opacity (fade out, wait, fade back in).
@ -541,11 +541,11 @@ void SystemView::renderCarousel(const Transform4x4f& trans)
float distance = i - mCamOffset; float distance = i - mCamOffset;
float scale = 1.0f + ((mCarousel.logoScale - 1.0f) * (1.0f - abs(distance))); float scale = 1.0f + ((mCarousel.logoScale - 1.0f) * (1.0f - fabs(distance)));
scale = Math::min(mCarousel.logoScale, Math::max(1.0f, scale)); scale = Math::min(mCarousel.logoScale, Math::max(1.0f, scale));
scale /= mCarousel.logoScale; scale /= mCarousel.logoScale;
int opacity = (int)Math::round(0x80 + ((0xFF - 0x80) * (1.0f - abs(distance)))); int opacity = (int)Math::round(0x80 + ((0xFF - 0x80) * (1.0f - fabs(distance))));
opacity = Math::max((int) 0x80, opacity); opacity = Math::max((int) 0x80, opacity);
const std::shared_ptr<GuiComponent> &comp = mEntries.at(index).data.logo; const std::shared_ptr<GuiComponent> &comp = mEntries.at(index).data.logo;

View file

@ -9,6 +9,10 @@
#include "AudioManager.h" #include "AudioManager.h"
#include "Settings.h" #include "Settings.h"
#if defined(__APPLE__)
#include <sstream>
#endif
bool PowerSaver::mState = false; bool PowerSaver::mState = false;
bool PowerSaver::mRunningScreenSaver = false; bool PowerSaver::mRunningScreenSaver = false;

View file

@ -172,7 +172,7 @@ void Settings::setDefaults()
#else #else
mIntMap["MaxVRAM"] = 128; mIntMap["MaxVRAM"] = 128;
#endif #endif
#ifdef __unix__ #if defined (__unix__) || defined (__APPLE__)
mStringMap["FullscreenMode"] = "normal"; mStringMap["FullscreenMode"] = "normal";
#endif #endif
mStringMap["PowerSaverMode"] = "disabled"; mStringMap["PowerSaverMode"] = "disabled";

View file

@ -9,12 +9,16 @@
#ifndef ES_CORE_SOUND_H #ifndef ES_CORE_SOUND_H
#define ES_CORE_SOUND_H #define ES_CORE_SOUND_H
#if defined(__linux__) || defined (_WIN64) #if defined(__linux__) || defined(_WIN64)
#include <SDL2/SDL_audio.h> #include <SDL2/SDL_audio.h>
#else #else
#include "SDL_audio.h" #include "SDL_audio.h"
#endif #endif
#if defined(__APPLE__)
#include <sstream>
#endif
#include <map> #include <map>
#include <memory> #include <memory>
#include <vector> #include <vector>

View file

@ -329,15 +329,15 @@ void ImageComponent::updateVertices()
void ImageComponent::updateColors() void ImageComponent::updateColors()
{ {
const float opacity = (mOpacity * (mFading ? mFadeOpacity / 255.0 : 1.0)) / 255.0; const float opacity = (mOpacity * (mFading ? mFadeOpacity / 255.0 : 1.0)) / 255.0;
const unsigned int color = Renderer::convertColor(mColorShift & 0xFFFFFF00 | const unsigned int color = Renderer::convertColor((mColorShift & 0xFFFFFF00) |
(unsigned char)((mColorShift & 0xFF) * opacity)); (unsigned char)((mColorShift & 0xFF) * opacity));
const unsigned int colorEnd = Renderer::convertColor(mColorShiftEnd & 0xFFFFFF00 | const unsigned int colorEnd = Renderer::convertColor((mColorShiftEnd & 0xFFFFFF00) |
(unsigned char)((mColorShiftEnd & 0xFF) * opacity)); (unsigned char)((mColorShiftEnd & 0xFF) * opacity));
mVertices[0].col = color; mVertices[0].col = color;
mVertices[1].col = mColorGradientHorizontal ? colorEnd : color; mVertices[1].col = mColorGradientHorizontal ? colorEnd : color;
mVertices[2].col = mColorGradientHorizontal ? color : colorEnd; mVertices[2].col = mColorGradientHorizontal ? color : colorEnd;
mVertices[3].col = colorEnd; mVertices[3].col = colorEnd;
} }

View file

@ -21,7 +21,7 @@
namespace Renderer namespace Renderer
{ {
#if defined(_DEBUG) #ifndef NDEBUG
#define GL_CHECK_ERROR(Function) (Function, _GLCheckError(#Function)) #define GL_CHECK_ERROR(Function) (Function, _GLCheckError(#Function))
static void _GLCheckError(const char* _funcName) static void _GLCheckError(const char* _funcName)
@ -30,7 +30,7 @@ namespace Renderer
if (errorCode != GL_NO_ERROR) { if (errorCode != GL_NO_ERROR) {
LOG(LogError) << "OpenGL error: " << _funcName << LOG(LogError) << "OpenGL error: " << _funcName <<
" failed with error code: " << errorCode; " failed with error code: 0x" << std::hex << errorCode;
} }
} }
#else #else

View file

@ -21,7 +21,7 @@
namespace Renderer namespace Renderer
{ {
#if defined(_DEBUG) #ifndef NDEBUG
#define GL_CHECK_ERROR(Function) (Function, _GLCheckError(#Function)) #define GL_CHECK_ERROR(Function) (Function, _GLCheckError(#Function))
static void _GLCheckError(const char* _funcName) static void _GLCheckError(const char* _funcName)
@ -30,7 +30,7 @@ namespace Renderer
if (errorCode != GL_NO_ERROR) { if (errorCode != GL_NO_ERROR) {
LOG(LogError) << "OpenGLES error: " << _funcName << LOG(LogError) << "OpenGLES error: " << _funcName <<
" failed with error code: " << errorCode; " failed with error code: 0x" << std::hex << errorCode;
} }
} }
#else #else

View file

@ -8,6 +8,10 @@
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
#if defined(__APPLE__)
#define _DARWIN_USE_64_BIT_INODE
#endif
#include "utils/FileSystemUtil.h" #include "utils/FileSystemUtil.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
@ -134,7 +138,7 @@ namespace Utils
#if defined(_WIN64) #if defined(_WIN64)
// On Windows we need to check HOMEDRIVE and HOMEPATH. // On Windows we need to check HOMEDRIVE and HOMEPATH.
if (!homePath.length()) { if (!homePath.length()) {
#ifdef _WIN64 #if defined(_WIN64)
std::string envHomeDrive = std::string envHomeDrive =
Utils::String::wideStringToString(_wgetenv(L"HOMEDRIVE")); Utils::String::wideStringToString(_wgetenv(L"HOMEDRIVE"));
std::string envHomePath = std::string envHomePath =
@ -167,7 +171,7 @@ namespace Utils
char temp[512]; char temp[512];
// Return current working directory. // Return current working directory.
#ifdef _WIN64 #if defined(_WIN64)
wchar_t tempWide[512]; wchar_t tempWide[512];
return (_wgetcwd(tempWide, 512) ? return (_wgetcwd(tempWide, 512) ?
getGenericPath(Utils::String::wideStringToString(tempWide)) : ""); getGenericPath(Utils::String::wideStringToString(tempWide)) : "");
@ -178,7 +182,7 @@ namespace Utils
std::string getPathToBinary(const std::string& executable) std::string getPathToBinary(const std::string& executable)
{ {
#ifdef _WIN64 #if defined(_WIN64)
return ""; return "";
#else #else
std::string pathVariable = std::string(getenv("PATH")); std::string pathVariable = std::string(getenv("PATH"));
@ -230,7 +234,7 @@ namespace Utils
// Just in case some build environments won't handle this correctly. // Just in case some build environments won't handle this correctly.
// For Windows it doesn't really work like that and the application could have // For Windows it doesn't really work like that and the application could have
// been install to an arbitrary location, so this function won't be used on that OS. // been install to an arbitrary location, so this function won't be used on that OS.
#ifdef __unix__ #if defined(__unix__)
if (!installPrefix.length()) if (!installPrefix.length())
installPrefix = "/usr/local"; installPrefix = "/usr/local";
return installPrefix + "/share/emulationstation"; return installPrefix + "/share/emulationstation";
@ -564,7 +568,7 @@ namespace Utils
return true; return true;
} }
#ifdef _WIN64 #if defined(_WIN64)
std::ifstream sourceFile(Utils::String::stringToWideString(_source_path).c_str(), std::ifstream sourceFile(Utils::String::stringToWideString(_source_path).c_str(),
std::ios::binary); std::ios::binary);
#else #else
@ -578,7 +582,7 @@ namespace Utils
return true; return true;
} }
#ifdef _WIN64 #if defined(_WIN64)
std::ofstream targetFile(Utils::String::stringToWideString(_destination_path).c_str(), std::ofstream targetFile(Utils::String::stringToWideString(_destination_path).c_str(),
std::ios::binary); std::ios::binary);
#else #else
@ -622,7 +626,7 @@ namespace Utils
return true; return true;
} }
#ifdef _WIN64 #if defined(_WIN64)
_wrename(Utils::String::stringToWideString(_source_path).c_str(), _wrename(Utils::String::stringToWideString(_source_path).c_str(),
Utils::String::stringToWideString(_destination_path).c_str()); Utils::String::stringToWideString(_destination_path).c_str());
#else #else
@ -641,7 +645,7 @@ namespace Utils
return true; return true;
// Try to remove file. // Try to remove file.
#ifdef _WIN64 #if defined(_WIN64)
if (_wunlink(Utils::String::stringToWideString(path).c_str()) != 0) { if (_wunlink(Utils::String::stringToWideString(path).c_str()) != 0) {
LOG(LogError) << "Couldn't delete file, permission problems?"; LOG(LogError) << "Couldn't delete file, permission problems?";
LOG(LogError) << path; LOG(LogError) << path;
@ -688,7 +692,7 @@ namespace Utils
createDirectory(parent); createDirectory(parent);
// Try to create directory again now that the parent should exist. // Try to create directory again now that the parent should exist.
#ifdef _WIN64 #if defined(_WIN64)
return (_wmkdir(Utils::String::stringToWideString(path).c_str()) == 0); return (_wmkdir(Utils::String::stringToWideString(path).c_str()) == 0);
#else #else
return (mkdir(path.c_str(), 0755) == 0); return (mkdir(path.c_str(), 0755) == 0);
@ -699,7 +703,10 @@ namespace Utils
{ {
std::string path = getGenericPath(_path); std::string path = getGenericPath(_path);
#ifdef _WIN64 #if defined(__APPLE__)
struct stat info;
return (stat(path.c_str(), &info) == 0);
#elif defined(_WIN64)
struct _stat64 info; struct _stat64 info;
return (_wstat64(Utils::String::stringToWideString(path).c_str(), &info) == 0); return (_wstat64(Utils::String::stringToWideString(path).c_str(), &info) == 0);
#else #else
@ -710,7 +717,7 @@ namespace Utils
bool driveExists(const std::string& _path) bool driveExists(const std::string& _path)
{ {
#ifdef _WIN64 #if defined(_WIN64)
std::string path = getGenericPath(_path); std::string path = getGenericPath(_path);
// Try to add a dot or a backslash and a dot depending on how the drive // Try to add a dot or a backslash and a dot depending on how the drive
// letter was defined by the user. // letter was defined by the user.
@ -741,12 +748,16 @@ namespace Utils
bool isRegularFile(const std::string& _path) bool isRegularFile(const std::string& _path)
{ {
std::string path = getGenericPath(_path); std::string path = getGenericPath(_path);
struct stat64 info;
#ifdef _WIN64 #if defined(__APPLE__)
struct stat info;
return (stat(path.c_str(), &info) == 0);
#elif defined(_WIN64)
struct stat64 info;
if (_wstat64(Utils::String::stringToWideString(path).c_str(), &info) != 0) if (_wstat64(Utils::String::stringToWideString(path).c_str(), &info) != 0)
return false; return false;
#else #else
struct stat64 info;
if (stat64(path.c_str(), &info) != 0) if (stat64(path.c_str(), &info) != 0)
return false; return false;
#endif #endif
@ -758,13 +769,17 @@ namespace Utils
bool isDirectory(const std::string& _path) bool isDirectory(const std::string& _path)
{ {
std::string path = getGenericPath(_path); std::string path = getGenericPath(_path);
struct stat64 info;
#ifdef _WIN64 #if defined(__APPLE__)
struct stat info;
return (stat(path.c_str(), &info) == 0);
#elif defined(_WIN64)
struct stat64 info;
if (_wstat64(Utils::String::stringToWideString(path).c_str(), &info) != 0) if (_wstat64(Utils::String::stringToWideString(path).c_str(), &info) != 0)
return false; return false;
#else #else
if (stat64(path.c_str(), &info) != 0) struct stat64 info;
if (stat64(path.c_str(), &info) != 0)
return false; return false;
#endif #endif
@ -784,10 +799,18 @@ namespace Utils
(Attributes & FILE_ATTRIBUTE_REPARSE_POINT)) (Attributes & FILE_ATTRIBUTE_REPARSE_POINT))
return true; return true;
#else #else
#if defined(__APPLE__)
struct stat info; struct stat info;
if (lstat(path.c_str(), &info) != 0) if (lstat(path.c_str(), &info) != 0)
return false; return false;
#else
struct stat64 info;
if (lstat64(path.c_str(), &info) != 0)
return false;
#endif
// Check for S_IFLNK attribute. // Check for S_IFLNK attribute.
return (S_ISLNK(info.st_mode)); return (S_ISLNK(info.st_mode));

View file

@ -24,15 +24,13 @@ namespace Utils
// 0xxxxxxx, one byte character. // 0xxxxxxx, one byte character.
if ((c & 0x80) == 0) { if ((c & 0x80) == 0) {
// 0xxxxxxx // 0xxxxxxx
result = ((_string[_cursor++] ) ); result = ((_string[_cursor++]));
} }
// 110xxxxx, two byte character. // 110xxxxx, two byte character.
else if ((c & 0xE0) == 0xC0) { else if ((c & 0xE0) == 0xC0) {
// 110xxxxx 10xxxxxx // 110xxxxx 10xxxxxx
result = (_string[_cursor++] & 0x1F) << 6; result = (_string[_cursor++] & 0x1F) << 6;
result |= _string[_cursor++] & 0x3F; result |= _string[_cursor++] & 0x3F;
// result = ((_string[_cursor++] & 0x1F) << 6) |
// ((_string[_cursor++] & 0x3F) );
} }
// 1110xxxx, three byte character. // 1110xxxx, three byte character.
else if ((c & 0xF0) == 0xE0) { else if ((c & 0xF0) == 0xE0) {
@ -40,9 +38,6 @@ namespace Utils
result = (_string[_cursor++] & 0x0F) << 12; result = (_string[_cursor++] & 0x0F) << 12;
result |= (_string[_cursor++] & 0x3F) << 6; result |= (_string[_cursor++] & 0x3F) << 6;
result |= _string[_cursor++] & 0x3F; result |= _string[_cursor++] & 0x3F;
// result = ((_string[_cursor++] & 0x0F) << 12) |
// ((_string[_cursor++] & 0x3F) << 6) |
// ((_string[_cursor++] & 0x3F) );
} }
// 11110xxx, four byte character. // 11110xxx, four byte character.
else if ((c & 0xF8) == 0xF0) { else if ((c & 0xF8) == 0xF0) {
@ -51,10 +46,6 @@ namespace Utils
result |= (_string[_cursor++] & 0x3F) << 12; result |= (_string[_cursor++] & 0x3F) << 12;
result |= (_string[_cursor++] & 0x3F) << 6; result |= (_string[_cursor++] & 0x3F) << 6;
result |= _string[_cursor++] & 0x3F; result |= _string[_cursor++] & 0x3F;
// result = ((_string[_cursor++] & 0x07) << 18) |
// ((_string[_cursor++] & 0x3F) << 12) |
// ((_string[_cursor++] & 0x3F) << 6) |
// ((_string[_cursor++] & 0x3F) );
} }
else { else {
// Error, invalid unicode. // Error, invalid unicode.