mirror of https://github.com/PCSX2/pcsx2.git
PAD/Host: Fix unconditionally sending state for disconnected ports
This commit is contained in:
parent
277706505e
commit
4873165dbc
|
@ -17,6 +17,11 @@
|
||||||
|
|
||||||
#include "PAD/Host/Global.h"
|
#include "PAD/Host/Global.h"
|
||||||
|
|
||||||
|
namespace PAD
|
||||||
|
{
|
||||||
|
enum class ControllerType : u8;
|
||||||
|
}
|
||||||
|
|
||||||
class KeyStatus
|
class KeyStatus
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -28,6 +33,7 @@ private:
|
||||||
u8 rx, ry;
|
u8 rx, ry;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PAD::ControllerType m_type[GAMEPAD_NUMBER] = {};
|
||||||
u32 m_button[GAMEPAD_NUMBER];
|
u32 m_button[GAMEPAD_NUMBER];
|
||||||
u8 m_button_pressure[GAMEPAD_NUMBER][MAX_KEYS];
|
u8 m_button_pressure[GAMEPAD_NUMBER][MAX_KEYS];
|
||||||
PADAnalog m_analog[GAMEPAD_NUMBER];
|
PADAnalog m_analog[GAMEPAD_NUMBER];
|
||||||
|
@ -40,6 +46,9 @@ public:
|
||||||
|
|
||||||
void Set(u32 pad, u32 index, float value);
|
void Set(u32 pad, u32 index, float value);
|
||||||
|
|
||||||
|
__fi PAD::ControllerType GetType(u32 pad) { return m_type[pad]; }
|
||||||
|
__fi void SetType(u32 pad, PAD::ControllerType type) { m_type[pad] = type; }
|
||||||
|
|
||||||
__fi void SetAxisScale(u32 pad, float scale) { m_axis_scale[pad] = scale; }
|
__fi void SetAxisScale(u32 pad, float scale) { m_axis_scale[pad] = scale; }
|
||||||
__fi float GetVibrationScale(u32 pad, u32 motor) const { return m_vibration_scale[pad][motor]; }
|
__fi float GetVibrationScale(u32 pad, u32 motor) const { return m_vibration_scale[pad][motor]; }
|
||||||
__fi void SetVibrationScale(u32 pad, u32 motor, float scale) { m_vibration_scale[pad][motor] = scale; }
|
__fi void SetVibrationScale(u32 pad, u32 motor, float scale) { m_vibration_scale[pad][motor] = scale; }
|
||||||
|
|
|
@ -187,13 +187,26 @@ void PAD::LoadConfig(const SettingsInterface& si)
|
||||||
{
|
{
|
||||||
const std::string section(StringUtil::StdStringFromFormat("Pad%u", i + 1u));
|
const std::string section(StringUtil::StdStringFromFormat("Pad%u", i + 1u));
|
||||||
const std::string type(si.GetStringValue(section.c_str(), "Type", GetDefaultPadType(i)));
|
const std::string type(si.GetStringValue(section.c_str(), "Type", GetDefaultPadType(i)));
|
||||||
const float axis_scale = si.GetFloatValue(section.c_str(), "AxisScale", 1.0f);
|
|
||||||
const float large_motor_scale = si.GetFloatValue(section.c_str(), "LargeMotorScale", 1.0f);
|
|
||||||
const float small_motor_scale = si.GetFloatValue(section.c_str(), "SmallMotorScale", 1.0f);
|
|
||||||
|
|
||||||
|
const ControllerInfo* ci = GetControllerInfo(type);
|
||||||
|
if (!ci)
|
||||||
|
{
|
||||||
|
g_key_status.SetType(i, ControllerType::NotConnected);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_key_status.SetType(i, ci->type);
|
||||||
|
|
||||||
|
const float axis_scale = si.GetFloatValue(section.c_str(), "AxisScale", 1.0f);
|
||||||
g_key_status.SetAxisScale(i, axis_scale);
|
g_key_status.SetAxisScale(i, axis_scale);
|
||||||
g_key_status.SetVibrationScale(i, 0, large_motor_scale);
|
|
||||||
g_key_status.SetVibrationScale(i, 1, small_motor_scale);
|
if (ci->vibration_caps != VibrationCapabilities::NoVibration)
|
||||||
|
{
|
||||||
|
const float large_motor_scale = si.GetFloatValue(section.c_str(), "LargeMotorScale", 1.0f);
|
||||||
|
const float small_motor_scale = si.GetFloatValue(section.c_str(), "SmallMotorScale", 1.0f);
|
||||||
|
g_key_status.SetVibrationScale(i, 0, large_motor_scale);
|
||||||
|
g_key_status.SetVibrationScale(i, 1, small_motor_scale);
|
||||||
|
}
|
||||||
|
|
||||||
LoadMacroButtonConfig(si, i, type, section);
|
LoadMacroButtonConfig(si, i, type, section);
|
||||||
}
|
}
|
||||||
|
@ -303,10 +316,21 @@ static const PAD::ControllerBindingInfo s_dualshock2_binds[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const PAD::ControllerInfo s_controller_info[] = {
|
static const PAD::ControllerInfo s_controller_info[] = {
|
||||||
{"None", "Not Connected", nullptr, 0, PAD::VibrationCapabilities::NoVibration},
|
{"None", "Not Connected", nullptr, 0, PAD::ControllerType::NotConnected, PAD::VibrationCapabilities::NoVibration},
|
||||||
{"DualShock2", "DuckShock 2", s_dualshock2_binds, std::size(s_dualshock2_binds), PAD::VibrationCapabilities::LargeSmallMotors},
|
{"DualShock2", "DuckShock 2", s_dualshock2_binds, std::size(s_dualshock2_binds), PAD::ControllerType::DualShock2, PAD::VibrationCapabilities::LargeSmallMotors},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const PAD::ControllerInfo* PAD::GetControllerInfo(ControllerType type)
|
||||||
|
{
|
||||||
|
for (const ControllerInfo& info : s_controller_info)
|
||||||
|
{
|
||||||
|
if (type == info.type)
|
||||||
|
return &info;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
const PAD::ControllerInfo* PAD::GetControllerInfo(const std::string_view& name)
|
const PAD::ControllerInfo* PAD::GetControllerInfo(const std::string_view& name)
|
||||||
{
|
{
|
||||||
for (const ControllerInfo& info : s_controller_info)
|
for (const ControllerInfo& info : s_controller_info)
|
||||||
|
|
|
@ -37,6 +37,13 @@ u8 PADpoll(u8 value);
|
||||||
|
|
||||||
namespace PAD
|
namespace PAD
|
||||||
{
|
{
|
||||||
|
enum class ControllerType: u8
|
||||||
|
{
|
||||||
|
NotConnected,
|
||||||
|
DualShock2,
|
||||||
|
Count
|
||||||
|
};
|
||||||
|
|
||||||
enum class ControllerBindingType : u8
|
enum class ControllerBindingType : u8
|
||||||
{
|
{
|
||||||
Unknown,
|
Unknown,
|
||||||
|
@ -69,6 +76,7 @@ namespace PAD
|
||||||
const char* display_name;
|
const char* display_name;
|
||||||
const ControllerBindingInfo* bindings;
|
const ControllerBindingInfo* bindings;
|
||||||
u32 num_bindings;
|
u32 num_bindings;
|
||||||
|
ControllerType type;
|
||||||
PAD::VibrationCapabilities vibration_caps;
|
PAD::VibrationCapabilities vibration_caps;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,6 +108,7 @@ namespace PAD
|
||||||
VibrationCapabilities GetControllerVibrationCapabilities(const std::string_view& type);
|
VibrationCapabilities GetControllerVibrationCapabilities(const std::string_view& type);
|
||||||
|
|
||||||
/// Returns general information for the specified controller type.
|
/// Returns general information for the specified controller type.
|
||||||
|
const ControllerInfo* GetControllerInfo(ControllerType type);
|
||||||
const ControllerInfo* GetControllerInfo(const std::string_view& name);
|
const ControllerInfo* GetControllerInfo(const std::string_view& name);
|
||||||
|
|
||||||
/// Performs automatic controller mapping with the provided list of generic mappings.
|
/// Performs automatic controller mapping with the provided list of generic mappings.
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "PAD/Host/StateManagement.h"
|
#include "PAD/Host/StateManagement.h"
|
||||||
#include "PAD/Host/KeyStatus.h"
|
#include "PAD/Host/KeyStatus.h"
|
||||||
|
#include "PAD/Host/PAD.h"
|
||||||
#include "Frontend/InputManager.h"
|
#include "Frontend/InputManager.h"
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -62,19 +63,31 @@ void QueryInfo::reset()
|
||||||
|
|
||||||
u8 QueryInfo::start_poll(int _port)
|
u8 QueryInfo::start_poll(int _port)
|
||||||
{
|
{
|
||||||
if (port > 1)
|
if (_port >= static_cast<int>(GAMEPAD_NUMBER))
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
queryDone = 0;
|
|
||||||
port = _port;
|
port = _port;
|
||||||
slot = slots[port];
|
slot = slots[port];
|
||||||
numBytes = 2;
|
|
||||||
lastByte = 0;
|
|
||||||
|
|
||||||
return 0xFF;
|
if (g_key_status.GetType(_port) == PAD::ControllerType::NotConnected)
|
||||||
|
{
|
||||||
|
queryDone = 1;
|
||||||
|
numBytes = 0;
|
||||||
|
lastByte = 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
queryDone = 0;
|
||||||
|
numBytes = 2;
|
||||||
|
lastByte = 0;
|
||||||
|
|
||||||
|
return 0xFF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue