Okay, update from me in case someone else finds this thread.
The situation here is that this input system does seem to provide some kind of localization for inputs, but there’s no control over it. For example, ToDisplayString() will add “Press”, “Hold”, etc, and as far as I can tell, it will translate input names based on… something ??? your operating system’s language, perhaps? but there doesn’t appear to be any control over this so there’s no way to get this system to respect your in-game language settings.
What I ended up doing is generating a set of input names that I could map to keys based on the Input System’s binding paths. Attached is a csv file containing those translations for anyone else who is interested.
Here’s how it works:
First, load this text file and convert it into a dictionary:
currentControlsDictionary_X = new Dictionary<string, string>();
TextAsset t = Resources.Load<TextAsset>("Loc/Inputs_X");
string[] split = t.text.Split('\n');
for (int i = 0; i < split.Length; i++)
{
if (split[i].Contains(","))
{
string[] split2 = split[i].Split(',');
if (!currentControlsDictionary_X.ContainsKey(split2[0]))
{
currentControlsDictionary_X.Add(split2[0], split2[(int)SaveManager.settings.currentLanguage + 1]);
}
}
}
Then, I get the translated string like this:
public static string GetInputDisplayString(InputAction inputAction, string bindingGroup)
{
InputBinding b = inputAction.bindings[inputAction.GetBindingIndex(bindingGroup)];
string path = b.overridePath;
if (string.IsNullOrEmpty(path))
path = b.path;
string key;
string[] split = path.Split('/');
if (split.Length > 2)//for example, controller/dpad/down
key = split[1] + split[2];
else
key = split[1];
if (bindingGroup == "Gamepad")
{
if (Gamepad.current is UnityEngine.InputSystem.DualShock.DualShockGamepad)
{
if (!currentControlsDictionary_P.ContainsKey(key))
return b.ToDisplayString();
else
{
//these strings are "Hold #" and and "Tap #". it's all I need for this game at the moment.
if (inputAction.interactions == "Hold")
return Strings.Controls_Hold.Replace("#", currentControlsDictionary_P[key]);
else if (inputAction.interactions == "Tap")
return Strings.Controls_Tap.Replace("#", currentControlsDictionary_P[key]);
else
return currentControlsDictionary_P[key];
}
}
else
{
if (!currentControlsDictionary_X.ContainsKey(key))
return b.ToDisplayString();
else
{
if (inputAction.interactions == "Hold")
return Strings.Controls_Hold.Replace("#", currentControlsDictionary_X[key]);
else if (inputAction.interactions == "Tap")
return Strings.Controls_Tap.Replace("#", currentControlsDictionary_X[key]);
else
return currentControlsDictionary_X[key];
}
}
}
else
{
if (!currentControlsDictionary_Keyboard.ContainsKey(key))
return b.ToDisplayString();
else
{
if (inputAction.interactions == "Hold")
return Strings.Controls_Hold.Replace("#", currentControlsDictionary_Keyboard[key]);
else if (inputAction.interactions == "Tap")
return Strings.Controls_Tap.Replace("#", currentControlsDictionary_Keyboard[key]);
else
return currentControlsDictionary_Keyboard[key];
}
}
}
8018432–1032470–Inputs_XboxController.zip (518 Bytes)