From 098cac3f60d78c6d905814878ff4811eaef42aba Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 31 Dec 2019 11:44:50 -0600 Subject: [PATCH] a few misc cleanups --- BizHawk.Client.EmuHawk/Input/OTK_Keyboard.cs | 43 +++++++------------ .../Properties/AssemblyInfo.cs | 1 - .../config/PSX/PSXControllerConfig.cs | 1 - .../tools/Lua/LuaConsole.cs | 1 - 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/BizHawk.Client.EmuHawk/Input/OTK_Keyboard.cs b/BizHawk.Client.EmuHawk/Input/OTK_Keyboard.cs index 200c970e6b..7ab287ab5a 100644 --- a/BizHawk.Client.EmuHawk/Input/OTK_Keyboard.cs +++ b/BizHawk.Client.EmuHawk/Input/OTK_Keyboard.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Text; using OpenTK.Input; namespace BizHawk.Client.EmuHawk @@ -25,7 +24,7 @@ namespace BizHawk.Client.EmuHawk {Key.Keypad0, SlimDX.DirectInput.Key.NumberPad0}, {Key.Keypad1, SlimDX.DirectInput.Key.NumberPad1}, {Key.Keypad2, SlimDX.DirectInput.Key.NumberPad2}, {Key.Keypad3, SlimDX.DirectInput.Key.NumberPad3}, {Key.Keypad4, SlimDX.DirectInput.Key.NumberPad4}, {Key.Keypad5, SlimDX.DirectInput.Key.NumberPad5}, {Key.Keypad6, SlimDX.DirectInput.Key.NumberPad6}, {Key.Keypad7, SlimDX.DirectInput.Key.NumberPad7}, {Key.Keypad8, SlimDX.DirectInput.Key.NumberPad8}, {Key.Keypad9, SlimDX.DirectInput.Key.NumberPad9}, {Key.KeypadAdd, SlimDX.DirectInput.Key.NumberPadPlus}, {Key.KeypadDecimal, SlimDX.DirectInput.Key.NumberPadPeriod}, {Key.KeypadDivide, SlimDX.DirectInput.Key.NumberPadSlash}, {Key.KeypadEnter, SlimDX.DirectInput.Key.NumberPadEnter}, {Key.KeypadMultiply, SlimDX.DirectInput.Key.NumberPadStar}, {Key.KeypadSubtract, SlimDX.DirectInput.Key.NumberPadMinus} }; - private static readonly List _eventList = new List(); + private static readonly List EventList = new List(); private static KeyboardState _kbState; public static void Initialize () @@ -35,7 +34,7 @@ namespace BizHawk.Client.EmuHawk public static IEnumerable Update () { - _eventList.Clear(); + EventList.Clear(); var lastState = _kbState; try { @@ -43,49 +42,37 @@ namespace BizHawk.Client.EmuHawk foreach (KeyValuePair entry in KeyEnumMap) { if (lastState.IsKeyUp(entry.Key) && _kbState.IsKeyDown(entry.Key)) - _eventList.Add(new KeyInput.KeyEvent { Key = entry.Value, Pressed = true }); + EventList.Add(new KeyInput.KeyEvent { Key = entry.Value, Pressed = true }); else if (lastState.IsKeyDown(entry.Key) && _kbState.IsKeyUp(entry.Key)) - _eventList.Add(new KeyInput.KeyEvent { Key = entry.Value, Pressed = false }); + EventList.Add(new KeyInput.KeyEvent { Key = entry.Value, Pressed = false }); } } catch { - //OpenTK's keyboard class isn't thread safe. - //In rare cases (sometimes it takes up to 10 minutes to occur) it will - //be updating the keyboard state when we call GetState() and choke. - //Until I fix OpenTK, it's fine to just swallow it because input continues working. - if(System.Diagnostics.Debugger.IsAttached) + // OpenTK's keyboard class isn't thread safe. + // In rare cases (sometimes it takes up to 10 minutes to occur) it will + // be updating the keyboard state when we call GetState() and choke. + // Until I fix OpenTK, it's fine to just swallow it because input continues working. + if (System.Diagnostics.Debugger.IsAttached) { System.Console.WriteLine("OpenTK Keyboard thread is angry."); } } - return _eventList; + return EventList; } - public static bool IsPressed (Key key) + public static bool IsPressed(Key key) { return _kbState.IsKeyDown(key); } - public static bool ShiftModifier { - get { - return IsPressed(Key.ShiftLeft) || IsPressed(Key.ShiftRight); - } - } + public static bool ShiftModifier => IsPressed(Key.ShiftLeft) || IsPressed(Key.ShiftRight); - public static bool CtrlModifier { - get { - return IsPressed(Key.ControlLeft) || IsPressed(Key.ControlRight); - } - } + public static bool CtrlModifier => IsPressed(Key.ControlLeft) || IsPressed(Key.ControlRight); - public static bool AltModifier { - get { - return IsPressed(Key.AltLeft) || IsPressed(Key.AltRight); - } - } + public static bool AltModifier => IsPressed(Key.AltLeft) || IsPressed(Key.AltRight); - public static Input.ModifierKey GetModifierKeysAsKeys () + public static Input.ModifierKey GetModifierKeysAsKeys() { Input.ModifierKey ret = Input.ModifierKey.None; if (ShiftModifier) diff --git a/BizHawk.Client.EmuHawk/Properties/AssemblyInfo.cs b/BizHawk.Client.EmuHawk/Properties/AssemblyInfo.cs index e317ccb818..1fa79bb7e3 100644 --- a/BizHawk.Client.EmuHawk/Properties/AssemblyInfo.cs +++ b/BizHawk.Client.EmuHawk/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfig.cs b/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfig.cs index 6f20bf17cc..728dc26c49 100644 --- a/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfig.cs +++ b/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfig.cs @@ -2,7 +2,6 @@ using System.Windows.Forms; using BizHawk.Emulation.Cores.Sony.PSX; -using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk { diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index d2ee978a82..7f461e199b 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -13,7 +13,6 @@ using BizHawk.Client.EmuHawk.ToolExtensions; using BizHawk.Client.EmuHawk.WinFormExtensions; using BizHawk.Common; using BizHawk.Emulation.Common; -using NLua; namespace BizHawk.Client.EmuHawk {