Merge pull request #1182 from baka0815/custom_cfg
evdev: Allow for custom <device>.cfg files in the /mappings/ directory.
This commit is contained in:
commit
68ee2828bb
|
@ -223,7 +223,9 @@
|
||||||
|
|
||||||
if(custom_mapping_fname != NULL)
|
if(custom_mapping_fname != NULL)
|
||||||
{
|
{
|
||||||
|
// custom mapping defined in config, use that
|
||||||
mapping_fname = custom_mapping_fname;
|
mapping_fname = custom_mapping_fname;
|
||||||
|
printf("evdev: user defined custom mapping found (%s)\n", custom_mapping_fname);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -232,6 +234,24 @@
|
||||||
#elif defined(TARGET_GCW0)
|
#elif defined(TARGET_GCW0)
|
||||||
mapping_fname = "controller_gcwz.cfg";
|
mapping_fname = "controller_gcwz.cfg";
|
||||||
#else
|
#else
|
||||||
|
// check if a config file name <device>.cfg exists in the /mappings/ directory
|
||||||
|
char* name_cfg = (char*)malloc(strlen(name)+4);
|
||||||
|
strcpy(name_cfg, name);
|
||||||
|
strcat(name_cfg, ".cfg");
|
||||||
|
|
||||||
|
size_t size_needed = snprintf(NULL, 0, EVDEV_MAPPING_PATH, name_cfg) + 1;
|
||||||
|
char* mapping_path = (char*)malloc(size_needed);
|
||||||
|
sprintf(mapping_path, EVDEV_MAPPING_PATH, name_cfg);
|
||||||
|
|
||||||
|
string dir = get_readonly_data_path(mapping_path);
|
||||||
|
free(mapping_path);
|
||||||
|
if (file_exists(dir)) {
|
||||||
|
printf("evdev: found a named mapping for the device (%s)\n", name_cfg);
|
||||||
|
mapping_fname = name_cfg;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
free(name_cfg);
|
||||||
|
|
||||||
if (strcmp(name, "Microsoft X-Box 360 pad") == 0 ||
|
if (strcmp(name, "Microsoft X-Box 360 pad") == 0 ||
|
||||||
strcmp(name, "Xbox 360 Wireless Receiver") == 0 ||
|
strcmp(name, "Xbox 360 Wireless Receiver") == 0 ||
|
||||||
strcmp(name, "Xbox 360 Wireless Receiver (XBOX)") == 0)
|
strcmp(name, "Xbox 360 Wireless Receiver (XBOX)") == 0)
|
||||||
|
@ -251,8 +271,10 @@
|
||||||
{
|
{
|
||||||
mapping_fname = "controller_generic.cfg";
|
mapping_fname = "controller_generic.cfg";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if(loaded_mappings.count(string(mapping_fname)) == 0)
|
if(loaded_mappings.count(string(mapping_fname)) == 0)
|
||||||
{
|
{
|
||||||
FILE* mapping_fd = NULL;
|
FILE* mapping_fd = NULL;
|
||||||
|
|
|
@ -261,6 +261,7 @@ string get_writable_config_path(const string& filename);
|
||||||
string get_writable_data_path(const string& filename);
|
string get_writable_data_path(const string& filename);
|
||||||
string get_readonly_config_path(const string& filename);
|
string get_readonly_config_path(const string& filename);
|
||||||
string get_readonly_data_path(const string& filename);
|
string get_readonly_data_path(const string& filename);
|
||||||
|
bool file_exists(const string& filename);
|
||||||
|
|
||||||
|
|
||||||
class VArray2
|
class VArray2
|
||||||
|
|
Loading…
Reference in New Issue