mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 00:29:19 +02:00
Change config locations
This commit is contained in:
@@ -896,12 +896,34 @@ eu07_application::init_files() {
|
|||||||
mkdir("logs", 0755);
|
mkdir("logs", 0755);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
int
|
int
|
||||||
eu07_application::init_settings( int Argc, char *Argv[] ) {
|
eu07_application::init_settings( int Argc, char *Argv[] ) {
|
||||||
Global.asVersion = VERSION_INFO;
|
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
|
// process command line arguments
|
||||||
for( int i = 1; i < Argc; ++i ) {
|
for( int i = 1; i < Argc; ++i ) {
|
||||||
|
|||||||
@@ -175,12 +175,32 @@ drivermouse_input::init() {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
drivermouse_input::recall_bindings() {
|
drivermouse_input::recall_bindings() {
|
||||||
|
|
||||||
cParser bindingparser( "eu07_input-mouse.ini", cParser::buffer_FILE );
|
std::string filePath = "eu07_input-mouse.ini";
|
||||||
if( false == bindingparser.ok() ) {
|
|
||||||
|
#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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,10 +150,31 @@ gamepad_input::bind( std::vector< std::reference_wrapper<user_command> > &Target
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
gamepad_input::recall_bindings() {
|
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() ) {
|
if( false == bindingparser.ok() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,12 +117,38 @@ std::unordered_map<int, std::string> keyboard_input::keytonamemap =
|
|||||||
{ GLFW_KEY_PAGE_UP, "page_up" },
|
{ GLFW_KEY_PAGE_UP, "page_up" },
|
||||||
{ GLFW_KEY_PAGE_DOWN, "page_down" },
|
{ GLFW_KEY_PAGE_DOWN, "page_down" },
|
||||||
};
|
};
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
keyboard_input::recall_bindings() {
|
keyboard_input::recall_bindings() {
|
||||||
|
|
||||||
cParser bindingparser( "eu07_input-keyboard.ini", cParser::buffer_FILE );
|
fs::path iniPath;
|
||||||
bindingparser.skipComments = false;
|
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() ) {
|
if( false == bindingparser.ok() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
23
uart.cpp
23
uart.cpp
@@ -186,13 +186,32 @@ uart_input::~uart_input()
|
|||||||
sp_free_port(port);
|
sp_free_port(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
uart_input::recall_bindings() {
|
uart_input::recall_bindings() {
|
||||||
|
|
||||||
m_inputbindings.clear();
|
m_inputbindings.clear();
|
||||||
|
std::string filePath = "eu07_input-uart.ini";
|
||||||
|
|
||||||
cParser bindingparser( "eu07_input-uart.ini", cParser::buffer_FILE );
|
#ifdef _WIN32
|
||||||
if( false == bindingparser.ok() ) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user