diff --git a/Core/EmuSettings.cpp b/Core/EmuSettings.cpp index 68b4cef..b05fe0c 100644 --- a/Core/EmuSettings.cpp +++ b/Core/EmuSettings.cpp @@ -285,3 +285,15 @@ bool EmuSettings::IsInputEnabled() { return !CheckFlag(EmulationFlags::InBackground) || _preferences.AllowBackgroundInput; } + +double EmuSettings::GetControllerDeadzoneRatio() +{ + switch(_input.ControllerDeadzoneSize) { + case 0: return 0.5; + case 1: return 0.75; + case 2: return 1; + case 3: return 1.25; + case 4: return 1.5; + } + return 1; +} diff --git a/Core/EmuSettings.h b/Core/EmuSettings.h index 6c02ba6..f8df04c 100644 --- a/Core/EmuSettings.h +++ b/Core/EmuSettings.h @@ -70,4 +70,5 @@ public: void InitializeRam(void* data, uint32_t length); bool IsInputEnabled(); + double GetControllerDeadzoneRatio(); }; \ No newline at end of file diff --git a/Core/ShortcutKeyHandler.cpp b/Core/ShortcutKeyHandler.cpp index 6749bd2..1689469 100644 --- a/Core/ShortcutKeyHandler.cpp +++ b/Core/ShortcutKeyHandler.cpp @@ -187,10 +187,9 @@ void ShortcutKeyHandler::CheckMappedKeys() void ShortcutKeyHandler::ProcessKeys() { - //TODO - /*if(!_console->GetSettings()->IsInputEnabled()) { + if(!_console->GetSettings()->IsInputEnabled()) { return; - }*/ + } auto lock = _lock.AcquireSafe(); KeyManager::RefreshKeyState(); diff --git a/Linux/LinuxGameController.cpp b/Linux/LinuxGameController.cpp index f4d5148..6edcfd6 100644 --- a/Linux/LinuxGameController.cpp +++ b/Linux/LinuxGameController.cpp @@ -122,7 +122,7 @@ void LinuxGameController::Calibrate() bool LinuxGameController::CheckAxis(unsigned int code, bool forPositive) { - double deadZoneRatio = 1; //TODO _console->GetSettings()->GetControllerDeadzoneRatio(); + double deadZoneRatio = _console->GetSettings()->GetControllerDeadzoneRatio(); int deadZoneNegative = (_axisDefaultValue[code] - libevdev_get_abs_minimum(_device, code)) * 0.400 * deadZoneRatio; int deadZonePositive = (libevdev_get_abs_maximum(_device, code) - _axisDefaultValue[code]) * 0.400 * deadZoneRatio; diff --git a/UI/Forms/Config/frmInputConfig.Designer.cs b/UI/Forms/Config/frmInputConfig.Designer.cs index cce5a72..6b2b000 100644 --- a/UI/Forms/Config/frmInputConfig.Designer.cs +++ b/UI/Forms/Config/frmInputConfig.Designer.cs @@ -64,6 +64,7 @@ this.chkDisplayPort2 = new System.Windows.Forms.CheckBox(); this.chkDisplayPort3 = new System.Windows.Forms.CheckBox(); this.chkDisplayPort4 = new System.Windows.Forms.CheckBox(); + this.chkDisplayPort5 = new System.Windows.Forms.CheckBox(); this.chkDisplayInputHorizontally = new System.Windows.Forms.CheckBox(); this.flowLayoutPanel3 = new System.Windows.Forms.FlowLayoutPanel(); this.lblDisplayPosition = new System.Windows.Forms.Label(); @@ -74,7 +75,6 @@ this.trkControllerDeadzoneSize = new System.Windows.Forms.TrackBar(); this.lblSmall = new System.Windows.Forms.Label(); this.lblLarge = new System.Windows.Forms.Label(); - this.chkDisplayPort5 = new System.Windows.Forms.CheckBox(); this.tabMain.SuspendLayout(); this.tpgControllers.SuspendLayout(); this.tlpControllers.SuspendLayout(); @@ -543,6 +543,16 @@ this.chkDisplayPort4.Text = "Port 4"; this.chkDisplayPort4.UseVisualStyleBackColor = true; // + // chkDisplayPort5 + // + this.chkDisplayPort5.AutoSize = true; + this.chkDisplayPort5.Location = new System.Drawing.Point(243, 3); + this.chkDisplayPort5.Name = "chkDisplayPort5"; + this.chkDisplayPort5.Size = new System.Drawing.Size(54, 17); + this.chkDisplayPort5.TabIndex = 4; + this.chkDisplayPort5.Text = "Port 5"; + this.chkDisplayPort5.UseVisualStyleBackColor = true; + // // chkDisplayInputHorizontally // this.chkDisplayInputHorizontally.AutoSize = true; @@ -613,7 +623,6 @@ this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel5.Size = new System.Drawing.Size(356, 55); this.tableLayoutPanel5.TabIndex = 3; - this.tableLayoutPanel5.Visible = false; // // lblDeadzone // @@ -658,16 +667,6 @@ this.lblLarge.TabIndex = 3; this.lblLarge.Text = "Large"; // - // chkDisplayPort5 - // - this.chkDisplayPort5.AutoSize = true; - this.chkDisplayPort5.Location = new System.Drawing.Point(243, 3); - this.chkDisplayPort5.Name = "chkDisplayPort5"; - this.chkDisplayPort5.Size = new System.Drawing.Size(54, 17); - this.chkDisplayPort5.TabIndex = 4; - this.chkDisplayPort5.Text = "Port 5"; - this.chkDisplayPort5.UseVisualStyleBackColor = true; - // // frmInputConfig // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/UI/Forms/Config/frmInputConfig.cs b/UI/Forms/Config/frmInputConfig.cs index d2c8bf0..69be955 100644 --- a/UI/Forms/Config/frmInputConfig.cs +++ b/UI/Forms/Config/frmInputConfig.cs @@ -46,6 +46,7 @@ namespace Mesen.GUI.Forms.Config AddBinding(nameof(InputConfig.DisplayInputPort5), chkDisplayPort5); AddBinding(nameof(InputConfig.DisplayInputPosition), cboDisplayInputPosition); AddBinding(nameof(InputConfig.DisplayInputHorizontally), chkDisplayInputHorizontally); + AddBinding(nameof(InputConfig.ControllerDeadzoneSize), trkControllerDeadzoneSize); UpdateUiSections(); } diff --git a/Windows/DirectInputManager.cpp b/Windows/DirectInputManager.cpp index 3655cf9..3793ce2 100644 --- a/Windows/DirectInputManager.cpp +++ b/Windows/DirectInputManager.cpp @@ -11,6 +11,7 @@ #include #include "../Core/MessageManager.h" #include "../Core/Console.h" +#include "../Core/EmuSettings.h" LPDIRECTINPUT8 DirectInputManager::_directInput = nullptr; vector DirectInputManager::_joysticks; @@ -353,9 +354,7 @@ bool DirectInputManager::IsPressed(int port, int button) DIJOYSTATE2& state = _joysticks[port].state; DIJOYSTATE2& defaultState = _joysticks[port].defaultState; - int deadRange = (int)(500 * 1); - //TODO - //_console->GetSettings()->GetControllerDeadzoneRatio() + int deadRange = (int)(500 * _console->GetSettings()->GetControllerDeadzoneRatio()); int povDirection = state.rgdwPOV[0] / 4500; bool povCentered = (LOWORD(state.rgdwPOV[0]) == 0xFFFF) || povDirection >= 8; diff --git a/Windows/XInputManager.cpp b/Windows/XInputManager.cpp index 185f0ff..c90053d 100644 --- a/Windows/XInputManager.cpp +++ b/Windows/XInputManager.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "XInputManager.h" #include "../Core/Console.h" +#include "../Core/EmuSettings.h" XInputManager::XInputManager(shared_ptr console) { @@ -56,8 +57,7 @@ bool XInputManager::IsPressed(uint8_t gamepadPort, uint8_t button) WORD xinputButton = 1 << (button - 1); return (_gamePadStates[gamepadPort]->Gamepad.wButtons & xinputButton) != 0; } else { - //TODO - double ratio = 1; //_console->GetSettings()->GetControllerDeadzoneRatio() * 2; + double ratio = _console->GetSettings()->GetControllerDeadzoneRatio() * 2; switch(button) { case 17: return gamepad.bLeftTrigger > (XINPUT_GAMEPAD_TRIGGER_THRESHOLD * ratio);