From 80af04421aabc9b1457ffda58351b1eab862f7b8 Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Sat, 25 Aug 2018 10:17:10 +0200 Subject: [PATCH] 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;