|
6 | 6 | using UnityExplorer.UI;
|
7 | 7 | using System.Collections.Generic;
|
8 | 8 | using UnityExplorer.UI.Inspectors;
|
| 9 | +using System.Linq; |
9 | 10 |
|
10 | 11 | namespace UnityExplorer.Core.Input
|
11 | 12 | {
|
@@ -84,16 +85,28 @@ public Vector2 MousePosition
|
84 | 85 | }
|
85 | 86 |
|
86 | 87 | internal static Dictionary<KeyCode, object> ActualKeyDict = new Dictionary<KeyCode, object>();
|
| 88 | + internal static Dictionary<string, string> enumNameFixes = new Dictionary<string, string> |
| 89 | + { |
| 90 | + { "Control", "Ctrl" }, |
| 91 | + { "Return", "Enter" }, |
| 92 | + { "Alpha", "Digit" }, |
| 93 | + { "Keypad", "Numpad" }, |
| 94 | + { "Numlock", "NumLock" }, |
| 95 | + { "Print", "PrintScreen" }, |
| 96 | + { "BackQuote", "Backquote" } |
| 97 | + }; |
87 | 98 |
|
88 | 99 | internal object GetActualKey(KeyCode key)
|
89 | 100 | {
|
90 | 101 | if (!ActualKeyDict.ContainsKey(key))
|
91 | 102 | {
|
92 | 103 | var s = key.ToString();
|
93 |
| - if (s.Contains("Control")) |
94 |
| - s = s.Replace("Control", "Ctrl"); |
95 |
| - else if (s.Contains("Return")) |
96 |
| - s = "Enter"; |
| 104 | + try |
| 105 | + { |
| 106 | + if (enumNameFixes.First(it => s.Contains(it.Key)) is KeyValuePair<string, string> entry) |
| 107 | + s = s.Replace(entry.Key, entry.Value); |
| 108 | + } |
| 109 | + catch { } |
97 | 110 |
|
98 | 111 | var parsed = Enum.Parse(TKey, s);
|
99 | 112 | var actualKey = m_kbIndexer.GetValue(CurrentKeyboard, new object[] { parsed });
|
|
0 commit comments