From 555e1402169361c9c4ba4db467bda556098c12e3 Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Fri, 31 Aug 2018 16:59:37 +0200 Subject: [PATCH] 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. --- core/linux-dist/evdev.cpp | 112 +++++++++++++++++++------------------- core/linux-dist/evdev.h | 2 - 2 files changed, 56 insertions(+), 58 deletions(-) diff --git a/core/linux-dist/evdev.cpp b/core/linux-dist/evdev.cpp index 25ff4c315..6eb60624e 100644 --- a/core/linux-dist/evdev.cpp +++ b/core/linux-dist/evdev.cpp @@ -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 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++) diff --git a/core/linux-dist/evdev.h b/core/linux-dist/evdev.h index 348fbc4e8..10d298819 100644 --- a/core/linux-dist/evdev.h +++ b/core/linux-dist/evdev.h @@ -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);