From 8e8383472219c9072da2ceb80e4111f26de3a6f8 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Fri, 16 Feb 2018 18:20:35 -0400 Subject: [PATCH] Use the joystick's name in new gamepad mappings, when possible. Resolves issue #1370. --- src/modules/joystick/sdl/JoystickModule.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/modules/joystick/sdl/JoystickModule.cpp b/src/modules/joystick/sdl/JoystickModule.cpp index e297883f7..393d60323 100644 --- a/src/modules/joystick/sdl/JoystickModule.cpp +++ b/src/modules/joystick/sdl/JoystickModule.cpp @@ -199,8 +199,18 @@ bool JoystickModule::setGamepadMapping(const std::string &guid, Joystick::Gamepa } else { - // Use a generic name if we have to create a new mapping string. - mapstr = guid + ",Controller,"; + std::string name = "Controller"; + + for (love::joystick::Joystick *stick : joysticks) + { + if (stick->getGUID() == guid) + { + name = stick->getName(); + break; + } + } + + mapstr = guid + "," + name + ","; } std::stringstream joyinputstream;