mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 06:13:36 +08:00
33 lines
910 B
C#
33 lines
910 B
C#
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);
|
|
}
|
|
}
|