Browse Source

Add input manager

habeebweeb 4 years ago
parent
commit
1ea3d1bcf1
19 changed files with 217 additions and 83 deletions
  1. 13 2
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragPoint/DragPoint.cs
  2. 8 7
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragPoint/DragPointGeneral.cs
  3. 2 4
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Windows/MainWindow.cs
  4. 1 4
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Windows/MessageWindow.cs
  5. 1 1
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Windows/SceneWindow.cs
  6. 13 4
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/EnvironmentManager.cs
  7. 117 0
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/InputManager.cs
  8. 6 1
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/MeidoManager.cs
  9. 1 0
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/MessageWindowManager.cs
  10. 8 3
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/SceneManager.cs
  11. 5 0
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/WindowManager.cs
  12. 6 10
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointChain.cs
  13. 3 2
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointFinger.cs
  14. 6 4
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointHead.cs
  15. 4 8
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointPelvis.cs
  16. 6 10
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointSpine.cs
  17. 4 8
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointTorso.cs
  18. 13 4
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MeidoPhotoStudio.cs
  19. 0 11
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Utility.cs

+ 13 - 2
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragPoint/DragPoint.cs

@@ -90,6 +90,16 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
         }
 
+        static DragPoint()
+        {
+            InputManager.Register(MpsKey.DragSelect, KeyCode.A);
+            InputManager.Register(MpsKey.DragDelete, KeyCode.D);
+            InputManager.Register(MpsKey.DragMove, KeyCode.Z);
+            InputManager.Register(MpsKey.DragRotate, KeyCode.X);
+            InputManager.Register(MpsKey.DragScale, KeyCode.C);
+            InputManager.Register(MpsKey.DragFinger, KeyCode.Space);
+        }
+
         private void Awake()
         {
             this.BaseScale = transform.localScale;
@@ -152,8 +162,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected bool OtherDragType()
         {
-            return Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D)
-                || Input.GetKey(KeyCode.Z) || Input.GetKey(KeyCode.X) || Input.GetKey(KeyCode.C);
+            return InputManager.GetKey(MpsKey.DragSelect) || InputManager.GetKey(MpsKey.DragDelete)
+                || InputManager.GetKey(MpsKey.DragMove) || InputManager.GetKey(MpsKey.DragRotate)
+                || InputManager.GetKey(MpsKey.DragScale) || InputManager.GetKey(MpsKey.DragFinger);
         }
 
         protected Vector3 CursorPosition()

+ 8 - 7
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragPoint/DragPointGeneral.cs

@@ -4,6 +4,7 @@ using UnityEngine;
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
     using static CustomGizmo;
+    using Input = InputManager;
 
     internal abstract class DragPointGeneral : DragPoint
     {
@@ -57,25 +58,25 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void UpdateDragType()
         {
-            bool shift = Utility.GetModKey(Utility.ModKey.Shift);
-            if (Input.GetKey(KeyCode.A))
+            bool shift = Input.Shift;
+            if (Input.GetKey(MpsKey.DragSelect))
             {
                 CurrentDragType = DragType.Select;
             }
-            else if (Input.GetKey(KeyCode.D))
+            else if (Input.GetKey(MpsKey.DragDelete))
             {
                 CurrentDragType = DragType.Delete;
             }
-            else if (Input.GetKey(KeyCode.Z))
+            else if (Input.GetKey(MpsKey.DragMove))
             {
-                if (Utility.GetModKey(Utility.ModKey.Control)) CurrentDragType = DragType.MoveY;
+                if (Input.Control) CurrentDragType = DragType.MoveY;
                 else CurrentDragType = shift ? DragType.RotY : DragType.MoveXZ;
             }
-            else if (Input.GetKey(KeyCode.X))
+            else if (Input.GetKey(MpsKey.DragRotate))
             {
                 CurrentDragType = shift ? DragType.RotLocalY : DragType.RotLocalXZ;
             }
-            else if (Input.GetKey(KeyCode.C))
+            else if (Input.GetKey(MpsKey.DragScale))
             {
                 CurrentDragType = DragType.Scale;
             }

+ 2 - 4
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Windows/MainWindow.cs

@@ -44,7 +44,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             this.lightManager.Select += (s, a) => ChangeWindow(Constants.Window.BG);
 
             windowPanes = new Dictionary<Constants.Window, BaseWindowPane>();
-            windowRect = new Rect(Screen.width, Screen.height * 0.08f, 230f, Screen.height * 0.9f);
+            WindowRect = new Rect(Screen.width, Screen.height * 0.08f, 240f, Screen.height * 0.9f);
 
             tabsPane = new TabsPane();
             tabsPane.TabChange += (s, a) => ChangeTab();
@@ -54,8 +54,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 Translation.ReinitializeTranslation();
             };
-            windowRect.width = 240f;
-            windowRect.height = Screen.height * 0.9f;
         }
 
         public override void Activate()
