41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
using UnityEngine;
|
|
|
|
namespace Ironspore
|
|
{
|
|
// Adapts UI Toolkit events only; gameplay continues to use Input System actions.
|
|
public static class SettingsInputCapture
|
|
{
|
|
public static string KeyboardPath(KeyCode key)
|
|
{
|
|
string name = key.ToString();
|
|
if (key >= KeyCode.Alpha0 && key <= KeyCode.Alpha9)
|
|
name = ((int)key - (int)KeyCode.Alpha0).ToString();
|
|
else if (name.StartsWith("Keypad"))
|
|
name = "numpad" + name.Substring(6);
|
|
switch (key)
|
|
{
|
|
case KeyCode.Return: name = "enter"; break;
|
|
case KeyCode.LeftControl: name = "leftCtrl"; break;
|
|
case KeyCode.RightControl: name = "rightCtrl"; break;
|
|
case KeyCode.LeftWindows: case KeyCode.LeftCommand: name = "leftMeta"; break;
|
|
case KeyCode.RightWindows: case KeyCode.RightCommand: name = "rightMeta"; break;
|
|
case KeyCode.Print: name = "printScreen"; break;
|
|
}
|
|
return "<Keyboard>/" + name.ToLowerInvariant();
|
|
}
|
|
|
|
public static string MousePath(int button)
|
|
{
|
|
switch (button)
|
|
{
|
|
case 0: return "<Mouse>/leftButton";
|
|
case 1: return "<Mouse>/rightButton";
|
|
case 2: return "<Mouse>/middleButton";
|
|
case 3: return "<Mouse>/backButton";
|
|
case 4: return "<Mouse>/forwardButton";
|
|
default: return "";
|
|
}
|
|
}
|
|
}
|
|
}
|