Haiku support (#596)
* Don't apply Wayland videodriver workaround on Haiku * dirent.d_type-less type detecting in IGFD The Dumb Way(tm). `stat`'s `st_mode` should be nicer? * CMake check for dirent.d_type, stat-based fallback * Move config dir setup to separate function Nicer to work with than macro kerfuffle. * Default sysFileDialog to off on Haiku * Logging stuff * Honour CMAKE_INSTALL_BINDIR * Use find_directory on Haiku Includes forgotten configPath line when home==NULL. * Address PR review notes
This commit is contained in:
parent
de77d51d7a
commit
e08399156a
8 changed files with 152 additions and 97 deletions
7
src/check/check_dirent_type.c
Normal file
7
src/check/check_dirent_type.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <dirent.h>
|
||||
|
||||
int main(int, char**) {
|
||||
struct dirent deTest = { };
|
||||
unsigned char deType = deTest.d_type;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -23,11 +23,84 @@
|
|||
#include <fmt/printf.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "winStuff.h"
|
||||
#define CONFIG_FILE "\\furnace.cfg"
|
||||
#else
|
||||
#ifdef __HAIKU__
|
||||
#include <support/SupportDefs.h>
|
||||
#include <storage/FindDirectory.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#define CONFIG_FILE "/furnace.cfg"
|
||||
#endif
|
||||
|
||||
void DivEngine::initConfDir() {
|
||||
#ifdef _WIN32
|
||||
// maybe move this function in here instead?
|
||||
configPath=getWinConfigPath();
|
||||
#elif defined (IS_MOBILE)
|
||||
configPath=SDL_GetPrefPath();
|
||||
#else
|
||||
#ifdef __HAIKU__
|
||||
char userSettingsDir[PATH_MAX];
|
||||
status_t findUserDir = find_directory(B_USER_SETTINGS_DIRECTORY,0,true,userSettingsDir,PATH_MAX);
|
||||
if (findUserDir==B_OK) {
|
||||
configPath=userSettingsDir;
|
||||
} else {
|
||||
logW("unable to find/create user settings directory (%s)!",strerror(findUserDir));
|
||||
configPath=".";
|
||||
return;
|
||||
}
|
||||
#else
|
||||
// TODO this should check XDG_CONFIG_HOME first
|
||||
char* home=getenv("HOME");
|
||||
if (home==NULL) {
|
||||
int uid=getuid();
|
||||
struct passwd* entry=getpwuid(uid);
|
||||
if (entry==NULL) {
|
||||
logW("unable to determine home directory (%s)!",strerror(errno));
|
||||
configPath=".";
|
||||
return;
|
||||
} else {
|
||||
configPath=entry->pw_dir;
|
||||
}
|
||||
} else {
|
||||
configPath=home;
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
configPath+="/Library/Application Support";
|
||||
#else
|
||||
// FIXME this doesn't honour XDG_CONFIG_HOME *at all*
|
||||
configPath+="/.config";
|
||||
#endif // __APPLE__
|
||||
#endif // __HAIKU__
|
||||
#ifdef __APPLE__
|
||||
configPath+="/Furnace";
|
||||
#else
|
||||
configPath+="/furnace";
|
||||
#endif // __APPLE__
|
||||
struct stat st;
|
||||
std::string pathSep="/";
|
||||
configPath+=pathSep;
|
||||
size_t sepPos=configPath.find(pathSep,1);
|
||||
while (sepPos!=std::string::npos) {
|
||||
std::string subpath=configPath.substr(0,sepPos++);
|
||||
if (stat(subpath.c_str(),&st)!=0) {
|
||||
logI("creating config path element %s ...",subpath.c_str());
|
||||
if (mkdir(subpath.c_str(),0755)!=0) {
|
||||
logW("could not create config path element %s! (%s)",subpath.c_str(),strerror(errno));
|
||||
configPath=".";
|
||||
return;
|
||||
}
|
||||
}
|
||||
sepPos=configPath.find(pathSep,sepPos);
|
||||
}
|
||||
configPath.resize(configPath.length()-pathSep.length());
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
bool DivEngine::saveConf() {
|
||||
configFile=configPath+String(CONFIG_FILE);
|
||||
FILE* f=ps_fopen(configFile.c_str(),"wb");
|
||||
|
|
|
|||
|
|
@ -27,11 +27,6 @@
|
|||
#include "../audio/sdlAudio.h"
|
||||
#endif
|
||||
#include <stdexcept>
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_JACK
|
||||
#include "../audio/jack.h"
|
||||
#endif
|
||||
|
|
@ -2989,36 +2984,6 @@ void DivEngine::quitDispatch() {
|
|||
BUSY_END;
|
||||
}
|
||||
|
||||
#define CHECK_CONFIG_DIR_MAC() \
|
||||
configPath+="/Library/Application Support/Furnace"; \
|
||||
if (stat(configPath.c_str(),&st)<0) { \
|
||||
logI("creating config dir..."); \
|
||||
if (mkdir(configPath.c_str(),0755)<0) { \
|
||||
logW("could not make config dir! (%s)",strerror(errno)); \
|
||||
configPath="."; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define CHECK_CONFIG_DIR() \
|
||||
configPath+="/.config"; \
|
||||
if (stat(configPath.c_str(),&st)<0) { \
|
||||
logI("creating user config dir..."); \
|
||||
if (mkdir(configPath.c_str(),0755)<0) { \
|
||||
logW("could not make user config dir! (%s)",strerror(errno)); \
|
||||
configPath="."; \
|
||||
} \
|
||||
} \
|
||||
if (configPath!=".") { \
|
||||
configPath+="/furnace"; \
|
||||
if (stat(configPath.c_str(),&st)<0) { \
|
||||
logI("creating config dir..."); \
|
||||
if (mkdir(configPath.c_str(),0755)<0) { \
|
||||
logW("could not make config dir! (%s)",strerror(errno)); \
|
||||
configPath="."; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
bool DivEngine::initAudioBackend() {
|
||||
// load values
|
||||
if (audioEngine==DIV_AUDIO_NULL) {
|
||||
|
|
@ -3148,45 +3113,12 @@ bool DivEngine::deinitAudioBackend() {
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "winStuff.h"
|
||||
#endif
|
||||
|
||||
bool DivEngine::init() {
|
||||
// register systems
|
||||
if (!systemsRegistered) registerSystems();
|
||||
|
||||
|
||||
// init config
|
||||
#ifdef _WIN32
|
||||
configPath=getWinConfigPath();
|
||||
#elif defined(IS_MOBILE)
|
||||
configPath=SDL_GetPrefPath("tildearrow","furnace");
|
||||
#else
|
||||
struct stat st;
|
||||
char* home=getenv("HOME");
|
||||
if (home==NULL) {
|
||||
int uid=getuid();
|
||||
struct passwd* entry=getpwuid(uid);
|
||||
if (entry==NULL) {
|
||||
logW("unable to determine config directory! (%s)",strerror(errno));
|
||||
configPath=".";
|
||||
} else {
|
||||
configPath=entry->pw_dir;
|
||||
#ifdef __APPLE__
|
||||
CHECK_CONFIG_DIR_MAC();
|
||||
#else
|
||||
CHECK_CONFIG_DIR();
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
configPath=home;
|
||||
#ifdef __APPLE__
|
||||
CHECK_CONFIG_DIR_MAC();
|
||||
#else
|
||||
CHECK_CONFIG_DIR();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
initConfDir();
|
||||
logD("config path: %s",configPath.c_str());
|
||||
|
||||
loadConf();
|
||||
|
|
|
|||
|
|
@ -485,6 +485,9 @@ class DivEngine {
|
|||
// returns the minimum VGM version which may carry the specified system, or 0 if none.
|
||||
int minVGMVersion(DivSystem which);
|
||||
|
||||
// determine and setup config dir
|
||||
void initConfDir();
|
||||
|
||||
// save config
|
||||
bool saveConf();
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,13 @@
|
|||
#define POWER_SAVE_DEFAULT 0
|
||||
#endif
|
||||
|
||||
#ifdef __HAIKU__
|
||||
// NFD doesn't support Haiku
|
||||
#define SYS_FILE_DIALOG_DEFAULT 0
|
||||
#else
|
||||
#define SYS_FILE_DIALOG_DEFAULT 1
|
||||
#endif
|
||||
|
||||
const char* mainFonts[]={
|
||||
"IBM Plex Sans",
|
||||
"Liberation Sans",
|
||||
|
|
@ -2062,7 +2069,7 @@ void FurnaceGUI::syncSettings() {
|
|||
settings.insFocusesPattern=e->getConfInt("insFocusesPattern",1);
|
||||
settings.stepOnInsert=e->getConfInt("stepOnInsert",0);
|
||||
settings.unifiedDataView=e->getConfInt("unifiedDataView",0);
|
||||
settings.sysFileDialog=e->getConfInt("sysFileDialog",1);
|
||||
settings.sysFileDialog=e->getConfInt("sysFileDialog",SYS_FILE_DIALOG_DEFAULT);
|
||||
settings.roundedWindows=e->getConfInt("roundedWindows",1);
|
||||
settings.roundedButtons=e->getConfInt("roundedButtons",1);
|
||||
settings.roundedMenus=e->getConfInt("roundedMenus",0);
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ int main(int argc, char** argv) {
|
|||
logE("CoInitializeEx failed!");
|
||||
}
|
||||
#endif
|
||||
#if !(defined(__APPLE__) || defined(_WIN32) || defined(ANDROID))
|
||||
#if !(defined(__APPLE__) || defined(_WIN32) || defined(ANDROID) || defined(__HAIKU__))
|
||||
// workaround for Wayland HiDPI issue
|
||||
if (getenv("SDL_VIDEODRIVER")==NULL) {
|
||||
setenv("SDL_VIDEODRIVER","x11",1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue