From 80af04421aabc9b1457ffda58351b1eab862f7b8 Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Sat, 25 Aug 2018 10:17:10 +0200 Subject: [PATCH 1/2] evdev: Mapping name as string That way we don't need to reserve memory and the output (on the command line) is correct. --- core/linux-dist/evdev.cpp | 14 +++++++------- core/linux-dist/evdev.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/linux-dist/evdev.cpp b/core/linux-dist/evdev.cpp index 4d062fab4..9b7e83b5d 100644 --- a/core/linux-dist/evdev.cpp +++ b/core/linux-dist/evdev.cpp @@ -123,7 +123,7 @@ int type = ((strstr(keycode.c_str(), "ABS_") != NULL) ? EV_ABS : EV_KEY); code = libevdev_event_code_from_name(type, keycode.c_str()); } - + if (code < 0) { printf("evdev: failed to find keycode for '%s'\n", keycode.c_str()); @@ -139,13 +139,13 @@ if(code >= 0) { char* name = NULL; - + if (libevdev_available) { int type = ((strstr(dc_key.c_str(), "axis_") != NULL) ? EV_ABS : EV_KEY); name = (char*)libevdev_event_code_get_name(type, code); } - + if (name != NULL) { printf("%s = %s (%d)\n", dc_key.c_str(), name, code); @@ -156,10 +156,10 @@ } } } - + if (code < 0) printf("WARNING: %s/%s not configured!\n", section.c_str(), dc_key.c_str()); - + return code; } @@ -169,7 +169,7 @@ mf.parse(fd); EvdevControllerMapping mapping = { - mf.get("emulator", "mapping_name", "").c_str(), + mf.get("emulator", "mapping_name", ""), load_keycode(&mf, "dreamcast", "btn_a"), load_keycode(&mf, "dreamcast", "btn_b"), load_keycode(&mf, "dreamcast", "btn_c"), @@ -370,7 +370,7 @@ } } controller->mapping = &loaded_mappings.find(string(mapping_fname))->second; - printf("evdev: Using '%s' mapping\n", controller->mapping->name); + printf("evdev: Using '%s' mapping\n", controller->mapping->name.c_str()); controller->init(); return 0; diff --git a/core/linux-dist/evdev.h b/core/linux-dist/evdev.h index fca2e3f14..464f13a00 100644 --- a/core/linux-dist/evdev.h +++ b/core/linux-dist/evdev.h @@ -4,7 +4,7 @@ struct EvdevControllerMapping { - const char* name; + const string name; const int Btn_A; const int Btn_B; const int Btn_C; From 8593c209d9c26634df52b09d31b9ba243575a3c1 Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Sat, 25 Aug 2018 10:55:52 +0200 Subject: [PATCH 2/2] Fixed type of formatting argument --- core/linux-dist/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/linux-dist/main.cpp b/core/linux-dist/main.cpp index 7990a702c..b86540888 100755 --- a/core/linux-dist/main.cpp +++ b/core/linux-dist/main.cpp @@ -192,7 +192,7 @@ void os_SetupInput() // 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); + 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()); } } }