Input: Added an option to customize the deadzone for analog sticks

This commit is contained in:
Sour 2019-01-22 19:38:24 -05:00
parent 0d0adaf95c
commit abf5c43896
20 changed files with 179 additions and 20 deletions

View File

@ -673,6 +673,7 @@ private:
KeyMappingSet _controllerKeys[4] = { KeyMappingSet(), KeyMappingSet(), KeyMappingSet(), KeyMappingSet() };
bool _needControllerUpdate = false;
uint32_t _zapperDetectionRadius = 0;
uint32_t _controllerDeadzoneSize = 2;
std::unordered_map<int, double> _mouseSensitivity;
int32_t _inputPollScanline = 241;
@ -1327,6 +1328,22 @@ public:
}
}
void SetControllerDeadzoneSize(uint32_t deadzoneSize)
{
_controllerDeadzoneSize = deadzoneSize;
}
double GetControllerDeadzoneRatio()
{
switch(_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;
}
}
void SetZapperDetectionRadius(uint32_t detectionRadius)
{
_zapperDetectionRadius = detectionRadius;

View File

@ -137,6 +137,7 @@ namespace Mesen.GUI.Config
public InteropEmu.InputDisplayPosition DisplayInputPosition = InteropEmu.InputDisplayPosition.BottomRight;
public bool DisplayInputHorizontally = true;
[MinMax(0, 4)] public UInt32 ControllerDeadzoneSize = 2;
public bool HideMousePointerForZapper = true;
[XmlElement(ElementName = "InputDevice")]
@ -219,6 +220,7 @@ namespace Mesen.GUI.Config
InteropEmu.SetInputDisplaySettings(displayPorts, inputInfo.DisplayInputPosition, inputInfo.DisplayInputHorizontally);
InteropEmu.SetZapperDetectionRadius(inputInfo.Zapper.DetectionRadius);
InteropEmu.SetControllerDeadzoneSize(inputInfo.ControllerDeadzoneSize);
InteropEmu.SetMouseSensitivity(InteropEmu.MouseDevice.ArkanoidController, (inputInfo.ArkanoidController.Sensitivity + 1) / 2.0);
InteropEmu.SetMouseSensitivity(InteropEmu.MouseDevice.HoriTrack, (inputInfo.HoriTrack.Sensitivity + 1) / 2.0);

View File

@ -218,6 +218,11 @@
<Control ID="chkDisplayPort4">Jugador 4</Control>
<Control ID="lblDisplayPosition">Posició de pantalla:</Control>
<Control ID="chkDisplayInputHorizontally">Mostra horitzontalment</Control>
<Control ID="lblSmall">Curt</Control>
<Control ID="lblLarge">Llarg</Control>
<Control ID="lblDeadzone">Controller axis deadzone size:</Control>
<Control ID="chkHideMousePointerForZapper">Hide mouse pointer when using zapper</Control>
<Control ID="lblKeyBinding">Advertència: La vostra configuració actual conté assignacions conflictives - algunes tecles del vostre teclat o botons del comandament han estat assignats a múltiples botons al comandament de la NES. Si això no ha estat intencionat, us preguem que reviseu i corregiu les vostres assignacions.</Control>

View File

@ -218,6 +218,11 @@
<Control ID="chkDisplayPort4">Port 4</Control>
<Control ID="lblDisplayPosition">Display Position:</Control>
<Control ID="chkDisplayInputHorizontally">Display horizontally</Control>
<Control ID="lblSmall">Small</Control>
<Control ID="lblLarge">Large</Control>
<Control ID="lblDeadzone">Controller axis deadzone size:</Control>
<Control ID="chkHideMousePointerForZapper">Hide mouse pointer when using zapper</Control>
<Control ID="lblKeyBinding">Warning: Your current configuration contains conflicting key bindings - some physical buttons on your keyboard or gamepad are mapped to multiple buttons on the NES controller. If this is not intentional, please review and correct your key bindings.</Control>

View File

@ -217,6 +217,11 @@
<Control ID="chkDisplayPort4">Jugador 4</Control>
<Control ID="lblDisplayPosition">Posición de pantalla:</Control>
<Control ID="chkDisplayInputHorizontally">Mostrar horizontalmente</Control>
<Control ID="lblSmall">Corto</Control>
<Control ID="lblLarge">Largo</Control>
<Control ID="lblDeadzone">Controller axis deadzone size:</Control>
<Control ID="chkHideMousePointerForZapper">Hide mouse pointer when using zapper</Control>
<Control ID="lblKeyBinding">Advertencia: su configuración actual contiene asignaciones conflictivas - algunas teclas de su teclado o botones del mando se han asignado a varios botones del mando de la NES. Si esto no es intencionado, revise y corrija las asignaciones.</Control>

View File

@ -218,6 +218,11 @@
<Control ID="chkDisplayPort4">Joueur 4</Control>
<Control ID="lblDisplayPosition">Position d'affichage :</Control>
<Control ID="chkDisplayInputHorizontally">Afficher horizontalement</Control>
<Control ID="lblSmall">Petit</Control>
<Control ID="lblLarge">Large</Control>
<Control ID="lblDeadzone">Taille du deadzone :</Control>
<Control ID="chkHideMousePointerForZapper">Cacher la souris lorsqu'un zapper est connecté</Control>
<Control ID="lblKeyBinding">Attention: Votre configuration actuelle contient des conflits - certaines touches sur votre clavier ou manette sont mappées à plusieurs boutons sur la console. Veuillez réviser votre configuration et la corriger au besoin.</Control>

View File

@ -219,6 +219,11 @@
<Control ID="chkDisplayPort4">プレーヤー4</Control>
<Control ID="lblDisplayPosition">表示位置:</Control>
<Control ID="chkDisplayInputHorizontally">水平表示</Control>
<Control ID="lblSmall"></Control>
<Control ID="lblLarge"></Control>
<Control ID="lblDeadzone">デッドゾーンの大きさ:</Control>
<Control ID="chkHideMousePointerForZapper">ガンが接続されている時にマウスポインターを隠す</Control>
<Control ID="lblKeyBinding">注意: 使っている設定の中には同じキーが複数のボタン―にマッピングされています。 間違いでこの設定にした場合は、設定を確認して直してください。</Control>

View File

@ -218,6 +218,11 @@
<Control ID="chkDisplayPort4">Jogador 4</Control>
<Control ID="lblDisplayPosition">Posição da tela</Control>
<Control ID="chkDisplayInputHorizontally">Mostrar horizontalmente</Control>
<Control ID="lblSmall">Curta</Control>
<Control ID="lblLarge">Longa</Control>
<Control ID="lblDeadzone">Controller axis deadzone size:</Control>
<Control ID="chkHideMousePointerForZapper">Esconder o ponteiro do mouse ao usar a pistola zapper</Control>
<Control ID="lblKeyBinding">Aviso: a configuração atual contém atribuições conflitantes - alguns botões físicos em seu teclado ou gamepad são mapeados para vários botões no controle NES. Se isso não for intencional, reveja e corrija suas atribuições.</Control>

View File

@ -217,6 +217,11 @@
<Control ID="chkDisplayPort4">Порт 4</Control>
<Control ID="lblDisplayPosition">Позиция :</Control>
<Control ID="chkDisplayInputHorizontally">Отображать горизонтально</Control>
<Control ID="lblSmall">Small</Control>
<Control ID="lblLarge">Large</Control>
<Control ID="lblDeadzone">Controller axis deadzone size:</Control>
<Control ID="chkHideMousePointerForZapper">Hide mouse pointer when using zapper</Control>
<Control ID="lblKeyBinding">Warning: Your current configuration contains conflicting key bindings - some physical buttons on your keyboard or gamepad are mapped to multiple buttons on the NES controller. If this is not intentional, please review and correct your key bindings.</Control>

View File

@ -217,6 +217,11 @@
<Control ID="chkDisplayPort4">Порт 4</Control>
<Control ID="lblDisplayPosition">Позиція :</Control>
<Control ID="chkDisplayInputHorizontally">Відображати горизонтально</Control>
<Control ID="lblSmall">Малий</Control>
<Control ID="lblLarge">Великий</Control>
<Control ID="lblDeadzone">Controller axis deadzone size:</Control>
<Control ID="chkHideMousePointerForZapper">Hide mouse pointer when using zapper</Control>
<Control ID="lblKeyBinding">Увага: Ваша поточна конфігурація містить конфліктуючі поєднання клавіш - деякі фізичні кнопки на вашому ключовому словнику або геймпадi відображаються на кількох кнопках на контролері NES. Якщо це не навмисне, перегляньте та виправте ключi.</Control>

View File

@ -221,6 +221,11 @@
<Control ID="chkDisplayPort4">玩家 4</Control>
<Control ID="lblDisplayPosition">显示位置:</Control>
<Control ID="chkDisplayInputHorizontally">横向</Control>
<Control ID="lblSmall"></Control>
<Control ID="lblLarge"></Control>
<Control ID="lblDeadzone">Controller axis deadzone size:</Control>
<Control ID="chkHideMousePointerForZapper">使用手枪时隐藏鼠标指针</Control>
<Control ID="lblKeyBinding">警告:您当前的配置包含冲突的键绑定 - 键盘或游戏手柄上的某些物理按钮映射到NES控制器上的多个按钮.如果这不是故意的,请查看并更正您的按键绑定.</Control>

View File

@ -71,6 +71,11 @@
this.lblDisplayPosition = new System.Windows.Forms.Label();
this.cboDisplayInputPosition = new System.Windows.Forms.ComboBox();
this.chkHideMousePointerForZapper = new Mesen.GUI.Controls.ctrlRiskyOption();
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
this.lblDeadzone = new System.Windows.Forms.Label();
this.trkControllerDeadzoneSize = new System.Windows.Forms.TrackBar();
this.lblSmall = new System.Windows.Forms.Label();
this.lblLarge = new System.Windows.Forms.Label();
this.tabMain.SuspendLayout();
this.tpgControllers.SuspendLayout();
this.tlpControllers.SuspendLayout();
@ -83,6 +88,8 @@
this.tableLayoutPanel3.SuspendLayout();
this.flowLayoutPanel2.SuspendLayout();
this.flowLayoutPanel3.SuspendLayout();
this.tableLayoutPanel4.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trkControllerDeadzoneSize)).BeginInit();
this.SuspendLayout();
//
// baseConfigPanel
@ -453,11 +460,13 @@
this.tableLayoutPanel2.ColumnCount = 1;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Controls.Add(this.grpDisplayInput, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.chkHideMousePointerForZapper, 0, 1);
this.tableLayoutPanel2.Controls.Add(this.chkHideMousePointerForZapper, 0, 2);
this.tableLayoutPanel2.Controls.Add(this.tableLayoutPanel4, 0, 1);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 3;
this.tableLayoutPanel2.RowCount = 4;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
@ -590,12 +599,73 @@
//
this.chkHideMousePointerForZapper.Checked = false;
this.chkHideMousePointerForZapper.Dock = System.Windows.Forms.DockStyle.Fill;
this.chkHideMousePointerForZapper.Location = new System.Drawing.Point(0, 96);
this.chkHideMousePointerForZapper.Location = new System.Drawing.Point(0, 151);
this.chkHideMousePointerForZapper.Name = "chkHideMousePointerForZapper";
this.chkHideMousePointerForZapper.Size = new System.Drawing.Size(362, 23);
this.chkHideMousePointerForZapper.TabIndex = 2;
this.chkHideMousePointerForZapper.Text = "Hide mouse pointer when using zapper";
//
// tableLayoutPanel4
//
this.tableLayoutPanel4.ColumnCount = 4;
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel4.Controls.Add(this.lblDeadzone, 0, 0);
this.tableLayoutPanel4.Controls.Add(this.trkControllerDeadzoneSize, 1, 0);
this.tableLayoutPanel4.Controls.Add(this.lblSmall, 1, 1);
this.tableLayoutPanel4.Controls.Add(this.lblLarge, 2, 1);
this.tableLayoutPanel4.Location = new System.Drawing.Point(0, 96);
this.tableLayoutPanel4.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
this.tableLayoutPanel4.RowCount = 2;
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel4.Size = new System.Drawing.Size(356, 55);
this.tableLayoutPanel4.TabIndex = 3;
//
// lblDeadzone
//
this.lblDeadzone.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblDeadzone.AutoSize = true;
this.lblDeadzone.Location = new System.Drawing.Point(3, 11);
this.lblDeadzone.Name = "lblDeadzone";
this.lblDeadzone.Size = new System.Drawing.Size(146, 13);
this.lblDeadzone.TabIndex = 0;
this.lblDeadzone.Text = "Controller axis deadzone size:";
//
// trkControllerDeadzoneSize
//
this.trkControllerDeadzoneSize.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.tableLayoutPanel4.SetColumnSpan(this.trkControllerDeadzoneSize, 2);
this.trkControllerDeadzoneSize.LargeChange = 1;
this.trkControllerDeadzoneSize.Location = new System.Drawing.Point(155, 3);
this.trkControllerDeadzoneSize.Maximum = 4;
this.trkControllerDeadzoneSize.Name = "trkControllerDeadzoneSize";
this.trkControllerDeadzoneSize.Size = new System.Drawing.Size(106, 29);
this.trkControllerDeadzoneSize.TabIndex = 1;
//
// lblSmall
//
this.lblSmall.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblSmall.AutoSize = true;
this.lblSmall.Location = new System.Drawing.Point(155, 38);
this.lblSmall.Name = "lblSmall";
this.lblSmall.Size = new System.Drawing.Size(32, 13);
this.lblSmall.TabIndex = 2;
this.lblSmall.Text = "Small";
//
// lblLarge
//
this.lblLarge.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.lblLarge.AutoSize = true;
this.lblLarge.Location = new System.Drawing.Point(227, 38);
this.lblLarge.Name = "lblLarge";
this.lblLarge.Size = new System.Drawing.Size(34, 13);
this.lblLarge.TabIndex = 3;
this.lblLarge.Text = "Large";
//
// frmInputConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -628,6 +698,9 @@
this.flowLayoutPanel2.PerformLayout();
this.flowLayoutPanel3.ResumeLayout(false);
this.flowLayoutPanel3.PerformLayout();
this.tableLayoutPanel4.ResumeLayout(false);
this.tableLayoutPanel4.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.trkControllerDeadzoneSize)).EndInit();
this.ResumeLayout(false);
}
@ -677,5 +750,10 @@
private System.Windows.Forms.ComboBox cboCartridge;
private System.Windows.Forms.Button btnSetupCartridge;
private Controls.ctrlRiskyOption chkHideMousePointerForZapper;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;
private System.Windows.Forms.Label lblDeadzone;
private System.Windows.Forms.TrackBar trkControllerDeadzoneSize;
private System.Windows.Forms.Label lblSmall;
private System.Windows.Forms.Label lblLarge;
}
}

