Browse Source

Use the joystick's name in new gamepad mappings, when possible. Resolves issue #1370.

Alex Szpakowski 7 years ago
parent
commit
8e83834722
1 changed files with 12 additions and 2 deletions
  1. 12 2
      src/modules/joystick/sdl/JoystickModule.cpp

+ 12 - 2
src/modules/joystick/sdl/JoystickModule.cpp

@@ -199,8 +199,18 @@ bool JoystickModule::setGamepadMapping(const std::string &guid, Joystick::Gamepa
 	}
 	}
 	else
 	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;
 	std::stringstream joyinputstream;