mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-17 23:39:18 +02:00
Change config locations
This commit is contained in:
@@ -896,12 +896,34 @@ eu07_application::init_files() {
|
||||
mkdir("logs", 0755);
|
||||
#endif
|
||||
}
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
int
|
||||
eu07_application::init_settings( int Argc, char *Argv[] ) {
|
||||
Global.asVersion = VERSION_INFO;
|
||||
|
||||
Global.LoadIniFile( "eu07.ini" );
|
||||
fs::path iniPath;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (const char *appdata = std::getenv("APPDATA"))
|
||||
{
|
||||
iniPath = fs::path(appdata) / "MaSzyna" / "Config" / "eu07.ini";
|
||||
}
|
||||
#else
|
||||
if (const char *home = std::getenv("HOME"))
|
||||
{
|
||||
iniPath = fs::path(home) / ".config" / "MaSzyna" / "eu07.ini";
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!iniPath.empty() && fs::exists(iniPath))
|
||||
{
|
||||
Global.LoadIniFile(iniPath.string().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.LoadIniFile("eu07.ini");
|
||||
}
|
||||
|
||||
// process command line arguments
|
||||
for( int i = 1; i < Argc; ++i ) {
|
||||
|
||||
@@ -175,12 +175,32 @@ drivermouse_input::init() {
|
||||
|
||||
return true;
|
||||
}
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
bool
|
||||
drivermouse_input::recall_bindings() {
|
||||
|
||||
cParser bindingparser( "eu07_input-mouse.ini", cParser::buffer_FILE );
|
||||
if( false == bindingparser.ok() ) {
|
||||
std::string filePath = "eu07_input-mouse.ini";
|
||||
|
||||
#ifdef _WIN32
|
||||
if (const char *appdata = std::getenv("APPDATA"))
|
||||
{
|
||||
fs::path appPath = fs::path(appdata) / "MaSzyna" / "Config" / "eu07_input-mouse.ini";
|
||||
if (fs::exists(appPath))
|
||||
filePath = appPath.string();
|
||||
}
|
||||
#else
|
||||
if (const char *home = std::getenv("HOME"))
|
||||
{
|
||||
fs::path appPath = fs::path(home) / ".config" / "MaSzyna" / "eu07_input-mouse.ini";
|
||||
if (fs::exists(appPath))
|
||||
filePath = appPath.string();
|
||||
}
|
||||
#endif
|
||||
|
||||
cParser bindingparser(filePath.c_str(), cParser::buffer_FILE);
|
||||
|
||||
if (false == bindingparser.ok()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,10 +150,31 @@ gamepad_input::bind( std::vector< std::reference_wrapper<user_command> > &Target
|
||||
}
|
||||
}
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
bool
|
||||
gamepad_input::recall_bindings() {
|
||||
std::string filePath = "eu07_input-gamepad.ini";
|
||||
|
||||
#ifdef _WIN32
|
||||
if (const char *appdata = std::getenv("APPDATA"))
|
||||
{
|
||||
fs::path appPath = fs::path(appdata) / "MaSzyna" / "Config" / "eu07_input-gamepad.ini";
|
||||
if (fs::exists(appPath))
|
||||
filePath = appPath.string();
|
||||
}
|
||||
#else
|
||||
if (const char *home = std::getenv("HOME"))
|
||||
{
|
||||
fs::path appPath = fs::path(home) / ".config" / "MaSzyna" / "eu07_input-gamepad.ini";
|
||||
if (fs::exists(appPath))
|
||||
filePath = appPath.string();
|
||||
}
|
||||
#endif
|
||||
|
||||
// bindingparser tworzony zawsze, z wybran¹ œcie¿k¹
|
||||
cParser bindingparser(filePath.c_str(), cParser::buffer_FILE);
|
||||
|
||||
cParser bindingparser( "eu07_input-gamepad.ini", cParser::buffer_FILE );
|
||||
if( false == bindingparser.ok() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -117,12 +117,38 @@ std::unordered_map<int, std::string> keyboard_input::keytonamemap =
|
||||
{ GLFW_KEY_PAGE_UP, "page_up" },
|
||||
{ GLFW_KEY_PAGE_DOWN, "page_down" },
|
||||
};
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
bool
|
||||
keyboard_input::recall_bindings() {
|
||||
|
||||
cParser bindingparser( "eu07_input-keyboard.ini", cParser::buffer_FILE );
|
||||
bindingparser.skipComments = false;
|
||||
fs::path iniPath;
|
||||
std::string path = "";
|
||||
#ifdef _WIN32
|
||||
if (const char *appdata = std::getenv("APPDATA"))
|
||||
{
|
||||
iniPath = fs::path(appdata) / "MaSzyna" / "Config" / "eu07_input-keyboard.ini";
|
||||
}
|
||||
#else
|
||||
if (const char *home = std::getenv("HOME"))
|
||||
{
|
||||
iniPath = fs::path(home) / ".config" / "MaSzyna" / "eu07_input-keyboard.ini";
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!iniPath.empty() && fs::exists(iniPath))
|
||||
{
|
||||
// Plik istnieje w AppData / ~/.config
|
||||
path = iniPath.string().c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback – plik w folderze symulatora
|
||||
path = "eu07_input-keyboard.ini";
|
||||
}
|
||||
cParser bindingparser(path.c_str(), cParser::buffer_FILE);
|
||||
|
||||
bindingparser.skipComments = false;
|
||||
if( false == bindingparser.ok() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
23
uart.cpp
23
uart.cpp
@@ -186,13 +186,32 @@ uart_input::~uart_input()
|
||||
sp_free_port(port);
|
||||
}
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
bool
|
||||
uart_input::recall_bindings() {
|
||||
|
||||
m_inputbindings.clear();
|
||||
std::string filePath = "eu07_input-uart.ini";
|
||||
|
||||
cParser bindingparser( "eu07_input-uart.ini", cParser::buffer_FILE );
|
||||
if( false == bindingparser.ok() ) {
|
||||
#ifdef _WIN32
|
||||
if (const char *appdata = std::getenv("APPDATA"))
|
||||
{
|
||||
fs::path appPath = fs::path(appdata) / "MaSzyna" / "Config" / "eu07_input-uart.ini";
|
||||
if (fs::exists(appPath))
|
||||
filePath = appPath.string();
|
||||
}
|
||||
#else
|
||||
if (const char *home = std::getenv("HOME"))
|
||||
{
|
||||
fs::path appPath = fs::path(home) / ".config" / "MaSzyna" / "eu07_input-uart.ini";
|
||||
if (fs::exists(appPath))
|
||||
filePath = appPath.string();
|
||||
}
|
||||
#endif
|
||||
cParser bindingparser(filePath.c_str(), cParser::buffer_FILE);
|
||||
if (false == bindingparser.ok())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user