mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 02:53:29 +08:00
WIP
This commit is contained in:
32
UXAssist/Common/KeyBindings.cs
Normal file
32
UXAssist/Common/KeyBindings.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using BepInEx.Configuration;
|
||||
using CommonAPI.Systems;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UXAssist.Common;
|
||||
|
||||
public static class KeyBindings
|
||||
{
|
||||
public static PressKeyBind RegisterKeyBinding(BuiltinKey key)
|
||||
{
|
||||
return CustomKeyBindSystem.RegisterKeyBindWithReturn<PressKeyBind>(key);
|
||||
}
|
||||
public static CombineKey FromKeyboardShortcut(KeyboardShortcut shortcut)
|
||||
{
|
||||
byte mod = 0;
|
||||
foreach (var modifier in shortcut.Modifiers)
|
||||
{
|
||||
mod |= modifier switch
|
||||
{
|
||||
KeyCode.LeftShift => 1,
|
||||
KeyCode.RightShift => 1,
|
||||
KeyCode.LeftControl => 2,
|
||||
KeyCode.RightControl => 2,
|
||||
KeyCode.LeftAlt => 4,
|
||||
KeyCode.RightAlt => 4,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
return new CombineKey((int)shortcut.MainKey, mod, ECombineKeyAction.OnceClick, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user