@@ -93,7 +91,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public override void Update()
         {
             base.Update();
-            if (Input.GetKeyDown(KeyCode.Tab))
+            if (InputManager.GetKeyDown(MpsKey.ToggleUI))
             {
                 this.Visible = !this.Visible;
             }

+ 1 - 4
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Windows/MessageWindow.cs

@@ -72,10 +72,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public override void Update()
         {
             base.Update();
-            if (Input.GetKeyDown(KeyCode.M))
-            {
-                this.ToggleVisibility();
-            }
+            if (InputManager.GetKeyDown(MpsKey.ToggleMessage)) this.ToggleVisibility();
         }
 
         public override void Draw()

+ 1 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Windows/SceneWindow.cs

@@ -55,7 +55,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public override void Update()
         {
             base.Update();
-            if (Input.GetKeyDown(KeyCode.F8)) Visible = !Visible;
+            if (InputManager.GetKeyDown(MpsKey.OpenSceneManager)) Visible = !Visible;
         }
 
         public override void Deactivate()

+ 13 - 4
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/EnvironmentManager.cs

@@ -4,6 +4,7 @@ using UnityEngine;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
+    using Input = InputManager;
     internal class EnvironmentManager : IManager, ISerializable
     {
         public const string header = "ENVIRONMENT";
@@ -53,6 +54,14 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
         }
 
+        static EnvironmentManager()
+        {
+            Input.Register(MpsKey.CameraLayer, KeyCode.Q);
+            Input.Register(MpsKey.CameraSave, KeyCode.S);
+            Input.Register(MpsKey.CameraLoad, KeyCode.A);
+            Input.Register(MpsKey.CameraReset, KeyCode.R);
+        }
+
         public EnvironmentManager(MeidoManager meidoManager)
         {
             DragPointLight.environmentManager = this;
@@ -185,19 +194,19 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         public void Update()
         {
-            if (Input.GetKey(KeyCode.Q))
+            if (Input.GetKey(MpsKey.CameraLayer))
             {
-                if (Input.GetKeyDown(KeyCode.S))
+                if (Input.GetKeyDown(MpsKey.CameraSave))
                 {
                     SaveCameraInfo();
                 }
 
-                if (Input.GetKeyDown(KeyCode.A))
+                if (Input.GetKeyDown(MpsKey.CameraLoad))
                 {
                     LoadCameraInfo(cameraInfo);
                 }
 
-                if (Input.GetKeyDown(KeyCode.R))
+                if (Input.GetKeyDown(MpsKey.CameraReset))
                 {
                     ResetCamera();
                 }

+ 117 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/InputManager.cs

@@ -0,0 +1,117 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+
+namespace COM3D2.MeidoPhotoStudio.Plugin
+{
+    internal class InputManager
+    {
+        private static InputListener inputListener;
+        public static KeyCode CurrentKeyCode { get; private set; }
+        public static bool Listening { get; private set; }
+        public static event EventHandler KeyChange;
+        public static bool Control => Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
+        public static bool Alt => Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt);
+        public static bool Shift => Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
+        private static readonly Dictionary<MpsKey, KeyCode> Actions = new Dictionary<MpsKey, KeyCode>();
+
+        public static void Register(MpsKey action, KeyCode key) => Actions[action] = key;
+
+        public static void StartListening()
+        {
+            if (inputListener == null) inputListener = new GameObject().AddComponent<InputListener>();
+            else if (inputListener.gameObject.activeSelf) StopListening();
+
+            inputListener.gameObject.SetActive(true);
+            inputListener.KeyChange += OnKeyChange;
+            CurrentKeyCode = KeyCode.None;
+            Listening = true;
+        }
+
+        public static void StopListening()
+        {
+            if (inputListener == null || !inputListener.gameObject.activeSelf) return;
+            inputListener.gameObject.SetActive(false);
+            inputListener.KeyChange -= OnKeyChange;
+            CurrentKeyCode = KeyCode.None;
+        }
+
+        public static bool GetKey(MpsKey action)
+        {
+            return (Listening || !Actions.ContainsKey(action)) ? false : Input.GetKey(Actions[action]);
+        }
+
+        public static bool GetKeyDown(MpsKey action)
+        {
+            return (Listening || !Actions.ContainsKey(action)) ? false : Input.GetKeyDown(Actions[action]);
+        }
+
+        public static void Deactivate()
+        {
+            StopListening();
+            GameObject.Destroy(inputListener?.gameObject);
+            inputListener = null;
+        }
+
+        private static void OnKeyChange(object sender, KeyChangeEventArgs args)
+        {
+            CurrentKeyCode = args.Key;
+            KeyChange?.Invoke(null, EventArgs.Empty);
+            StopListening();
+        }
+
+        /* Listener taken from https://forum.unity.com/threads/find-out-which-key-was-pressed.385250/ */
+        private class InputListener : MonoBehaviour
+        {
+            private static readonly KeyCode[] keyCodes;
+            public event EventHandler<KeyChangeEventArgs> KeyChange;
+
+            static InputListener()
+            {
+                keyCodes = Enum.GetValues(typeof(KeyCode))
+                    .Cast<KeyCode>()
+                    .Where(keyCode => keyCode < KeyCode.Numlock)
+                    .ToArray();
+            }
+
+            private void Awake() => DontDestroyOnLoad(this);
+
+            private void Update()
+            {
+                if (Input.anyKeyDown)
+                {
+                    foreach (KeyCode key in keyCodes)
+                    {
+                        if (Input.GetKeyDown(key))
+                        {
+                            KeyChange?.Invoke(this, new KeyChangeEventArgs(key));
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+
+        private class KeyChangeEventArgs : EventArgs
+        {
+            public KeyCode Key { get; }
+            public KeyChangeEventArgs(KeyCode key) => this.Key = key;
+        }
+    }
+
+    internal enum MpsKey
+    {
+        // MeidoPhotoStudio
+        Activate, Screenshot, ToggleUI, ToggleMessage,
+        // MeidoManager
+        MeidoUndressing,
+        // Camera
+        CameraLayer, CameraReset, CameraSave, CameraLoad,
+        // Dragpoint
+        DragSelect, DragDelete, DragMove, DragRotate, DragScale,
+        DragFinger,
+        // Scene management
+        SaveScene, LoadScene, OpenSceneManager
+    }
+}

+ 6 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/MeidoManager.cs

@@ -47,6 +47,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
         }
 
+        static MeidoManager()
+        {
+            InputManager.Register(MpsKey.MeidoUndressing, KeyCode.H);
+        }
+
         public void ChangeMaid(int index)
         {
             OnUpdateMeido(null, new MeidoUpdateEventArgs(index));
@@ -78,7 +83,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         public void Update()
         {
-            if (Input.GetKeyDown(KeyCode.H)) UndressAll();
+            if (InputManager.GetKeyDown(MpsKey.MeidoUndressing)) UndressAll();
         }
 
         public void Serialize(System.IO.BinaryWriter binaryWriter)

+ 1 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/MessageWindowManager.cs

@@ -19,6 +19,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         public MessageWindowManager()
         {
+            InputManager.Register(MpsKey.ToggleMessage, KeyCode.M);
             sysRoot = GameObject.Find("__GameMain__/SystemUI Root");
             this.msgWnd = GameMain.Instance.MsgWnd;
             this.msgGameObject = sysRoot.transform.Find("MessageWindowPanel").gameObject;

+ 8 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/SceneManager.cs

@@ -7,6 +7,7 @@ using BepInEx.Configuration;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
+    using Input = InputManager;
     internal class SceneManager : IManager
     {
         public static bool Busy { get; private set; } = false;
@@ -67,6 +68,10 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 SortMode.Name,
                 "Scene sorting mode"
             );
+
+            InputManager.Register(MpsKey.OpenSceneManager, KeyCode.F8);
+            InputManager.Register(MpsKey.SaveScene, KeyCode.S);
+            InputManager.Register(MpsKey.LoadScene, KeyCode.A);
         }
 
         public SceneManager(MeidoPhotoStudio meidoPhotoStudio)
@@ -90,10 +95,10 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         public void Update()
         {
-            if (Utility.GetModKey(Utility.ModKey.Control))
+            if (Input.Control)
             {
-                if (Input.GetKeyDown(KeyCode.S)) QuickSaveScene();
-                else if (Input.GetKeyDown(KeyCode.A)) QuickLoadScene();
+                if (Input.GetKeyDown(MpsKey.SaveScene)) QuickSaveScene();
+                else if (Input.GetKeyDown(MpsKey.LoadScene)) QuickLoadScene();
             }
         }
 

+ 5 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/WindowManager.cs

@@ -13,6 +13,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             set => Windows[id] = value;
         }
 
+        public WindowManager()
+        {
+            InputManager.Register(MpsKey.ToggleUI, KeyCode.Tab);
+        }
+
         public void DrawWindow(BaseWindow window)
         {
             if (window.Visible)

+ 6 - 10
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointChain.cs

@@ -2,6 +2,7 @@ using UnityEngine;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
+    using Input = InputManager;
     internal class DragPointChain : DragPointMeido
     {
         private readonly TBody.IKCMO IK = new TBody.IKCMO();
@@ -69,14 +70,10 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void UpdateDragType()
         {
-            bool control = Utility.GetModKey(Utility.ModKey.Control);
-            bool alt = Utility.GetModKey(Utility.ModKey.Alt);
+            bool control = Input.Control;
+            bool alt = Input.Alt;
 
-            if (Input.GetKey(KeyCode.Space) || OtherDragType())
-            {
-                CurrentDragType = DragType.Ignore;
-            }
-            else if (control && alt)
+            if (control && alt)
             {
                 // mune
                 CurrentDragType = DragType.RotY;
@@ -87,12 +84,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
             else if (alt)
             {
-                bool shift = Utility.GetModKey(Utility.ModKey.Shift);
-                CurrentDragType = shift ? DragType.RotLocalY : DragType.RotLocalXZ;
+                CurrentDragType = Input.Shift ? DragType.RotLocalY : DragType.RotLocalXZ;
             }
             else
             {
-                CurrentDragType = DragType.None;
+                CurrentDragType = OtherDragType() ? DragType.Ignore : DragType.None;
             }
         }
 

+ 3 - 2
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointFinger.cs

@@ -2,6 +2,7 @@ using UnityEngine;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
+    using Input = InputManager;
     internal class DragPointFinger : DragPointMeido
     {
         private readonly TBody.IKCMO IK = new TBody.IKCMO();
@@ -39,9 +40,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void UpdateDragType()
         {
-            if (Input.GetKey(KeyCode.Space))
+            if (Input.GetKey(MpsKey.DragFinger))
             {
-                CurrentDragType = Utility.GetModKey(Utility.ModKey.Shift)
+                CurrentDragType = Input.Shift
                     ? DragType.RotLocalY
                     : DragType.MoveXZ;
             }

+ 6 - 4
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointHead.cs

@@ -3,6 +3,7 @@ using UnityEngine;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
+    using Input = InputManager;
     internal class DragPointHead : DragPointMeido
     {
         TBody body;
@@ -31,18 +32,19 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void UpdateDragType()
         {
-            bool shift = Utility.GetModKey(Utility.ModKey.Shift);
-            if (Utility.GetModKey(Utility.ModKey.Alt) && Utility.GetModKey(Utility.ModKey.Control))
+            bool shift = Input.Shift;
+            bool alt = Input.Alt;
+            if (alt && Input.Control)
             {
                 // eyes
                 CurrentDragType = shift ? DragType.MoveY : DragType.MoveXZ;
             }
-            else if (Utility.GetModKey(Utility.ModKey.Alt))
+            else if (alt)
             {
                 // head
                 CurrentDragType = shift ? DragType.RotLocalY : DragType.RotLocalXZ;
             }
-            else if (Input.GetKey(KeyCode.A))
+            else if (Input.GetKey(MpsKey.DragSelect))
             {
                 CurrentDragType = DragType.Select;
             }

+ 4 - 8
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointPelvis.cs

@@ -2,6 +2,7 @@ using UnityEngine;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
+    using Input = InputManager;
     internal class DragPointPelvis : DragPointMeido
     {
         private Quaternion pelvisRotation;
@@ -15,18 +16,13 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void UpdateDragType()
         {
-            if (Input.GetKey(KeyCode.Space) || OtherDragType())
+            if (Input.Alt && !Input.Control)
             {
-                CurrentDragType = DragType.Ignore;
-            }
-            else if (Utility.GetModKey(Utility.ModKey.Alt) && !Utility.GetModKey(Utility.ModKey.Control))
-            {
-                bool shift = Utility.GetModKey(Utility.ModKey.Shift);
-                CurrentDragType = shift ? DragType.RotLocalY : DragType.RotLocalXZ;
+                CurrentDragType = Input.Shift ? DragType.RotLocalY : DragType.RotLocalXZ;
             }
             else
             {
-                CurrentDragType = DragType.None;
+                CurrentDragType = OtherDragType() ? DragType.Ignore : DragType.None;
             }
         }
 

+ 6 - 10
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointSpine.cs

@@ -2,6 +2,7 @@ using UnityEngine;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
+    using Input = InputManager;
     internal class DragPointSpine : DragPointMeido
     {
         private Quaternion spineRotation;
@@ -38,15 +39,10 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void UpdateDragType()
         {
-            bool shift = Utility.GetModKey(Utility.ModKey.Shift);
-            bool alt = Utility.GetModKey(Utility.ModKey.Alt);
-            bool ctrl = Utility.GetModKey(Utility.ModKey.Control);
+            bool shift = Input.Shift;
+            bool alt = Input.Alt;
 
-            if (Input.GetKey(KeyCode.Space) || OtherDragType())
-            {
-                CurrentDragType = DragType.Ignore;
-            }
-            else if (isThigh && alt && shift)
+            if (isThigh && alt && shift)
             {
                 // gizmo thigh rotation
                 CurrentDragType = DragType.RotLocalXZ;
@@ -59,14 +55,14 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 CurrentDragType = DragType.RotLocalY;
             }
-            else if (ctrl)
+            else if (Input.Control)
             {
                 // hip y transform and spine gizmo rotation
                 CurrentDragType = DragType.MoveY;
             }
             else
             {
-                CurrentDragType = DragType.None;
+                CurrentDragType = OtherDragType() ? DragType.Ignore : DragType.None;
             }
         }
 

+ 4 - 8
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointTorso.cs

@@ -2,6 +2,7 @@ using UnityEngine;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
+    using Input = InputManager;
     internal class DragPointTorso : DragPointMeido
     {
         private static readonly float[] blah = new[] { 0.03f, 0.1f, 0.09f, 0.07f };
@@ -29,18 +30,13 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void UpdateDragType()
         {
-            if (Input.GetKey(KeyCode.Space) || OtherDragType())
+            if (Input.Alt && !Input.Control)
             {
-                CurrentDragType = DragType.Ignore;
-            }
-            else if (Utility.GetModKey(Utility.ModKey.Alt) && !Utility.GetModKey(Utility.ModKey.Control))
-            {
-                bool shift = Utility.GetModKey(Utility.ModKey.Shift);
-                CurrentDragType = shift ? DragType.RotLocalY : DragType.RotLocalXZ;
+                CurrentDragType = Input.Shift ? DragType.RotLocalY : DragType.RotLocalXZ;
             }
             else
             {
-                CurrentDragType = DragType.None;
+                CurrentDragType = OtherDragType() ? DragType.Ignore : DragType.None;
             }
         }
 

+ 13 - 4
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MeidoPhotoStudio.cs

@@ -9,6 +9,7 @@ using BepInEx;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
+    using Input = InputManager;
     [BepInPlugin(pluginGuid, pluginName, pluginVersion)]
     public class MeidoPhotoStudio : BaseUnityPlugin
     {
@@ -33,6 +34,12 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         private bool active = false;
         private bool uiActive = false;
 
+        static MeidoPhotoStudio()
+        {
+            Input.Register(MpsKey.Screenshot, KeyCode.S);
+            Input.Register(MpsKey.Activate, KeyCode.F6);
+        }
+
         private void Awake()
         {
             ScreenshotEvent += OnScreenshotEvent;
@@ -213,7 +220,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             if (currentScene == Constants.Scene.Daily)
             {
-                if (Input.GetKeyDown(KeyCode.F6))
+                if (Input.GetKeyDown(MpsKey.Activate))
                 {
                     if (active) Deactivate();
                     else Activate();
@@ -221,9 +228,10 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
                 if (active)
                 {
-                    if (!Input.GetKey(KeyCode.Q) && !Utility.GetModKey(Utility.ModKey.Control)
-                        && Input.GetKeyDown(KeyCode.S)
-                    ) TakeScreenshot();
+                    if (!Input.Control && !Input.GetKey(MpsKey.CameraLayer) && Input.GetKeyDown(MpsKey.Screenshot))
+                    {
+                        TakeScreenshot();
+                    }
 
                     meidoManager.Update();
                     environmentManager.Update();
@@ -411,6 +419,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 effectManager.Deactivate();
                 messageWindowManager.Deactivate();
                 windowManager.Deactivate();
+                InputManager.Deactivate();
 
                 Modal.Close();
 

+ 0 - 11
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Utility.cs

@@ -85,17 +85,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             GetFieldInfo<TType>(name).SetValue(instance, value);
         }
 
-        public static bool GetModKey(ModKey key)
-        {
-            switch (key)
-            {
-                case ModKey.Control: return Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
-                case ModKey.Alt: return Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt);
-                case ModKey.Shift: return Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
-                default: return false;
-            }
-        }
-
         public static bool AnyMouseDown()
         {
             return Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2);