View File

@ -43,6 +43,7 @@ namespace Mesen.GUI.Forms.Config
AddBinding("DisplayInputPort4", chkDisplayPort4);
AddBinding("DisplayInputPosition", cboDisplayInputPosition);
AddBinding("DisplayInputHorizontally", chkDisplayInputHorizontally);
AddBinding("ControllerDeadzoneSize", trkControllerDeadzoneSize);
AddBinding("HideMousePointerForZapper", chkHideMousePointerForZapper);
//Sort expansion port dropdown alphabetically, but keep the "None" option at the top

View File

@ -61,6 +61,7 @@ namespace Mesen.GUI
[DllImport(DLLPath)] public static extern void SetControllerType(int port, ControllerType type);
[DllImport(DLLPath)] public static extern void SetControllerKeys(int port, KeyMappingSet mapping);
[DllImport(DLLPath)] public static extern void SetZapperDetectionRadius(UInt32 detectionRadius);
[DllImport(DLLPath)] public static extern void SetControllerDeadzoneSize(UInt32 deadzoneSize);
[DllImport(DLLPath)] public static extern void SetExpansionDevice(ExpansionPortDevice device);
[DllImport(DLLPath)] public static extern void SetConsoleType(ConsoleType type);
[DllImport(DLLPath)] public static extern void SetMouseSensitivity(MouseDevice device, double sensitivity);

View File

@ -310,6 +310,7 @@ namespace InteropEmu {
DllExport void __stdcall SetControllerType(uint32_t port, ControllerType type) { _settings->SetControllerType(port, type); }
DllExport void __stdcall SetControllerKeys(uint32_t port, KeyMappingSet mappings) { _settings->SetControllerKeys(port, mappings); }
DllExport void __stdcall SetZapperDetectionRadius(uint32_t detectionRadius) { _settings->SetZapperDetectionRadius(detectionRadius); }
DllExport void __stdcall SetControllerDeadzoneSize(uint32_t deadzoneSize) { _settings->SetControllerDeadzoneSize(deadzoneSize); }
DllExport void __stdcall SetExpansionDevice(ExpansionPortDevice device) { _settings->SetExpansionDevice(device); }
DllExport void __stdcall SetConsoleType(ConsoleType type) { _settings->SetConsoleType(type); }
DllExport void __stdcall SetMouseSensitivity(MouseDevice device, double sensitivity) { _settings->SetMouseSensitivity(device, sensitivity); }

View File

@ -10,6 +10,8 @@
#include "DirectInputManager.h"
#include <algorithm>
#include "../Core/MessageManager.h"
#include "../Core/Console.h"
#include "../Core/EmulationSettings.h"
LPDIRECTINPUT8 DirectInputManager::_directInput = nullptr;
vector<DirectInputData> DirectInputManager::_joysticks;
@ -352,7 +354,7 @@ bool DirectInputManager::IsPressed(int port, int button)
DIJOYSTATE2& state = _joysticks[port].state;
DIJOYSTATE2& defaultState = _joysticks[port].defaultState;
int deadRange = 500;
int deadRange = 500 * _console->GetSettings()->GetControllerDeadzoneRatio();
int povDirection = state.rgdwPOV[0] / 4500;
bool povCentered = (LOWORD(state.rgdwPOV[0]) == 0xFFFF) || povDirection >= 8;
@ -417,8 +419,9 @@ void DirectInputManager::UpdateInputState(DirectInputData &data)
}
DirectInputManager::DirectInputManager(HWND hWnd)
DirectInputManager::DirectInputManager(shared_ptr<Console> console, HWND hWnd)
{
_console = console;
_hWnd = hWnd;
Initialize();
}

View File

@ -3,6 +3,8 @@
#include <dinput.h>
#include "../Utilities/SimpleLock.h"
class Console;
struct DirectInputData
{
LPDIRECTINPUTDEVICE8 joystick;
@ -16,6 +18,7 @@ class DirectInputManager
{
private:
static HWND _hWnd;
shared_ptr<Console> _console;
bool _needToUpdate = false;
bool _requestUpdate = false;
static LPDIRECTINPUT8 _directInput;
@ -33,7 +36,7 @@ private:
static int __stdcall EnumObjectsCallback(const DIDEVICEOBJECTINSTANCE* pdidoi, void* pContext);
public:
DirectInputManager(HWND window);
DirectInputManager(shared_ptr<Console> console, HWND window);
~DirectInputManager();
void RefreshState();

View File

@ -252,8 +252,8 @@ WindowsKeyManager::~WindowsKeyManager()
void WindowsKeyManager::StartUpdateDeviceThread()
{
_updateDeviceThread = std::thread([=]() {
_xInput.reset(new XInputManager());
_directInput.reset(new DirectInputManager(_hWnd));
_xInput.reset(new XInputManager(_console));
_directInput.reset(new DirectInputManager(_console, _hWnd));
while(!_stopUpdateDeviceThread) {
//Check for newly plugged in controllers every 5 secs (this takes ~60-70ms when no new controllers are found)

View File

@ -1,8 +1,11 @@
#include "stdafx.h"
#include "XInputManager.h"
#include "../Core/Console.h"
#include "../Core/EmulationSettings.h"
XInputManager::XInputManager()
XInputManager::XInputManager(shared_ptr<Console> console)
{
_console = console;
for(int i = 0; i < XUSER_MAX_COUNT; i++) {
_gamePadStates.push_back(shared_ptr<XINPUT_STATE>(new XINPUT_STATE()));
_gamePadConnected.push_back(true);
@ -54,17 +57,19 @@ bool XInputManager::IsPressed(uint8_t gamepadPort, uint8_t button)
WORD xinputButton = 1 << (button - 1);
return (_gamePadStates[gamepadPort]->Gamepad.wButtons & xinputButton) != 0;
} else {
double ratio = _console->GetSettings()->GetControllerDeadzoneRatio() * 2;
switch(button) {
case 17: return gamepad.bLeftTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD;
case 18: return gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD;
case 19: return gamepad.sThumbRY > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE;
case 20: return gamepad.sThumbRY < -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE;
case 21: return gamepad.sThumbRX < -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE;
case 22: return gamepad.sThumbRX > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE;
case 23: return gamepad.sThumbLY > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE;
case 24: return gamepad.sThumbLY < -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE;
case 25: return gamepad.sThumbLX < -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE;
case 26: return gamepad.sThumbLX > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE;
case 17: return gamepad.bLeftTrigger > (XINPUT_GAMEPAD_TRIGGER_THRESHOLD * ratio);
case 18: return gamepad.bRightTrigger > (XINPUT_GAMEPAD_TRIGGER_THRESHOLD * ratio);
case 19: return gamepad.sThumbRY > (XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE * ratio);
case 20: return gamepad.sThumbRY < -(XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE * ratio);
case 21: return gamepad.sThumbRX < -(XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE * ratio);
case 22: return gamepad.sThumbRX > (XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE * ratio);
case 23: return gamepad.sThumbLY > (XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE * ratio);
case 24: return gamepad.sThumbLY < -(XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE * ratio);
case 25: return gamepad.sThumbLX < -(XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE * ratio);
case 26: return gamepad.sThumbLX > (XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE * ratio);
}
}
}

View File

@ -3,14 +3,17 @@
#include "stdafx.h"
#include <Xinput.h>
class Console;
class XInputManager
{
private:
shared_ptr<Console> _console;
vector<shared_ptr<XINPUT_STATE>> _gamePadStates;
vector<uint8_t> _gamePadConnected;
public:
XInputManager();
XInputManager(shared_ptr<Console> console);
bool NeedToUpdate();
void UpdateDeviceList();