-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for 0.219.13 (The Bog Witch)
- Loading branch information
1 parent
d19b62d
commit 6e1f850
Showing
3 changed files
with
5 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,8 @@ | ||
using UnityEngine; | ||
using UnityEngine.InputSystem; | ||
using UnityEngine.InputSystem.LowLevel; | ||
|
||
namespace BetterCartographyTable.Extensions; | ||
|
||
public static class KeyCodeExtensions | ||
{ | ||
public static string ToKeyHintString(this KeyCode keyCode) | ||
{ | ||
var (isMouseButton, mouseButton) = ZInput.KeyCodeToMouseButton(keyCode, logWarning: false); | ||
if (isMouseButton) | ||
{ | ||
var mouseString = mouseButton switch | ||
{ | ||
MouseButton.Left => "$button_mouse0", | ||
MouseButton.Right => "$button_mouse1", | ||
MouseButton.Middle => "$button_mouse2", | ||
MouseButton.Forward => Mouse.current?.forwardButton.displayName ?? "Mouse Forward", | ||
MouseButton.Back => Mouse.current?.backButton.displayName ?? "Mouse Back", | ||
_ => null, | ||
}; | ||
if (mouseString is not null) return mouseString; | ||
} | ||
|
||
var key = ZInput.KeyCodeToKey(keyCode, logWarning: false); | ||
return key switch | ||
{ | ||
Key.Comma => ",", | ||
Key.Period => ".", | ||
Key.Space => "$button_space", | ||
Key.LeftShift => "$button_lshift", | ||
Key.RightShift => "$button_rshift", | ||
Key.LeftAlt => "$button_lalt", | ||
Key.RightAlt => "$button_ralt", | ||
Key.LeftCtrl => "$button_lctrl", | ||
Key.RightCtrl => "$button_rctrl", | ||
Key.Enter => "$button_return", | ||
Key.NumpadEnter => "$button_return", | ||
Key.None => "$menu_none", | ||
_ => Keyboard.current?[key].displayName ?? key.ToString(), | ||
}; | ||
} | ||
public static string ToKeyHintString(this KeyCode keyCode) => ZInput.KeyCodeToDisplayName(keyCode); | ||
} |