mirror of
https://github.com/RetroPie/EmulationStation.git
synced 2025-04-02 10:41:48 -04:00
Compare commits
3 commits
538278a010
...
377f551859
Author | SHA1 | Date | |
---|---|---|---|
|
377f551859 | ||
|
a82d3cc8e8 | ||
|
a3bcf1f8cb |
10 changed files with 108 additions and 49 deletions
6
.github/workflows/win32.yml
vendored
6
.github/workflows/win32.yml
vendored
|
@ -27,14 +27,14 @@ jobs:
|
||||||
# Check-out repository under $GITHUB_WORKSPACE
|
# Check-out repository under $GITHUB_WORKSPACE
|
||||||
# https://github.com/actions/checkout
|
# https://github.com/actions/checkout
|
||||||
- name: Check-out repository
|
- name: Check-out repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
|
|
||||||
# Discover location of MSBuild tool and to PATH environment variables
|
# Discover location of MSBuild tool and to PATH environment variables
|
||||||
# https://github.com/microsoft/setup-msbuild
|
# https://github.com/microsoft/setup-msbuild
|
||||||
- name: Locate MSBuild
|
- name: Locate MSBuild
|
||||||
uses: microsoft/setup-msbuild@v1.3.1
|
uses: microsoft/setup-msbuild@v2
|
||||||
|
|
||||||
# Use NuGet to download the latest libVLC.
|
# Use NuGet to download the latest libVLC.
|
||||||
- name: Download libVLC
|
- name: Download libVLC
|
||||||
|
@ -130,7 +130,7 @@ jobs:
|
||||||
# Uploads artifacts from workflow
|
# Uploads artifacts from workflow
|
||||||
# https://github.com/actions/upload-artifact
|
# https://github.com/actions/upload-artifact
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: EmulationStation
|
name: EmulationStation
|
||||||
path: |
|
path: |
|
||||||
|
|
|
@ -120,6 +120,7 @@ set(ES_SOURCES
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
LIST(APPEND ES_SOURCES
|
LIST(APPEND ES_SOURCES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/EmulationStation.rc
|
${CMAKE_CURRENT_SOURCE_DIR}/src/EmulationStation.rc
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/EmulationStation.manifest
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
9
es-app/src/EmulationStation.manifest
Normal file
9
es-app/src/EmulationStation.manifest
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
|
||||||
|
<assembly manifestVersion='1.0' xmlns='urn:schemas-microsoft-com:asm.v1'>
|
||||||
|
<application>
|
||||||
|
<windowsSettings>
|
||||||
|
<dpiAwareness xmlns='http://schemas.microsoft.com/SMI/2016/WindowsSettings'>PerMonitorV2</dpiAwareness>
|
||||||
|
<activeCodePage xmlns='http://schemas.microsoft.com/SMI/2019/WindowsSettings'>UTF-8</activeCodePage>
|
||||||
|
</windowsSettings>
|
||||||
|
</application>
|
||||||
|
</assembly>
|
|
@ -280,10 +280,12 @@ void FileData::launchGame(Window* window)
|
||||||
{
|
{
|
||||||
LOG(LogInfo) << "Attempting to launch game...";
|
LOG(LogInfo) << "Attempting to launch game...";
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
AudioManager::getInstance()->deinit();
|
AudioManager::getInstance()->deinit();
|
||||||
VolumeControl::getInstance()->deinit();
|
VolumeControl::getInstance()->deinit();
|
||||||
InputManager::getInstance()->deinit();
|
InputManager::getInstance()->deinit();
|
||||||
window->deinit();
|
window->deinit();
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string command = mEnvData->mLaunchCommand;
|
std::string command = mEnvData->mLaunchCommand;
|
||||||
|
|
||||||
|
@ -299,7 +301,7 @@ void FileData::launchGame(Window* window)
|
||||||
Scripting::fireEvent("game-start", rom, basename, name);
|
Scripting::fireEvent("game-start", rom, basename, name);
|
||||||
|
|
||||||
LOG(LogInfo) << " " << command;
|
LOG(LogInfo) << " " << command;
|
||||||
int exitCode = runSystemCommand(command);
|
int exitCode = launchGameCommand(command);
|
||||||
|
|
||||||
if(exitCode != 0)
|
if(exitCode != 0)
|
||||||
{
|
{
|
||||||
|
@ -308,9 +310,11 @@ void FileData::launchGame(Window* window)
|
||||||
|
|
||||||
Scripting::fireEvent("game-end");
|
Scripting::fireEvent("game-end");
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
window->init();
|
window->init();
|
||||||
InputManager::getInstance()->init();
|
InputManager::getInstance()->init();
|
||||||
VolumeControl::getInstance()->init();
|
VolumeControl::getInstance()->init();
|
||||||
|
#endif
|
||||||
window->normalizeNextUpdate();
|
window->normalizeNextUpdate();
|
||||||
|
|
||||||
//update number of times the game has been launched
|
//update number of times the game has been launched
|
||||||
|
|
|
@ -522,6 +522,7 @@ void GuiMenu::openQuitMenu()
|
||||||
ComponentListRow row;
|
ComponentListRow row;
|
||||||
if (UIModeController::getInstance()->isUIModeFull())
|
if (UIModeController::getInstance()->isUIModeFull())
|
||||||
{
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
auto static restart_es_fx = []() {
|
auto static restart_es_fx = []() {
|
||||||
Scripting::fireEvent("quit");
|
Scripting::fireEvent("quit");
|
||||||
if (quitES(QuitMode::RESTART)) {
|
if (quitES(QuitMode::RESTART)) {
|
||||||
|
@ -538,6 +539,7 @@ void GuiMenu::openQuitMenu()
|
||||||
}
|
}
|
||||||
row.addElement(std::make_shared<TextComponent>(window, "RESTART EMULATIONSTATION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
row.addElement(std::make_shared<TextComponent>(window, "RESTART EMULATIONSTATION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
||||||
s->addRow(row);
|
s->addRow(row);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(Settings::getInstance()->getBool("ShowExit"))
|
if(Settings::getInstance()->getBool("ShowExit"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,12 +30,10 @@ namespace Scripting
|
||||||
for(std::list<std::string>::const_iterator dirIt = scriptDirList.cbegin(); dirIt != scriptDirList.cend(); ++dirIt) {
|
for(std::list<std::string>::const_iterator dirIt = scriptDirList.cbegin(); dirIt != scriptDirList.cend(); ++dirIt) {
|
||||||
std::list<std::string> scripts = Utils::FileSystem::getDirContent(*dirIt);
|
std::list<std::string> scripts = Utils::FileSystem::getDirContent(*dirIt);
|
||||||
for (std::list<std::string>::const_iterator it = scripts.cbegin(); it != scripts.cend(); ++it) {
|
for (std::list<std::string>::const_iterator it = scripts.cbegin(); it != scripts.cend(); ++it) {
|
||||||
#ifndef WIN32 // osx / linux
|
|
||||||
if (!Utils::FileSystem::isExecutable(*it)) {
|
if (!Utils::FileSystem::isExecutable(*it)) {
|
||||||
LOG(LogWarning) << *it << " is not executable. Review file permissions.";
|
LOG(LogWarning) << *it << " is not executable. Review file permissions.";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
std::string script = *it;
|
std::string script = *it;
|
||||||
if (arg1.length() > 0) {
|
if (arg1.length() > 0) {
|
||||||
script += " \"" + arg1 + "\"";
|
script += " \"" + arg1 + "\"";
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
#include <SDL_events.h>
|
#include <SDL_events.h>
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
|
#include <SDL.h>
|
||||||
|
#include <SDL_opengl.h>
|
||||||
|
#include <Windows.h>
|
||||||
|
#include "renderers/Renderer.h"
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,15 +34,63 @@ int runRestartCommand()
|
||||||
|
|
||||||
int runSystemCommand(const std::string& cmd_utf8)
|
int runSystemCommand(const std::string& cmd_utf8)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
|
||||||
// on Windows we use _wsystem to support non-ASCII paths
|
|
||||||
// which requires converting from utf8 to a wstring
|
|
||||||
typedef std::codecvt_utf8<wchar_t> convert_type;
|
|
||||||
std::wstring_convert<convert_type, wchar_t> converter;
|
|
||||||
std::wstring wchar_str = converter.from_bytes(cmd_utf8);
|
|
||||||
return _wsystem(wchar_str.c_str());
|
|
||||||
#else
|
|
||||||
return system(cmd_utf8.c_str());
|
return system(cmd_utf8.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
int launchGameCommand(const std::string& cmd_utf8)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
STARTUPINFO
|
||||||
|
si;
|
||||||
|
PROCESS_INFORMATION
|
||||||
|
pi;
|
||||||
|
SDL_Event
|
||||||
|
event;
|
||||||
|
DWORD
|
||||||
|
rcode = 0;
|
||||||
|
Uint32
|
||||||
|
wf;
|
||||||
|
int
|
||||||
|
width,
|
||||||
|
height;
|
||||||
|
|
||||||
|
wf = SDL_GetWindowFlags(Renderer::getSDLWindow());
|
||||||
|
SDL_SetWindowFullscreen(Renderer::getSDLWindow(), 0);
|
||||||
|
SDL_SetWindowBordered(Renderer::getSDLWindow(), SDL_TRUE);
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
Renderer::swapBuffers();
|
||||||
|
|
||||||
|
memset(&si, 0, sizeof si);
|
||||||
|
memset(&pi, 0, sizeof pi);
|
||||||
|
si.cb = sizeof si;
|
||||||
|
|
||||||
|
if(!CreateProcess(NULL, (LPSTR)cmd_utf8.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
||||||
|
return 9009;
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
if(WaitForSingleObject(pi.hProcess, 200) == 0)
|
||||||
|
break;
|
||||||
|
while(SDL_PollEvent(&event))
|
||||||
|
; // NOP
|
||||||
|
}
|
||||||
|
|
||||||
|
GetExitCodeProcess(pi.hProcess, &rcode);
|
||||||
|
CloseHandle(pi.hProcess);
|
||||||
|
CloseHandle(pi.hThread);
|
||||||
|
|
||||||
|
if(wf & SDL_WINDOW_FULLSCREEN)
|
||||||
|
SDL_SetWindowFullscreen(Renderer::getSDLWindow(), SDL_WINDOW_FULLSCREEN);
|
||||||
|
if(wf & SDL_WINDOW_BORDERLESS)
|
||||||
|
SDL_SetWindowBordered(Renderer::getSDLWindow(), SDL_FALSE);
|
||||||
|
|
||||||
|
wf = SDL_GetWindowFlags(Renderer::getSDLWindow());
|
||||||
|
if(wf & SDL_WINDOW_MINIMIZED)
|
||||||
|
SDL_RestoreWindow(Renderer::getSDLWindow());
|
||||||
|
|
||||||
|
return rcode;
|
||||||
|
#else
|
||||||
|
return runSystemCommand(cmd_utf8);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,9 +109,7 @@ int quitES(QuitMode mode)
|
||||||
void touch(const std::string& filename)
|
void touch(const std::string& filename)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
FILE* fp = fopen(filename.c_str(), "ab+");
|
// Windows hasn't /tmp directory usualy so nothing to touch.
|
||||||
if (fp != NULL)
|
|
||||||
fclose(fp);
|
|
||||||
#else
|
#else
|
||||||
int fd = open(filename.c_str(), O_CREAT|O_WRONLY, 0644);
|
int fd = open(filename.c_str(), O_CREAT|O_WRONLY, 0644);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
|
|
|
@ -17,7 +17,8 @@ enum QuitMode
|
||||||
REBOOT = 3
|
REBOOT = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
int runSystemCommand(const std::string& cmd_utf8); // run a utf-8 encoded in the shell (requires wstring conversion on Windows)
|
int runSystemCommand(const std::string& cmd_utf8); // run a utf-8 encoded in the shell
|
||||||
|
int launchGameCommand(const std::string& cmd_utf8);
|
||||||
int quitES(QuitMode mode = QuitMode::QUIT);
|
int quitES(QuitMode mode = QuitMode::QUIT);
|
||||||
void processQuitMode();
|
void processQuitMode();
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
// because windows...
|
// because windows...
|
||||||
|
#include "utils/StringUtil.h"
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#define getcwd _getcwd
|
#define getcwd _getcwd
|
||||||
|
@ -34,21 +35,6 @@ namespace Utils
|
||||||
static std::string exePath = "";
|
static std::string exePath = "";
|
||||||
static std::map<std::string, bool> pathExistsIndex = std::map<std::string, bool>();
|
static std::map<std::string, bool> pathExistsIndex = std::map<std::string, bool>();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
static std::string convertFromWideString(const std::wstring _wstring)
|
|
||||||
{
|
|
||||||
const int numBytes = WideCharToMultiByte(CP_UTF8, 0, _wstring.c_str(), (int)_wstring.length(), nullptr, 0, nullptr, nullptr);
|
|
||||||
std::string string(numBytes, 0);
|
|
||||||
|
|
||||||
WideCharToMultiByte(CP_UTF8, 0, _wstring.c_str(), (int)_wstring.length(), (char*)string.c_str(), numBytes, nullptr, nullptr);
|
|
||||||
|
|
||||||
return std::string(string);
|
|
||||||
|
|
||||||
} // convertFromWideString
|
|
||||||
#endif // _WIN32
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
stringList getDirContent(const std::string& _path, const bool _recursive)
|
stringList getDirContent(const std::string& _path, const bool _recursive)
|
||||||
|
@ -62,16 +48,16 @@ namespace Utils
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
const std::unique_lock<std::recursive_mutex> lock(mutex);
|
const std::unique_lock<std::recursive_mutex> lock(mutex);
|
||||||
WIN32_FIND_DATAW findData;
|
WIN32_FIND_DATA findData;
|
||||||
const std::string wildcard = path + "/*";
|
const std::string wildcard = path + "/*";
|
||||||
const HANDLE hFind = FindFirstFileW(std::wstring(wildcard.begin(), wildcard.end()).c_str(), &findData);
|
const HANDLE hFind = FindFirstFile(wildcard.c_str(), &findData);
|
||||||
|
|
||||||
if(hFind != INVALID_HANDLE_VALUE)
|
if(hFind != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
// loop over all files in the directory
|
// loop over all files in the directory
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
const std::string name = convertFromWideString(findData.cFileName);
|
const std::string name = findData.cFileName;
|
||||||
|
|
||||||
// ignore "." and ".."
|
// ignore "." and ".."
|
||||||
if((name != ".") && (name != ".."))
|
if((name != ".") && (name != ".."))
|
||||||
|
@ -84,7 +70,7 @@ namespace Utils
|
||||||
contentList.merge(getDirContent(fullName, true));
|
contentList.merge(getDirContent(fullName, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(FindNextFileW(hFind, &findData));
|
while(FindNextFile(hFind, &findData));
|
||||||
|
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
}
|
}
|
||||||
|
@ -216,13 +202,14 @@ namespace Utils
|
||||||
void setExePath(const std::string& _path)
|
void setExePath(const std::string& _path)
|
||||||
{
|
{
|
||||||
const size_t path_max = 32767;
|
const size_t path_max = 32767;
|
||||||
|
std::string result(path_max, 0);
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
std::wstring result(path_max, 0);
|
if(GetModuleFileName(nullptr, &result[0], path_max) != 0){
|
||||||
if(GetModuleFileNameW(nullptr, &result[0], path_max) != 0)
|
result.resize(result.find_first_of('\0'));
|
||||||
exePath = convertFromWideString(result);
|
exePath = result;
|
||||||
|
}
|
||||||
#else // _WIN32
|
#else // _WIN32
|
||||||
std::string result(path_max, 0);
|
|
||||||
if(readlink("/proc/self/exe", &result[0], path_max) != -1)
|
if(readlink("/proc/self/exe", &result[0], path_max) != -1)
|
||||||
exePath = result;
|
exePath = result;
|
||||||
#endif // !_WIN32
|
#endif // !_WIN32
|
||||||
|
@ -570,9 +557,9 @@ namespace Utils
|
||||||
if(hFile != INVALID_HANDLE_VALUE)
|
if(hFile != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
resolved.resize(GetFinalPathNameByHandle(hFile, nullptr, 0, FILE_NAME_NORMALIZED) + 1);
|
resolved.resize(GetFinalPathNameByHandle(hFile, nullptr, 0, FILE_NAME_NORMALIZED) + 1);
|
||||||
if(GetFinalPathNameByHandle(hFile, (LPSTR)resolved.data(), (DWORD)resolved.size(), FILE_NAME_NORMALIZED) > 0)
|
if(GetFinalPathNameByHandle(hFile, (LPSTR)resolved.data(), resolved.size(), FILE_NAME_NORMALIZED) > 0)
|
||||||
{
|
{
|
||||||
resolved.resize(resolved.size() - 1);
|
resolved.resize(resolved.find_first_of('\0'));
|
||||||
resolved = getGenericPath(resolved);
|
resolved = getGenericPath(resolved);
|
||||||
}
|
}
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
@ -764,9 +751,19 @@ namespace Utils
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
bool isExecutable(const std::string& _path)
|
bool isExecutable(const std::string& _path)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::string ext = getenv("PATHEXT");
|
||||||
|
Utils::String::stringVector pathext = Utils::String::delimitedStringToVector(ext, ";");
|
||||||
|
|
||||||
|
ext = getExtension(_path);
|
||||||
|
for(auto it = pathext.cbegin(); it != pathext.cend(); it++)
|
||||||
|
if(stricmp(ext.c_str(), it->c_str()) == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
const std::string path = getGenericPath(_path);
|
const std::string path = getGenericPath(_path);
|
||||||
|
|
||||||
// regular files and executables, but not setuid, setgid, shared text
|
// regular files and executables, but not setuid, setgid, shared text
|
||||||
|
@ -780,9 +777,8 @@ namespace Utils
|
||||||
|
|
||||||
// check for mask attributes
|
// check for mask attributes
|
||||||
return (info.st_mode & mask) == mask && (info.st_mode & mask_exec) != 0;
|
return (info.st_mode & mask) == mask && (info.st_mode & mask_exec) != 0;
|
||||||
|
#endif
|
||||||
} // isExecutable
|
} // isExecutable
|
||||||
#endif // !_WIN32
|
|
||||||
|
|
||||||
} // FileSystem::
|
} // FileSystem::
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,7 @@ namespace Utils
|
||||||
bool isDirectory (const std::string& _path);
|
bool isDirectory (const std::string& _path);
|
||||||
bool isSymlink (const std::string& _path);
|
bool isSymlink (const std::string& _path);
|
||||||
bool isHidden (const std::string& _path);
|
bool isHidden (const std::string& _path);
|
||||||
#if !defined(_WIN32)
|
|
||||||
bool isExecutable (const std::string& _path);
|
bool isExecutable (const std::string& _path);
|
||||||
#endif // !_WIN32
|
|
||||||
|
|
||||||
} // FileSystem::
|
} // FileSystem::
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue