Input: Added option to control analog stick deadzone size
This commit is contained in:
parent
a3829c58fa
commit
fdb8ca6292
8 changed files with 32 additions and 21 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -70,4 +70,5 @@ public:
|
|||
void InitializeRam(void* data, uint32_t length);
|
||||
|
||||
bool IsInputEnabled();
|
||||
double GetControllerDeadzoneRatio();
|
||||
};
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
23
UI/Forms/Config/frmInputConfig.Designer.cs
generated
23
UI/Forms/Config/frmInputConfig.Designer.cs
generated
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <algorithm>
|
||||
#include "../Core/MessageManager.h"
|
||||
#include "../Core/Console.h"
|
||||
#include "../Core/EmuSettings.h"
|
||||
|
||||
LPDIRECTINPUT8 DirectInputManager::_directInput = nullptr;
|
||||
vector<DirectInputData> 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;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "stdafx.h"
|
||||
#include "XInputManager.h"
|
||||
#include "../Core/Console.h"
|
||||
#include "../Core/EmuSettings.h"
|
||||
|
||||
XInputManager::XInputManager(shared_ptr<Console> 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);
|
||||
|
|
Loading…
Add table
Reference in a new issue