From 4d5e588a59b34d4b1b3cf9393cd1d31e2b0a37b7 Mon Sep 17 00:00:00 2001 From: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com> Date: Sun, 5 May 2024 14:19:05 -0700 Subject: [PATCH] Remove DInput input adapter (#3867) --- .../BizHawk.Bizware.Input.csproj | 2 - src/BizHawk.Bizware.Input/DirectX/DGamepad.cs | 291 -------------- .../DirectX/DKeyInput.cs | 377 ------------------ .../DirectX/DirectInputAdapter.cs | 77 ---- src/BizHawk.Bizware.Input/DirectX/XGamepad.cs | 220 ---------- .../KeyInput/RawKeyInput.cs | 30 +- src/BizHawk.Client.Common/config/Config.cs | 2 - .../config/ConfigEnums.cs | 6 - src/BizHawk.Client.EmuHawk/Input/Input.cs | 8 +- .../config/EmuHawkOptions.Designer.cs | 112 ++---- .../config/EmuHawkOptions.cs | 16 - 11 files changed, 58 insertions(+), 1083 deletions(-) delete mode 100644 src/BizHawk.Bizware.Input/DirectX/DGamepad.cs delete mode 100644 src/BizHawk.Bizware.Input/DirectX/DKeyInput.cs delete mode 100644 src/BizHawk.Bizware.Input/DirectX/DirectInputAdapter.cs delete mode 100644 src/BizHawk.Bizware.Input/DirectX/XGamepad.cs diff --git a/src/BizHawk.Bizware.Input/BizHawk.Bizware.Input.csproj b/src/BizHawk.Bizware.Input/BizHawk.Bizware.Input.csproj index a43e7e1abb..ffb3ee4b93 100644 --- a/src/BizHawk.Bizware.Input/BizHawk.Bizware.Input.csproj +++ b/src/BizHawk.Bizware.Input/BizHawk.Bizware.Input.csproj @@ -8,8 +8,6 @@ disable - - diff --git a/src/BizHawk.Bizware.Input/DirectX/DGamepad.cs b/src/BizHawk.Bizware.Input/DirectX/DGamepad.cs deleted file mode 100644 index 29d1d2d21a..0000000000 --- a/src/BizHawk.Bizware.Input/DirectX/DGamepad.cs +++ /dev/null @@ -1,291 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using System.Reflection; - -using BizHawk.Common; - -using Vortice.DirectInput; - -namespace BizHawk.Bizware.Input -{ - internal sealed class DGamepad - { - private static readonly object SyncObj = new(); - private static readonly List Devices = new(); - private static IDirectInput8 _directInput; - - public static void Initialize(IntPtr mainFormHandle) - { - lock (SyncObj) - { - Cleanup(); - - _directInput = DInput.DirectInput8Create(); - - foreach (var device in _directInput.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly)) - { - Console.WriteLine("joy device: {0} `{1}`", device.InstanceGuid, device.ProductName); - - if (device.ProductName.Contains("XBOX 360") || device.ProductName.Contains("Xbox One") || device.ProductName.Contains("XINPUT")) - continue; // Don't input XBOX 360 controllers into here; we'll process them via XInput (there are limitations in some trigger axes when xbox pads go over xinput) - - var joystick = _directInput.CreateDevice(device.InstanceGuid); - joystick.SetCooperativeLevel(mainFormHandle, CooperativeLevel.Background | CooperativeLevel.NonExclusive); - joystick.SetDataFormat(); -#if false - // GetObjects returns localized names, so this doesn't actually work - foreach (var deviceObject in joystick.GetObjects(DeviceObjectTypeFlags.Axis)) - { - joystick.GetObjectPropertiesByName(deviceObject.Name).Range = new(-1000, 1000); - } -#elif false - // when https://github.com/amerkoleci/Vortice.Windows/issues/393 is fixed, this is what we should do - // cpp: this is fixed now, but updating to 3.x means bumping up to .net6+ - foreach (var deviceObject in joystick.GetObjects(DeviceObjectTypeFlags.Axis)) - { - joystick.GetObjectPropertiesById(deviceObject.ObjectId).Range = new(-1000, 1000); - } -#else - // hack due to the above problems - var dict = (Dictionary)typeof(IDirectInputDevice8) - .GetField("_mapNameToObjectFormat", BindingFlags.Instance | BindingFlags.NonPublic)! - .GetValue(joystick); - - foreach (var deviceObject in joystick.GetObjects(DeviceObjectTypeFlags.Axis)) - { - joystick.GetObjectPropertiesByName(dict.Values.First(odf => odf.Guid == deviceObject.ObjectType).Name!).Range = new(-1000, 1000); - } -#endif - joystick.Acquire(); - - var p = new DGamepad(joystick, Devices.Count); - Devices.Add(p); - } - } - } - - public static IEnumerable EnumerateDevices() - { - lock (SyncObj) - { - foreach (var device in Devices) - { - yield return device; - } - } - } - - public static void UpdateAll() - { - lock (SyncObj) - { - foreach (var device in Devices) - { - device.Update(); - } - } - } - - public static void Cleanup() - { - lock (SyncObj) - { - foreach (var device in Devices) - { - device._joystick.Dispose(); - } - - Devices.Clear(); - - if (_directInput != null) - { - _directInput.Dispose(); - _directInput = null; - } - } - } - - // ********************************** Instance Members ********************************** - - private readonly IDirectInputDevice8 _joystick; - private JoystickState _state = new(); - - private DGamepad(IDirectInputDevice8 joystick, int index) - { - _joystick = joystick; - PlayerNumber = index + 1; - InputNamePrefix = $"J{PlayerNumber} "; - Update(); - InitializeCallbacks(); - } - - public void Update() - { - try - { - if (_joystick.Acquire().Failure) - return; - } - catch - { - return; - } - - if (_joystick.Poll() - .Failure) - { - return; - } - - try - { - _joystick.GetCurrentJoystickState(ref _state); - } - catch (SharpGen.Runtime.SharpGenException) - { - // do something? - } - } - - private static readonly ImmutableArray _axesPropertyInfos = typeof(JoystickState).GetProperties().Where(pi => pi.PropertyType == typeof(int)).ToImmutableArray(); - - public IEnumerable<(string AxisID, float Value)> GetAxes() - { - return _axesPropertyInfos.Select(pi => (pi.Name, 10.0f * (int)pi.GetValue(_state))); - } - - /// FOR DEBUGGING ONLY - public JoystickState GetInternalState() - { - return _state; - } - - public int PlayerNumber { get; } - - public readonly string InputNamePrefix; - - public string ButtonName(int index) - { - return _names[index]; - } - - public bool Pressed(int index) - { - return _actions[index](); - } - - public int NumButtons { get; private set; } - - private readonly List _names = new(); - private readonly List> _actions = new(); - - private void AddItem(string name, Func callback) - { - _names.Add(name); - _actions.Add(callback); - NumButtons++; - } - - private void InitializeCallbacks() - { - const int dzp = 400; - const int dzn = -400; - - _names.Clear(); - _actions.Clear(); - NumButtons = 0; - - AddItem("AccelerationX+", () => _state.AccelerationX >= dzp); - AddItem("AccelerationX-", () => _state.AccelerationX <= dzn); - AddItem("AccelerationY+", () => _state.AccelerationY >= dzp); - AddItem("AccelerationY-", () => _state.AccelerationY <= dzn); - AddItem("AccelerationZ+", () => _state.AccelerationZ >= dzp); - AddItem("AccelerationZ-", () => _state.AccelerationZ <= dzn); - AddItem("AngularAccelerationX+", () => _state.AngularAccelerationX >= dzp); - AddItem("AngularAccelerationX-", () => _state.AngularAccelerationX <= dzn); - AddItem("AngularAccelerationY+", () => _state.AngularAccelerationY >= dzp); - AddItem("AngularAccelerationY-", () => _state.AngularAccelerationY <= dzn); - AddItem("AngularAccelerationZ+", () => _state.AngularAccelerationZ >= dzp); - AddItem("AngularAccelerationZ-", () => _state.AngularAccelerationZ <= dzn); - AddItem("AngularVelocityX+", () => _state.AngularVelocityX >= dzp); - AddItem("AngularVelocityX-", () => _state.AngularVelocityX <= dzn); - AddItem("AngularVelocityY+", () => _state.AngularVelocityY >= dzp); - AddItem("AngularVelocityY-", () => _state.AngularVelocityY <= dzn); - AddItem("AngularVelocityZ+", () => _state.AngularVelocityZ >= dzp); - AddItem("AngularVelocityZ-", () => _state.AngularVelocityZ <= dzn); - AddItem("ForceX+", () => _state.ForceX >= dzp); - AddItem("ForceX-", () => _state.ForceX <= dzn); - AddItem("ForceY+", () => _state.ForceY >= dzp); - AddItem("ForceY-", () => _state.ForceY <= dzn); - AddItem("ForceZ+", () => _state.ForceZ >= dzp); - AddItem("ForceZ-", () => _state.ForceZ <= dzn); - AddItem("RotationX+", () => _state.RotationX >= dzp); - AddItem("RotationX-", () => _state.RotationX <= dzn); - AddItem("RotationY+", () => _state.RotationY >= dzp); - AddItem("RotationY-", () => _state.RotationY <= dzn); - AddItem("RotationZ+", () => _state.RotationZ >= dzp); - AddItem("RotationZ-", () => _state.RotationZ <= dzn); - AddItem("TorqueX+", () => _state.TorqueX >= dzp); - AddItem("TorqueX-", () => _state.TorqueX <= dzn); - AddItem("TorqueY+", () => _state.TorqueY >= dzp); - AddItem("TorqueY-", () => _state.TorqueY <= dzn); - AddItem("TorqueZ+", () => _state.TorqueZ >= dzp); - AddItem("TorqueZ-", () => _state.TorqueZ <= dzn); - AddItem("VelocityX+", () => _state.VelocityX >= dzp); - AddItem("VelocityX-", () => _state.VelocityX <= dzn); - AddItem("VelocityY+", () => _state.VelocityY >= dzp); - AddItem("VelocityY-", () => _state.VelocityY <= dzn); - AddItem("VelocityZ+", () => _state.VelocityZ >= dzp); - AddItem("VelocityZ-", () => _state.VelocityZ <= dzn); - AddItem("X+", () => _state.X >= dzp); - AddItem("X-", () => _state.X <= dzn); - AddItem("Y+", () => _state.Y >= dzp); - AddItem("Y-", () => _state.Y <= dzn); - AddItem("Z+", () => _state.Z >= dzp); - AddItem("Z-", () => _state.Z <= dzn); - - // i don't know what the "Slider"s do, so they're omitted for the moment - - for (var i = 0; i < _state.Buttons.Length; i++) - { - var j = i; - AddItem($"B{i + 1}", () => _state.Buttons[j]); - } - - for (var i = 0; i < _state.PointOfViewControllers.Length; i++) - { - var j = i; - AddItem($"POV{i + 1}U", () => { - var t = _state.PointOfViewControllers[j]; - return 0.RangeTo(4500).Contains(t) || 31500.RangeToExclusive(36000).Contains(t); - }); - AddItem($"POV{i + 1}D", () => 13500.RangeTo(22500).Contains(_state.PointOfViewControllers[j])); - AddItem($"POV{i + 1}L", () => 22500.RangeTo(31500).Contains(_state.PointOfViewControllers[j])); - AddItem($"POV{i + 1}R", () => 4500.RangeTo(13500).Contains(_state.PointOfViewControllers[j])); - } - } - - // Note that this does not appear to work at this time. I probably need to have more infos. - public void SetVibration(int left, int right) - { - // my first clue that it doesn't work is that LEFT and RIGHT _AREN'T USED_ - // I should just look for C++ examples instead of trying to look for SlimDX examples - - var parameters = new EffectParameters - { - Duration = 0x2710, - Gain = 0x2710, - SamplePeriod = 0, - TriggerButton = 0, - TriggerRepeatInterval = 0x2710, - Flags = EffectFlags.None - }; - parameters.GetAxes(out var temp1, out var temp2); - parameters.SetAxes(temp1, temp2); - var effect = _joystick.CreateEffect(EffectGuid.ConstantForce, parameters); - effect.Start(1); - } - } -} \ No newline at end of file diff --git a/src/BizHawk.Bizware.Input/DirectX/DKeyInput.cs b/src/BizHawk.Bizware.Input/DirectX/DKeyInput.cs deleted file mode 100644 index 59f07dcaf9..0000000000 --- a/src/BizHawk.Bizware.Input/DirectX/DKeyInput.cs +++ /dev/null @@ -1,377 +0,0 @@ -#nullable enable - -using System; -using System.Collections.Generic; -using System.Linq; - -using BizHawk.Client.Common; -using BizHawk.Common.CollectionExtensions; - -using Vortice.DirectInput; - -using static BizHawk.Common.RawInputImports; - -using DInputKey = Vortice.DirectInput.Key; - -namespace BizHawk.Bizware.Input -{ - internal static class DKeyInput - { - private static IDirectInput8? _directInput; - - private static IDirectInputDevice8? _keyboard; - - private static readonly object _lockObj = new(); - - public static void Initialize(IntPtr mainFormHandle) - { - lock (_lockObj) - { - Cleanup(); - - _directInput = DInput.DirectInput8Create(); - - _keyboard = _directInput.CreateDevice(PredefinedDevice.SysKeyboard); - _keyboard.SetCooperativeLevel(mainFormHandle, CooperativeLevel.Background | CooperativeLevel.NonExclusive); - _keyboard.SetDataFormat(); - _keyboard.Properties.BufferSize = 8; - } - } - - public static void Cleanup() - { - lock (_lockObj) - { - _keyboard?.Dispose(); - _keyboard = null; - _directInput?.Dispose(); - _directInput = null; - } - } - - public static IEnumerable Update(Config config) - { - DistinctKey Mapped(DInputKey k) - => KeyEnumMap[config.HandleAlternateKeyboardLayouts ? MapToRealKeyViaScanCode(k) : k]; - - lock (_lockObj) - { - if (_keyboard is null || _keyboard.Acquire().Failure || _keyboard.Poll().Failure) - { - return Enumerable.Empty(); - } - - var eventList = new List(); - while (true) - { - try - { - var events = _keyboard.GetBufferedKeyboardData(); - if (events.Length == 0) - { - return eventList; - } - - eventList.AddRange(events - .Select(e => new KeyEvent(Mapped(e.Key), e.IsPressed)) - .Where(ke => ke.Key != DistinctKey.Unknown)); - } - catch (SharpGen.Runtime.SharpGenException) - { - return eventList; - } - } - } - } - - private static DInputKey MapToRealKeyViaScanCode(DInputKey key) - { - const uint MAPVK_VSC_TO_VK_EX = 0x03; - // DInputKey is a scancode with bit 7 indicating an E0 prefix - var scanCode = (uint)key; - if ((scanCode & 0x80) != 0) - { - // exception for the Pause key (which uses an E1 prefix rather with 1D) - if (key == DInputKey.Pause) - { - scanCode = 0xE11D; - } - else - { - scanCode &= 0x7F; - scanCode |= 0xE000; - } - } - - var virtualKey = MapVirtualKeyW(scanCode, MAPVK_VSC_TO_VK_EX); - return VKeyToDKeyMap.GetValueOrDefault(virtualKey, DInputKey.Unknown); - } - - private static readonly IReadOnlyDictionary KeyEnumMap = new Dictionary - { - [DInputKey.D0] = DistinctKey.D0, - [DInputKey.D1] = DistinctKey.D1, - [DInputKey.D2] = DistinctKey.D2, - [DInputKey.D3] = DistinctKey.D3, - [DInputKey.D4] = DistinctKey.D4, - [DInputKey.D5] = DistinctKey.D5, - [DInputKey.D6] = DistinctKey.D6, - [DInputKey.D7] = DistinctKey.D7, - [DInputKey.D8] = DistinctKey.D8, - [DInputKey.D9] = DistinctKey.D9, - [DInputKey.A] = DistinctKey.A, - [DInputKey.B] = DistinctKey.B, - [DInputKey.C] = DistinctKey.C, - [DInputKey.D] = DistinctKey.D, - [DInputKey.E] = DistinctKey.E, - [DInputKey.F] = DistinctKey.F, - [DInputKey.G] = DistinctKey.G, - [DInputKey.H] = DistinctKey.H, - [DInputKey.I] = DistinctKey.I, - [DInputKey.J] = DistinctKey.J, - [DInputKey.K] = DistinctKey.K, - [DInputKey.L] = DistinctKey.L, - [DInputKey.M] = DistinctKey.M, - [DInputKey.N] = DistinctKey.N, - [DInputKey.O] = DistinctKey.O, - [DInputKey.P] = DistinctKey.P, - [DInputKey.Q] = DistinctKey.Q, - [DInputKey.R] = DistinctKey.R, - [DInputKey.S] = DistinctKey.S, - [DInputKey.T] = DistinctKey.T, - [DInputKey.U] = DistinctKey.U, - [DInputKey.V] = DistinctKey.V, - [DInputKey.W] = DistinctKey.W, - [DInputKey.X] = DistinctKey.X, - [DInputKey.Y] = DistinctKey.Y, - [DInputKey.Z] = DistinctKey.Z, - [DInputKey.AbntC1] = DistinctKey.AbntC1, - [DInputKey.AbntC2] = DistinctKey.AbntC2, - [DInputKey.Apostrophe] = DistinctKey.OemQuotes, - [DInputKey.Applications] = DistinctKey.Apps, - [DInputKey.AT] = DistinctKey.Unknown, - [DInputKey.AX] = DistinctKey.Unknown, - [DInputKey.Back] = DistinctKey.Back, - [DInputKey.Backslash] = DistinctKey.OemPipe, - [DInputKey.Calculator] = DistinctKey.Unknown, - [DInputKey.CapsLock] = DistinctKey.CapsLock, - [DInputKey.Colon] = DistinctKey.Unknown, - [DInputKey.Comma] = DistinctKey.OemComma, - [DInputKey.Convert] = DistinctKey.ImeConvert, - [DInputKey.Delete] = DistinctKey.Delete, - [DInputKey.Down] = DistinctKey.Down, - [DInputKey.End] = DistinctKey.End, - [DInputKey.Equals] = DistinctKey.OemPlus, - [DInputKey.Escape] = DistinctKey.Escape, - [DInputKey.F1] = DistinctKey.F1, - [DInputKey.F2] = DistinctKey.F2, - [DInputKey.F3] = DistinctKey.F3, - [DInputKey.F4] = DistinctKey.F4, - [DInputKey.F5] = DistinctKey.F5, - [DInputKey.F6] = DistinctKey.F6, - [DInputKey.F7] = DistinctKey.F7, - [DInputKey.F8] = DistinctKey.F8, - [DInputKey.F9] = DistinctKey.F9, - [DInputKey.F10] = DistinctKey.F10, - [DInputKey.F11] = DistinctKey.F11, - [DInputKey.F12] = DistinctKey.F12, - [DInputKey.F13] = DistinctKey.F13, - [DInputKey.F14] = DistinctKey.F14, - [DInputKey.F15] = DistinctKey.F15, - [DInputKey.Grave] = DistinctKey.OemTilde, - [DInputKey.Home] = DistinctKey.Home, - [DInputKey.Insert] = DistinctKey.Insert, - [DInputKey.Kana] = DistinctKey.KanaMode, - [DInputKey.Kanji] = DistinctKey.KanjiMode, - [DInputKey.LeftBracket] = DistinctKey.OemOpenBrackets, - [DInputKey.LeftControl] = DistinctKey.LeftCtrl, - [DInputKey.Left] = DistinctKey.Left, - [DInputKey.LeftAlt] = DistinctKey.LeftAlt, - [DInputKey.LeftShift] = DistinctKey.LeftShift, - [DInputKey.LeftWindowsKey] = DistinctKey.LWin, - [DInputKey.Mail] = DistinctKey.LaunchMail, - [DInputKey.MediaSelect] = DistinctKey.SelectMedia, - [DInputKey.MediaStop] = DistinctKey.MediaStop, - [DInputKey.Minus] = DistinctKey.OemMinus, - [DInputKey.Mute] = DistinctKey.VolumeMute, - [DInputKey.MyComputer] = DistinctKey.Unknown, - [DInputKey.NextTrack] = DistinctKey.MediaNextTrack, - [DInputKey.NoConvert] = DistinctKey.ImeNonConvert, - [DInputKey.NumberLock] = DistinctKey.NumLock, - [DInputKey.NumberPad0] = DistinctKey.NumPad0, - [DInputKey.NumberPad1] = DistinctKey.NumPad1, - [DInputKey.NumberPad2] = DistinctKey.NumPad2, - [DInputKey.NumberPad3] = DistinctKey.NumPad3, - [DInputKey.NumberPad4] = DistinctKey.NumPad4, - [DInputKey.NumberPad5] = DistinctKey.NumPad5, - [DInputKey.NumberPad6] = DistinctKey.NumPad6, - [DInputKey.NumberPad7] = DistinctKey.NumPad7, - [DInputKey.NumberPad8] = DistinctKey.NumPad8, - [DInputKey.NumberPad9] = DistinctKey.NumPad9, - [DInputKey.NumberPadComma] = DistinctKey.Separator, - [DInputKey.NumberPadEnter] = DistinctKey.NumPadEnter, - [DInputKey.NumberPadEquals] = DistinctKey.OemPlus, - [DInputKey.Subtract] = DistinctKey.Subtract, - [DInputKey.Decimal] = DistinctKey.Decimal, - [DInputKey.Add] = DistinctKey.Add, - [DInputKey.Divide] = DistinctKey.Divide, - [DInputKey.Multiply] = DistinctKey.Multiply, - [DInputKey.Oem102] = DistinctKey.OemBackslash, - [DInputKey.PageDown] = DistinctKey.PageDown, - [DInputKey.PageUp] = DistinctKey.PageUp, - [DInputKey.Pause] = DistinctKey.Pause, - [DInputKey.Period] = DistinctKey.OemPeriod, - [DInputKey.PlayPause] = DistinctKey.MediaPlayPause, - [DInputKey.Power] = DistinctKey.Unknown, - [DInputKey.PreviousTrack] = DistinctKey.MediaPreviousTrack, - [DInputKey.RightBracket] = DistinctKey.OemCloseBrackets, - [DInputKey.RightControl] = DistinctKey.RightCtrl, - [DInputKey.Return] = DistinctKey.Return, - [DInputKey.Right] = DistinctKey.Right, - [DInputKey.RightAlt] = DistinctKey.RightAlt, - [DInputKey.RightShift] = DistinctKey.RightShift, - [DInputKey.RightWindowsKey] = DistinctKey.RWin, - [DInputKey.ScrollLock] = DistinctKey.Scroll, - [DInputKey.Semicolon] = DistinctKey.OemSemicolon, - [DInputKey.Slash] = DistinctKey.OemQuestion, - [DInputKey.Sleep] = DistinctKey.Sleep, - [DInputKey.Space] = DistinctKey.Space, - [DInputKey.Stop] = DistinctKey.MediaStop, - [DInputKey.PrintScreen] = DistinctKey.PrintScreen, - [DInputKey.Tab] = DistinctKey.Tab, - [DInputKey.Underline] = DistinctKey.Unknown, - [DInputKey.Unlabeled] = DistinctKey.Unknown, - [DInputKey.Up] = DistinctKey.Up, - [DInputKey.VolumeDown] = DistinctKey.VolumeDown, - [DInputKey.VolumeUp] = DistinctKey.VolumeUp, - [DInputKey.Wake] = DistinctKey.Sleep, - [DInputKey.WebBack] = DistinctKey.BrowserBack, - [DInputKey.WebFavorites] = DistinctKey.BrowserFavorites, - [DInputKey.WebForward] = DistinctKey.BrowserForward, - [DInputKey.WebHome] = DistinctKey.BrowserHome, - [DInputKey.WebRefresh] = DistinctKey.BrowserRefresh, - [DInputKey.WebSearch] = DistinctKey.BrowserSearch, - [DInputKey.WebStop] = DistinctKey.BrowserStop, - [DInputKey.Yen] = DistinctKey.Unknown, - [DInputKey.Unknown] = DistinctKey.Unknown - }; - - private static readonly IReadOnlyDictionary VKeyToDKeyMap = new Dictionary - { - [0x30] = DInputKey.D0, - [0x31] = DInputKey.D1, - [0x32] = DInputKey.D2, - [0x33] = DInputKey.D3, - [0x34] = DInputKey.D4, - [0x35] = DInputKey.D5, - [0x36] = DInputKey.D6, - [0x37] = DInputKey.D7, - [0x38] = DInputKey.D8, - [0x39] = DInputKey.D9, - [0x41] = DInputKey.A, - [0x42] = DInputKey.B, - [0x43] = DInputKey.C, - [0x44] = DInputKey.D, - [0x45] = DInputKey.E, - [0x46] = DInputKey.F, - [0x47] = DInputKey.G, - [0x48] = DInputKey.H, - [0x49] = DInputKey.I, - [0x4A] = DInputKey.J, - [0x4B] = DInputKey.K, - [0x4C] = DInputKey.L, - [0x4D] = DInputKey.M, - [0x4E] = DInputKey.N, - [0x4F] = DInputKey.O, - [0x50] = DInputKey.P, - [0x51] = DInputKey.Q, - [0x52] = DInputKey.R, - [0x53] = DInputKey.S, - [0x54] = DInputKey.T, - [0x55] = DInputKey.U, - [0x56] = DInputKey.V, - [0x57] = DInputKey.W, - [0x58] = DInputKey.X, - [0x59] = DInputKey.Y, - [0x5A] = DInputKey.Z, - [0xDE] = DInputKey.Apostrophe, - [0x5D] = DInputKey.Applications, - [0x08] = DInputKey.Back, - [0xDC] = DInputKey.Backslash, - [0x14] = DInputKey.CapsLock, - [0xBC] = DInputKey.Comma, - [0x1C] = DInputKey.Convert, - [0x2E] = DInputKey.Delete, - [0x28] = DInputKey.Down, - [0x23] = DInputKey.End, - [0xBB] = DInputKey.Equals, - [0x1B] = DInputKey.Escape, - [0x70] = DInputKey.F1, - [0x71] = DInputKey.F2, - [0x72] = DInputKey.F3, - [0x73] = DInputKey.F4, - [0x74] = DInputKey.F5, - [0x75] = DInputKey.F6, - [0x76] = DInputKey.F7, - [0x77] = DInputKey.F8, - [0x78] = DInputKey.F9, - [0x79] = DInputKey.F10, - [0x7A] = DInputKey.F11, - [0x7B] = DInputKey.F12, - [0x7C] = DInputKey.F13, - [0x7D] = DInputKey.F14, - [0x7E] = DInputKey.F15, - [0xC0] = DInputKey.Grave, - [0x24] = DInputKey.Home, - [0x2D] = DInputKey.Insert, - [0xDB] = DInputKey.LeftBracket, - [0xA2] = DInputKey.LeftControl, - [0x25] = DInputKey.Left, - [0xA4] = DInputKey.LeftAlt, - [0xA0] = DInputKey.LeftShift, - [0x5B] = DInputKey.LeftWindowsKey, - [0xB4] = DInputKey.Mail, - [0xB5] = DInputKey.MediaSelect, - [0xB2] = DInputKey.MediaStop, - [0xBD] = DInputKey.Minus, - [0xAD] = DInputKey.Mute, - [0xB0] = DInputKey.NextTrack, - [0x90] = DInputKey.NumberLock, - [0x6D] = DInputKey.Subtract, - [0x6B] = DInputKey.Add, - [0x6F] = DInputKey.Divide, - [0x6A] = DInputKey.Multiply, - [0xE2] = DInputKey.Oem102, - [0x22] = DInputKey.PageDown, - [0x21] = DInputKey.PageUp, - [0x13] = DInputKey.Pause, - [0xBE] = DInputKey.Period, - [0xB3] = DInputKey.PlayPause, - [0xB1] = DInputKey.PreviousTrack, - [0xDD] = DInputKey.RightBracket, - [0xA3] = DInputKey.RightControl, - [0x0D] = DInputKey.Return, - [0x27] = DInputKey.Right, - [0xA5] = DInputKey.RightAlt, - [0xA1] = DInputKey.RightShift, - [0x5C] = DInputKey.RightWindowsKey, - [0x91] = DInputKey.ScrollLock, - [0xBA] = DInputKey.Semicolon, - [0xBF] = DInputKey.Slash, - [0x5F] = DInputKey.Sleep, - [0x20] = DInputKey.Space, - [0x2C] = DInputKey.PrintScreen, - [0x09] = DInputKey.Tab, - [0x26] = DInputKey.Up, - [0xAE] = DInputKey.VolumeDown, - [0xAF] = DInputKey.VolumeUp, - [0xA6] = DInputKey.WebBack, - [0xAB] = DInputKey.WebFavorites, - [0xA7] = DInputKey.WebForward, - [0xAC] = DInputKey.WebHome, - [0xA8] = DInputKey.WebRefresh, - [0xAA] = DInputKey.WebSearch, - [0xA9] = DInputKey.WebStop, - }; - } -} diff --git a/src/BizHawk.Bizware.Input/DirectX/DirectInputAdapter.cs b/src/BizHawk.Bizware.Input/DirectX/DirectInputAdapter.cs deleted file mode 100644 index 3a836f34a6..0000000000 --- a/src/BizHawk.Bizware.Input/DirectX/DirectInputAdapter.cs +++ /dev/null @@ -1,77 +0,0 @@ -#nullable enable - -using System; -using System.Collections.Generic; -using System.Linq; - -using BizHawk.Client.Common; -using BizHawk.Common.CollectionExtensions; - -namespace BizHawk.Bizware.Input -{ - public sealed class DirectInputAdapter : IHostInputAdapter - { - private static readonly IReadOnlyCollection XINPUT_HAPTIC_CHANNEL_NAMES = new[] { "Left", "Right" }; // doesn't seem to be a way to detect this via XInput, so assuming x360/xbone will be good enough - - private IReadOnlyDictionary _lastHapticsSnapshot = new Dictionary(); - - private Config? _config; - - public string Desc => "DirectInput+XInput"; - - public void DeInitAll() - { - DKeyInput.Cleanup(); - DGamepad.Cleanup(); - } - - public void FirstInitAll(IntPtr mainFormHandle) - { - DKeyInput.Initialize(mainFormHandle); - IPCKeyInput.Initialize(); - ReInitGamepads(mainFormHandle); - } - - public IReadOnlyDictionary> GetHapticsChannels() - => XGamepad.EnumerateDevices().ToDictionary(pad => pad.InputNamePrefix, _ => XINPUT_HAPTIC_CHANNEL_NAMES); - - public void ReInitGamepads(IntPtr mainFormHandle) - { - DGamepad.Initialize(mainFormHandle); - XGamepad.Initialize(); - } - - public void PreprocessHostGamepads() - { - DGamepad.UpdateAll(); - XGamepad.UpdateAll(); - } - - public void ProcessHostGamepads(Action handleButton, Action handleAxis) - { - foreach (var pad in XGamepad.EnumerateDevices()) - { - if (!pad.IsConnected) - continue; - for (int b = 0, n = pad.NumButtons; b < n; b++) handleButton(pad.InputNamePrefix + pad.ButtonName(b), pad.Pressed(b), ClientInputFocus.Pad); - foreach (var (axisName, f) in pad.GetAxes()) handleAxis(pad.InputNamePrefix + axisName, (int) f); - var leftStrength = _lastHapticsSnapshot.GetValueOrDefault(pad.InputNamePrefix + "Left"); - var rightStrength = _lastHapticsSnapshot.GetValueOrDefault(pad.InputNamePrefix + "Right"); - pad.SetVibration(leftStrength, rightStrength); // values will be 0 if not found - } - foreach (var pad in DGamepad.EnumerateDevices()) - { - for (int b = 0, n = pad.NumButtons; b < n; b++) handleButton(pad.InputNamePrefix + pad.ButtonName(b), pad.Pressed(b), ClientInputFocus.Pad); - foreach (var (axisName, f) in pad.GetAxes()) handleAxis(pad.InputNamePrefix + axisName, (int) f); - } - } - - public IEnumerable ProcessHostKeyboards() => DKeyInput.Update(_config ?? throw new(nameof(ProcessHostKeyboards) + " called before the global config was passed")) - .Concat(IPCKeyInput.Update()); - - public void SetHaptics(IReadOnlyCollection<(string Name, int Strength)> hapticsSnapshot) - => _lastHapticsSnapshot = hapticsSnapshot.ToDictionary(tuple => tuple.Name, tuple => tuple.Strength); - - public void UpdateConfig(Config config) => _config = config; - } -} diff --git a/src/BizHawk.Bizware.Input/DirectX/XGamepad.cs b/src/BizHawk.Bizware.Input/DirectX/XGamepad.cs deleted file mode 100644 index 2e982eac3b..0000000000 --- a/src/BizHawk.Bizware.Input/DirectX/XGamepad.cs +++ /dev/null @@ -1,220 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; - -using BizHawk.Common; - -using Vortice.XInput; - -namespace BizHawk.Bizware.Input -{ - internal sealed class XGamepad - { - // ********************************** Static interface ********************************** - - private static readonly object SyncObj = new(); - private static readonly List Devices = new(); - private static readonly bool IsAvailable; - - // Vortice has some support for the unofficial API, but it has some issues - // (e.g. the check for AllowUnofficialAPI is in static ctor (???), uses it regardless of it being available) - // We'll just get the proc ourselves and use it - [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate uint XInputGetStateExProcDelegate(int dwUserIndex, out State state); - - private static readonly XInputGetStateExProcDelegate XInputGetStateExProc; - - static XGamepad() - { - try - { - // some users won't even have xinput installed. in order to avoid spurious exceptions and possible instability, check for the library first - IsAvailable = XInput.Version != XInputVersion.Invalid; - if (IsAvailable) - { - var libHandle = XInput.Version switch - { - XInputVersion.Version14 => LoaderApiImports.GetModuleHandleW("xinput1_4.dll"), - XInputVersion.Version13 => LoaderApiImports.GetModuleHandleW("xinput1_3.dll"), - _ => IntPtr.Zero // unofficial API isn't available for 9.1.0 - }; - - if (libHandle != IntPtr.Zero) - { - var fptr = LoaderApiImports.GetProcAddress(libHandle, new IntPtr(100)); - if (fptr != IntPtr.Zero) - { - XInputGetStateExProc = - Marshal.GetDelegateForFunctionPointer(fptr); - } - } - - // don't remove this code. it's important to catch errors on systems with broken xinput installs. - _ = XInputGetStateExProc?.Invoke(0, out _); - _ = XInput.GetState(0, out _); - } - } - catch - { - IsAvailable = false; - } - } - - public static void Initialize() - { - lock (SyncObj) - { - Devices.Clear(); - - if (!IsAvailable) - return; - - if (XInput.GetState(0, out _)) Devices.Add(new(0)); - if (XInput.GetState(1, out _)) Devices.Add(new(1)); - if (XInput.GetState(2, out _)) Devices.Add(new(2)); - if (XInput.GetState(3, out _)) Devices.Add(new(3)); - } - } - - public static IEnumerable EnumerateDevices() - { - lock (SyncObj) - { - foreach (var device in Devices) - { - yield return device; - } - } - } - - public static void UpdateAll() - { - lock (SyncObj) - { - foreach (var device in Devices) - { - device.Update(); - } - } - } - - // ********************************** Instance Members ********************************** - - private readonly int _index0; - private State _state; - - public int PlayerNumber => _index0 + 1; - public bool IsConnected => XInput.GetState(_index0, out _); - public readonly string InputNamePrefix; - - private XGamepad(int index0) - { - _index0 = index0; - InputNamePrefix = $"X{PlayerNumber} "; - InitializeButtons(); - Update(); - } - - public void Update() - { - if (!IsConnected) - return; - - _state = default; - if (XInputGetStateExProc is not null) - { - XInputGetStateExProc(_index0, out _state); - } - else - { - XInput.GetState(_index0, out _state); - } - } - - public IEnumerable<(string AxisID, float Value)> GetAxes() - { - var g = _state.Gamepad; - - //constant for adapting a +/- 32768 range to a +/-10000-based range - const float f = 32768 / 10000.0f; - - //since our whole input framework really only understands whole axes, let's make the triggers look like an axis - var lTrig = g.LeftTrigger / 255.0f * 2 - 1; - var rTrig = g.RightTrigger / 255.0f * 2 - 1; - lTrig *= 10000; - rTrig *= 10000; - - yield return ("LeftThumbX", g.LeftThumbX / f); - yield return ("LeftThumbY", g.LeftThumbY / f); - yield return ("RightThumbX", g.RightThumbX / f); - yield return ("RightThumbY", g.RightThumbY / f); - yield return ("LeftTrigger", lTrig); - yield return ("RightTrigger", rTrig); - } - - public int NumButtons { get; private set; } - - private readonly List _names = new(); - private readonly List> _actions = new(); - - private void InitializeButtons() - { - const int dzp = 20000; - const int dzn = -20000; - const int dzt = 40; - - AddItem("A", () => (_state.Gamepad.Buttons & GamepadButtons.A) != 0); - AddItem("B", () => (_state.Gamepad.Buttons & GamepadButtons.B) != 0); - AddItem("X", () => (_state.Gamepad.Buttons & GamepadButtons.X) != 0); - AddItem("Y", () => (_state.Gamepad.Buttons & GamepadButtons.Y) != 0); - AddItem("Guide", () => (_state.Gamepad.Buttons & GamepadButtons.Guide) != 0); - - AddItem("Start", () => (_state.Gamepad.Buttons & GamepadButtons.Start) != 0); - AddItem("Back", () => (_state.Gamepad.Buttons & GamepadButtons.Back) != 0); - AddItem("LeftThumb", () => (_state.Gamepad.Buttons & GamepadButtons.LeftThumb) != 0); - AddItem("RightThumb", () => (_state.Gamepad.Buttons & GamepadButtons.RightThumb) != 0); - AddItem("LeftShoulder", () => (_state.Gamepad.Buttons & GamepadButtons.LeftShoulder) != 0); - AddItem("RightShoulder", () => (_state.Gamepad.Buttons & GamepadButtons.RightShoulder) != 0); - - AddItem("DpadUp", () => (_state.Gamepad.Buttons & GamepadButtons.DPadUp) != 0); - AddItem("DpadDown", () => (_state.Gamepad.Buttons & GamepadButtons.DPadDown) != 0); - AddItem("DpadLeft", () => (_state.Gamepad.Buttons & GamepadButtons.DPadLeft) != 0); - AddItem("DpadRight", () => (_state.Gamepad.Buttons & GamepadButtons.DPadRight) != 0); - - AddItem("LStickUp", () => _state.Gamepad.LeftThumbY >= dzp); - AddItem("LStickDown", () => _state.Gamepad.LeftThumbY <= dzn); - AddItem("LStickLeft", () => _state.Gamepad.LeftThumbX <= dzn); - AddItem("LStickRight", () => _state.Gamepad.LeftThumbX >= dzp); - - AddItem("RStickUp", () => _state.Gamepad.RightThumbY >= dzp); - AddItem("RStickDown", () => _state.Gamepad.RightThumbY <= dzn); - AddItem("RStickLeft", () => _state.Gamepad.RightThumbX <= dzn); - AddItem("RStickRight", () => _state.Gamepad.RightThumbX >= dzp); - - AddItem("LeftTrigger", () => _state.Gamepad.LeftTrigger > dzt); - AddItem("RightTrigger", () => _state.Gamepad.RightTrigger > dzt); - } - - private void AddItem(string name, Func pressed) - { - _names.Add(name); - _actions.Add(pressed); - NumButtons++; - } - - public string ButtonName(int index) => _names[index]; - - public bool Pressed(int index) => _actions[index](); - - /// and are in 0.. - public void SetVibration(int left, int right) - { - static ushort Conv(int i) => unchecked((ushort) ((i >> 15) & 0xFFFF)); - - if (!XInput.SetVibration(_index0, new(Conv(left), Conv(right)))) - { - // Ignored, most likely the controller disconnected - } - } - } -} diff --git a/src/BizHawk.Bizware.Input/KeyInput/RawKeyInput.cs b/src/BizHawk.Bizware.Input/KeyInput/RawKeyInput.cs index e5b651e4ed..02821ce039 100644 --- a/src/BizHawk.Bizware.Input/KeyInput/RawKeyInput.cs +++ b/src/BizHawk.Bizware.Input/KeyInput/RawKeyInput.cs @@ -209,11 +209,35 @@ namespace BizHawk.Bizware.Input } } + private static readonly RawKey[] _rawKeysNoTranslation = + { + RawKey.NUMPAD0, + RawKey.NUMPAD1, + RawKey.NUMPAD2, + RawKey.NUMPAD3, + RawKey.NUMPAD4, + RawKey.NUMPAD5, + RawKey.NUMPAD6, + RawKey.NUMPAD7, + RawKey.NUMPAD8, + RawKey.NUMPAD9, + RawKey.DECIMAL, + RawKey.NUMPADENTER, + RawKey.PAUSE, + RawKey.POWER, + RawKey.WAKE, + RawKey.INTL2, + RawKey.INTL3, + RawKey.INTL4, + RawKey.LANG3, + RawKey.LANG4 + }; + private static RawKey MapToRealKeyViaScanCode(RawKey key) { - // Numpad Enter just gets mapped to the virtual Enter key - // Pause is special as it uses 0xE11D technically - if (key is RawKey.NUMPADENTER or RawKey.PAUSE) + // Some keys are special and don't have a proper translation + // for these keys just passthrough to our normal handling + if (Array.IndexOf(_rawKeysNoTranslation, key) != -1) { return key; } diff --git a/src/BizHawk.Client.Common/config/Config.cs b/src/BizHawk.Client.Common/config/Config.cs index 70743b285b..0589440f49 100644 --- a/src/BizHawk.Client.Common/config/Config.cs +++ b/src/BizHawk.Client.Common/config/Config.cs @@ -393,8 +393,6 @@ namespace BizHawk.Client.Common // ReSharper disable once UnusedMember.Global public string LastWrittenFromDetailed { get; set; } = VersionInfo.GetEmuVersion(); - public EHostInputMethod HostInputMethod { get; set; } = HostCapabilityDetector.HasDirectX ? EHostInputMethod.DirectInput : EHostInputMethod.SDL2; - public bool UseStaticWindowTitles { get; set; } public List ModifierKeys { get; set; } = new(); diff --git a/src/BizHawk.Client.Common/config/ConfigEnums.cs b/src/BizHawk.Client.Common/config/ConfigEnums.cs index d46bbfe1d5..efe3d9aa1e 100644 --- a/src/BizHawk.Client.Common/config/ConfigEnums.cs +++ b/src/BizHawk.Client.Common/config/ConfigEnums.cs @@ -27,12 +27,6 @@ N64Tas = 4 } - public enum EHostInputMethod - { - SDL2 = 0, - DirectInput = 1 - } - public enum OpposingDirPolicy { Priority = 0, diff --git a/src/BizHawk.Client.EmuHawk/Input/Input.cs b/src/BizHawk.Client.EmuHawk/Input/Input.cs index 0026130f5f..223fd1eaf4 100644 --- a/src/BizHawk.Client.EmuHawk/Input/Input.cs +++ b/src/BizHawk.Client.EmuHawk/Input/Input.cs @@ -45,13 +45,7 @@ namespace BizHawk.Client.EmuHawk MainFormInputAllowedCallback = mainFormInputAllowedCallback; - Adapter = _currentConfig.HostInputMethod switch - { - EHostInputMethod.SDL2 => new SDL2InputAdapter(), - _ when OSTailoredCode.IsUnixHost => new SDL2InputAdapter(), - EHostInputMethod.DirectInput => new DirectInputAdapter(), - _ => throw new InvalidOperationException() - }; + Adapter = new SDL2InputAdapter(); Console.WriteLine($"Using {Adapter.Desc} for host input (keyboard + gamepads)"); Adapter.UpdateConfig(_currentConfig); Adapter.FirstInitAll(mainFormHandle); diff --git a/src/BizHawk.Client.EmuHawk/config/EmuHawkOptions.Designer.cs b/src/BizHawk.Client.EmuHawk/config/EmuHawkOptions.Designer.cs index e2f383d3f1..e528e2fd30 100755 --- a/src/BizHawk.Client.EmuHawk/config/EmuHawkOptions.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/config/EmuHawkOptions.Designer.cs @@ -33,6 +33,7 @@ this.CancelBtn = new System.Windows.Forms.Button(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); + this.cbMergeLAndRModifierKeys = new System.Windows.Forms.CheckBox(); this.HandleAlternateKeyboardLayoutsCheckBox = new System.Windows.Forms.CheckBox(); this.NeverAskSaveCheckbox = new System.Windows.Forms.CheckBox(); this.label2 = new BizHawk.WinForms.Controls.LocLabelEx(); @@ -42,10 +43,8 @@ this.RunInBackgroundCheckbox = new System.Windows.Forms.CheckBox(); this.EnableContextMenuCheckbox = new System.Windows.Forms.CheckBox(); this.PauseWhenMenuActivatedCheckbox = new System.Windows.Forms.CheckBox(); - this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.rbInputMethodSDL2 = new System.Windows.Forms.RadioButton(); - this.rbInputMethodDirectInput = new System.Windows.Forms.RadioButton(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.locLabelEx1 = new BizHawk.WinForms.Controls.LocLabelEx(); this.StartPausedCheckbox = new System.Windows.Forms.CheckBox(); this.label14 = new BizHawk.WinForms.Controls.LocLabelEx(); this.StartFullScreenCheckbox = new System.Windows.Forms.CheckBox(); @@ -72,11 +71,8 @@ this.FrameAdvSkipLagCheckbox = new System.Windows.Forms.CheckBox(); this.BackupSRamCheckbox = new System.Windows.Forms.CheckBox(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.locLabelEx1 = new BizHawk.WinForms.Controls.LocLabelEx(); - this.cbMergeLAndRModifierKeys = new System.Windows.Forms.CheckBox(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); - this.groupBox3.SuspendLayout(); this.groupBox1.SuspendLayout(); this.tabPage3.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -86,7 +82,7 @@ // OkBtn // this.OkBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.OkBtn.Location = new System.Drawing.Point(280, 440); + this.OkBtn.Location = new System.Drawing.Point(280, 371); this.OkBtn.Name = "OkBtn"; this.OkBtn.Size = new System.Drawing.Size(60, 23); this.OkBtn.TabIndex = 0; @@ -98,7 +94,7 @@ // this.CancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CancelBtn.Location = new System.Drawing.Point(346, 440); + this.CancelBtn.Location = new System.Drawing.Point(346, 371); this.CancelBtn.Name = "CancelBtn"; this.CancelBtn.Size = new System.Drawing.Size(60, 23); this.CancelBtn.TabIndex = 1; @@ -108,15 +104,13 @@ // // tabControl1 // - this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage3); this.tabControl1.Location = new System.Drawing.Point(12, 12); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(394, 417); + this.tabControl1.Size = new System.Drawing.Size(394, 348); this.tabControl1.TabIndex = 2; // // tabPage1 @@ -131,16 +125,25 @@ this.tabPage1.Controls.Add(this.RunInBackgroundCheckbox); this.tabPage1.Controls.Add(this.EnableContextMenuCheckbox); this.tabPage1.Controls.Add(this.PauseWhenMenuActivatedCheckbox); - this.tabPage1.Controls.Add(this.groupBox3); this.tabPage1.Controls.Add(this.groupBox1); this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(386, 391); + this.tabPage1.Size = new System.Drawing.Size(386, 322); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "General"; this.tabPage1.UseVisualStyleBackColor = true; // + // cbMergeLAndRModifierKeys + // + this.cbMergeLAndRModifierKeys.AutoSize = true; + this.cbMergeLAndRModifierKeys.Location = new System.Drawing.Point(7, 151); + this.cbMergeLAndRModifierKeys.Name = "cbMergeLAndRModifierKeys"; + this.cbMergeLAndRModifierKeys.Size = new System.Drawing.Size(320, 17); + this.cbMergeLAndRModifierKeys.TabIndex = 29; + this.cbMergeLAndRModifierKeys.Text = "Merge L+R modifier keys e.g. Shift instead of LShift and RShift"; + this.cbMergeLAndRModifierKeys.UseVisualStyleBackColor = true; + // // HandleAlternateKeyboardLayoutsCheckBox // this.HandleAlternateKeyboardLayoutsCheckBox.AutoSize = true; @@ -156,7 +159,7 @@ this.NeverAskSaveCheckbox.AutoSize = true; this.NeverAskSaveCheckbox.Location = new System.Drawing.Point(6, 29); this.NeverAskSaveCheckbox.Name = "NeverAskSaveCheckbox"; - this.NeverAskSaveCheckbox.Size = new System.Drawing.Size(184, 17); + this.NeverAskSaveCheckbox.Size = new System.Drawing.Size(387, 17); this.NeverAskSaveCheckbox.TabIndex = 20; this.NeverAskSaveCheckbox.Text = "When EmuHawk is closing, skip \"unsaved changes\" prompts and discard all"; this.NeverAskSaveCheckbox.UseVisualStyleBackColor = true; @@ -225,39 +228,6 @@ this.PauseWhenMenuActivatedCheckbox.Text = "Pause when menu activated"; this.PauseWhenMenuActivatedCheckbox.UseVisualStyleBackColor = true; // - // groupBox3 - // - this.groupBox3.Controls.Add(this.rbInputMethodSDL2); - this.groupBox3.Controls.Add(this.rbInputMethodDirectInput); - this.groupBox3.Location = new System.Drawing.Point(6, 151); - this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(369, 48); - this.groupBox3.TabIndex = 16; - this.groupBox3.TabStop = false; - this.groupBox3.Text = "Input Method (requires restart)"; - // - // rbInputMethodSDL2 - // - this.rbInputMethodSDL2.AutoSize = true; - this.rbInputMethodSDL2.Location = new System.Drawing.Point(136, 19); - this.rbInputMethodSDL2.Name = "rbInputMethodSDL2"; - this.rbInputMethodSDL2.Size = new System.Drawing.Size(65, 17); - this.rbInputMethodSDL2.TabIndex = 1; - this.rbInputMethodSDL2.TabStop = true; - this.rbInputMethodSDL2.Text = "SDL2"; - this.rbInputMethodSDL2.UseVisualStyleBackColor = true; - // - // rbInputMethodDirectInput - // - this.rbInputMethodDirectInput.AutoSize = true; - this.rbInputMethodDirectInput.Location = new System.Drawing.Point(7, 20); - this.rbInputMethodDirectInput.Name = "rbInputMethodDirectInput"; - this.rbInputMethodDirectInput.Size = new System.Drawing.Size(114, 17); - this.rbInputMethodDirectInput.TabIndex = 0; - this.rbInputMethodDirectInput.TabStop = true; - this.rbInputMethodDirectInput.Text = "DirectInput+XInput"; - this.rbInputMethodDirectInput.UseVisualStyleBackColor = true; - // // groupBox1 // this.groupBox1.Controls.Add(this.locLabelEx1); @@ -266,13 +236,19 @@ this.groupBox1.Controls.Add(this.StartFullScreenCheckbox); this.groupBox1.Controls.Add(this.label3); this.groupBox1.Controls.Add(this.SingleInstanceModeCheckbox); - this.groupBox1.Location = new System.Drawing.Point(6, 221); + this.groupBox1.Location = new System.Drawing.Point(6, 174); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(369, 133); this.groupBox1.TabIndex = 15; this.groupBox1.TabStop = false; this.groupBox1.Text = "Startup Options"; // + // locLabelEx1 + // + this.locLabelEx1.Location = new System.Drawing.Point(26, 112); + this.locLabelEx1.Name = "locLabelEx1"; + this.locLabelEx1.Text = "Note: Only a tiny subset of commandline args work (incl. rom path)"; + // // StartPausedCheckbox // this.StartPausedCheckbox.AutoSize = true; @@ -331,7 +307,7 @@ this.tabPage3.Controls.Add(this.BackupSRamCheckbox); this.tabPage3.Location = new System.Drawing.Point(4, 22); this.tabPage3.Name = "tabPage3"; - this.tabPage3.Size = new System.Drawing.Size(386, 391); + this.tabPage3.Size = new System.Drawing.Size(386, 322); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "Advanced"; this.tabPage3.UseVisualStyleBackColor = true; @@ -378,11 +354,7 @@ // AutosaveSRAMtextBox // this.AutosaveSRAMtextBox.Location = new System.Drawing.Point(151, 33); - this.AutosaveSRAMtextBox.Maximum = new decimal(new int[] { - 100000, - 0, - 0, - 0}); + this.AutosaveSRAMtextBox.Maximum = new decimal(new int[] { 100000, 0, 0, 0 }); this.AutosaveSRAMtextBox.Name = "AutosaveSRAMtextBox"; this.AutosaveSRAMtextBox.Size = new System.Drawing.Size(50, 20); this.AutosaveSRAMtextBox.TabIndex = 5; @@ -440,8 +412,7 @@ // this.label6.Location = new System.Drawing.Point(27, 243); this.label6.Name = "label6"; - this.label6.Text = "Skips some integrity check exceptions in waterbox cores.\r\nUseful for romhackers. " + - "Reboot core after changing.\r\nDon't bother reporting bugs if checked.\r\n"; + this.label6.Text = "Skips some integrity check exceptions in waterbox cores.\r\nUseful for romhackers. " + "Reboot core after changing.\r\nDon\'t bother reporting bugs if checked.\r\n"; // // cbSkipWaterboxIntegrityChecks // @@ -457,8 +428,7 @@ // this.label5.Location = new System.Drawing.Point(27, 194); this.label5.Name = "label5"; - this.label5.Text = "Will prevent many Out Of Memory crashes during long movies.\r\nYou must restart the" + - " program after changing this."; + this.label5.Text = "Will prevent many Out Of Memory crashes during long movies.\r\nYou must restart the" + " program after changing this."; // // cbMoviesOnDisk // @@ -512,29 +482,13 @@ this.BackupSRamCheckbox.Text = "Backup SaveRAM to .SaveRAM.bak"; this.BackupSRamCheckbox.UseVisualStyleBackColor = true; // - // locLabelEx1 - // - this.locLabelEx1.Location = new System.Drawing.Point(26, 112); - this.locLabelEx1.Name = "locLabelEx1"; - this.locLabelEx1.Text = "Note: Only a tiny subset of commandline args work (incl. rom path)"; - // - // cbMergeLAndRModifierKeys - // - this.cbMergeLAndRModifierKeys.AutoSize = true; - this.cbMergeLAndRModifierKeys.Location = new System.Drawing.Point(7, 202); - this.cbMergeLAndRModifierKeys.Name = "cbMergeLAndRModifierKeys"; - this.cbMergeLAndRModifierKeys.Size = new System.Drawing.Size(320, 17); - this.cbMergeLAndRModifierKeys.TabIndex = 29; - this.cbMergeLAndRModifierKeys.Text = "Merge L+R modifier keys e.g. Shift instead of LShift and RShift"; - this.cbMergeLAndRModifierKeys.UseVisualStyleBackColor = true; - // // EmuHawkOptions // this.AcceptButton = this.OkBtn; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.CancelBtn; - this.ClientSize = new System.Drawing.Size(418, 470); + this.ClientSize = new System.Drawing.Size(418, 401); this.Controls.Add(this.tabControl1); this.Controls.Add(this.CancelBtn); this.Controls.Add(this.OkBtn); @@ -546,8 +500,6 @@ this.tabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); this.tabPage1.PerformLayout(); - this.groupBox3.ResumeLayout(false); - this.groupBox3.PerformLayout(); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.tabPage3.ResumeLayout(false); @@ -556,7 +508,6 @@ this.groupBox2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.AutosaveSRAMtextBox)).EndInit(); this.ResumeLayout(false); - } #endregion @@ -594,9 +545,6 @@ private System.Windows.Forms.CheckBox RunInBackgroundCheckbox; private System.Windows.Forms.CheckBox EnableContextMenuCheckbox; private System.Windows.Forms.CheckBox PauseWhenMenuActivatedCheckbox; - private System.Windows.Forms.GroupBox groupBox3; - private System.Windows.Forms.RadioButton rbInputMethodSDL2; - private System.Windows.Forms.RadioButton rbInputMethodDirectInput; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.CheckBox StartPausedCheckbox; private BizHawk.WinForms.Controls.LocLabelEx label14; diff --git a/src/BizHawk.Client.EmuHawk/config/EmuHawkOptions.cs b/src/BizHawk.Client.EmuHawk/config/EmuHawkOptions.cs index 6a8a67db3e..e27de1d189 100755 --- a/src/BizHawk.Client.EmuHawk/config/EmuHawkOptions.cs +++ b/src/BizHawk.Client.EmuHawk/config/EmuHawkOptions.cs @@ -58,8 +58,6 @@ namespace BizHawk.Client.EmuHawk private void GuiOptions_Load(object sender, EventArgs e) { - rbInputMethodDirectInput.Enabled = HostCapabilityDetector.HasDirectX; - StartFullScreenCheckbox.Checked = _config.StartFullscreen; StartPausedCheckbox.Checked = _config.StartPaused; PauseWhenMenuActivatedCheckbox.Checked = _config.PauseWhenMenuActivated; @@ -82,18 +80,6 @@ namespace BizHawk.Client.EmuHawk cbMoviesOnDisk.Checked = _config.Movies.MoviesOnDisk; cbSkipWaterboxIntegrityChecks.Checked = _config.SkipWaterboxIntegrityChecks; NoMixedKeyPriorityCheckBox.Checked = _config.NoMixedInputHokeyOverride; - - switch (_config.HostInputMethod) - { - case EHostInputMethod.SDL2: - rbInputMethodSDL2.Checked = true; - break; - case EHostInputMethod.DirectInput: - rbInputMethodDirectInput.Checked = true; - break; - default: - throw new InvalidOperationException(); - } } private void OkBtn_Click(object sender, EventArgs e) @@ -122,8 +108,6 @@ namespace BizHawk.Client.EmuHawk _config.SuppressAskSave = NeverAskSaveCheckbox.Checked; _config.MergeLAndRModifierKeys = cbMergeLAndRModifierKeys.Checked; _config.SingleInstanceMode = SingleInstanceModeCheckbox.Checked; - if(rbInputMethodDirectInput.Checked) _config.HostInputMethod = EHostInputMethod.DirectInput; - if(rbInputMethodSDL2.Checked) _config.HostInputMethod = EHostInputMethod.SDL2; _config.BackupSaveram = BackupSRamCheckbox.Checked; _config.AutosaveSaveRAM = AutosaveSRAMCheckbox.Checked;