evdev: Remove unnecessary exports in header

``input_evdev_init(EvdevController* controller, const char* device, const char* mapping_fname)`` and ``input_evdev_button_duplicate_button(EvdevControllerMapping* mapping1, EvdevControllerMapping* mapping2)`` are no longer used outside evdev.cpp
Needed to move ``input_evdev_init()`` around a bit.
This commit is contained in:
Christoph "baka0815" Schwerdtfeger 2018-08-31 16:59:37 +02:00
parent 8cbc342b06
commit 555e140216
2 changed files with 56 additions and 58 deletions

View File

@ -158,62 +158,6 @@
}
}
void input_evdev_init()
{
int evdev_device_id[4] = { -1, -1, -1, -1 };
size_t size_needed;
int port, i;
char* evdev_device;
for (port = 0; port < 4; port++)
{
size_needed = snprintf(NULL, 0, EVDEV_DEVICE_CONFIG_KEY, port+1) + 1;
char* evdev_config_key = (char*)malloc(size_needed);
sprintf(evdev_config_key, EVDEV_DEVICE_CONFIG_KEY, port+1);
evdev_device_id[port] = cfgLoadInt("input", evdev_config_key, EVDEV_DEFAULT_DEVICE_ID(port+1));
free(evdev_config_key);
// Check if the same device is already in use on another port
if (evdev_device_id[port] < 0)
{
printf("evdev: Controller %d disabled by config.\n", port + 1);
}
else
{
size_needed = snprintf(NULL, 0, EVDEV_DEVICE_STRING, evdev_device_id[port]) + 1;
evdev_device = (char*)malloc(size_needed);
sprintf(evdev_device, EVDEV_DEVICE_STRING, evdev_device_id[port]);
size_needed = snprintf(NULL, 0, EVDEV_MAPPING_CONFIG_KEY, port+1) + 1;
evdev_config_key = (char*)malloc(size_needed);
sprintf(evdev_config_key, EVDEV_MAPPING_CONFIG_KEY, port+1);
string tmp;
const char* mapping = (cfgExists("input", evdev_config_key) == 2 ? (tmp = cfgLoadStr("input", evdev_config_key, "")).c_str() : NULL);
free(evdev_config_key);
input_evdev_init(&evdev_controllers[port], evdev_device, mapping);
free(evdev_device);
for (i = 0; i < port; i++)
{
if (evdev_device_id[port] == evdev_device_id[i])
{
// Multiple controllers with the same device, check for multiple button assignments
if (input_evdev_button_duplicate_button(evdev_controllers[i].mapping, evdev_controllers[port].mapping))
{
printf("WARNING: One or more button(s) of this device is also used in the configuration of input device %d (mapping: %s)\n", i, evdev_controllers[i].mapping->name.c_str());
}
}
}
mcfg_CreateController(port, GetMapleDeviceType(evdev_controllers[port].mapping->Maple_Device1, port), GetMapleDeviceType(evdev_controllers[port].mapping->Maple_Device2, port));
}
}
}
std::map<std::string, EvdevControllerMapping> loaded_mappings;
int load_keycode(ConfigFile* cfg, string section, string dc_key)
@ -490,6 +434,62 @@
}
}
void input_evdev_init()
{
int evdev_device_id[4] = { -1, -1, -1, -1 };
size_t size_needed;
int port, i;
char* evdev_device;
for (port = 0; port < 4; port++)
{
size_needed = snprintf(NULL, 0, EVDEV_DEVICE_CONFIG_KEY, port+1) + 1;
char* evdev_config_key = (char*)malloc(size_needed);
sprintf(evdev_config_key, EVDEV_DEVICE_CONFIG_KEY, port+1);
evdev_device_id[port] = cfgLoadInt("input", evdev_config_key, EVDEV_DEFAULT_DEVICE_ID(port+1));
free(evdev_config_key);
// Check if the same device is already in use on another port
if (evdev_device_id[port] < 0)
{
printf("evdev: Controller %d disabled by config.\n", port + 1);
}
else
{
size_needed = snprintf(NULL, 0, EVDEV_DEVICE_STRING, evdev_device_id[port]) + 1;
evdev_device = (char*)malloc(size_needed);
sprintf(evdev_device, EVDEV_DEVICE_STRING, evdev_device_id[port]);
size_needed = snprintf(NULL, 0, EVDEV_MAPPING_CONFIG_KEY, port+1) + 1;
evdev_config_key = (char*)malloc(size_needed);
sprintf(evdev_config_key, EVDEV_MAPPING_CONFIG_KEY, port+1);
string tmp;
const char* mapping = (cfgExists("input", evdev_config_key) == 2 ? (tmp = cfgLoadStr("input", evdev_config_key, "")).c_str() : NULL);
free(evdev_config_key);
input_evdev_init(&evdev_controllers[port], evdev_device, mapping);
free(evdev_device);
for (i = 0; i < port; i++)
{
if (evdev_device_id[port] == evdev_device_id[i])
{
// Multiple controllers with the same device, check for multiple button assignments
if (input_evdev_button_duplicate_button(evdev_controllers[i].mapping, evdev_controllers[port].mapping))
{
printf("WARNING: One or more button(s) of this device is also used in the configuration of input device %d (mapping: %s)\n", i, evdev_controllers[i].mapping->name.c_str());
}
}
}
mcfg_CreateController(port, GetMapleDeviceType(evdev_controllers[port].mapping->Maple_Device1, port), GetMapleDeviceType(evdev_controllers[port].mapping->Maple_Device2, port));
}
}
}
void input_evdev_close()
{
for (int port = 0; port < 4 ; port++)

View File

@ -75,7 +75,5 @@ struct EvdevController
extern void input_evdev_init();
extern void input_evdev_close();
extern int input_evdev_init(EvdevController* controller, const char* device, const char* mapping_fname);
extern bool input_evdev_handle(u32 port);
extern void input_evdev_rumble(u32 port, u16 pow_strong, u16 pow_weak);
extern bool input_evdev_button_duplicate_button(EvdevControllerMapping* mapping1, EvdevControllerMapping* mapping2);