mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-03-06 14:27:44 +00:00
AnalogController: Show controller number in OSD messages
This commit is contained in:
parent
95468901f2
commit
9539ce032b
|
@ -5,7 +5,7 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
Log_SetChannel(AnalogController);
|
Log_SetChannel(AnalogController);
|
||||||
|
|
||||||
AnalogController::AnalogController(System* system) : m_system(system)
|
AnalogController::AnalogController(System* system, u32 index) : m_system(system), m_index(index)
|
||||||
{
|
{
|
||||||
m_axis_state.fill(0x80);
|
m_axis_state.fill(0x80);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ bool AnalogController::DoState(StateWrapper& sw)
|
||||||
|
|
||||||
if (old_analog_mode != m_analog_mode)
|
if (old_analog_mode != m_analog_mode)
|
||||||
{
|
{
|
||||||
m_system->GetHostInterface()->AddFormattedOSDMessage(2.0f, "Controller switched to %s mode.",
|
m_system->GetHostInterface()->AddFormattedOSDMessage(2.0f, "Controller %u switched to %s mode.", m_index + 1u,
|
||||||
m_analog_mode ? "analog" : "digital");
|
m_analog_mode ? "analog" : "digital");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,8 +90,8 @@ void AnalogController::SetButtonState(Button button, bool pressed)
|
||||||
{
|
{
|
||||||
if (m_analog_locked)
|
if (m_analog_locked)
|
||||||
{
|
{
|
||||||
m_system->GetHostInterface()->AddFormattedOSDMessage(2.0f, "Controller is locked to %s mode by the game.",
|
m_system->GetHostInterface()->AddFormattedOSDMessage(2.0f, "Controller %u is locked to %s mode by the game.",
|
||||||
m_analog_mode ? "analog" : "digital");
|
m_index + 1u, m_analog_mode ? "analog" : "digital");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -149,8 +149,8 @@ void AnalogController::SetAnalogMode(bool enabled)
|
||||||
if (m_analog_mode == enabled)
|
if (m_analog_mode == enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_InfoPrintf("Controller switched to %s mode.", enabled ? "analog" : "digital");
|
Log_InfoPrintf("Controller %u switched to %s mode.", m_index + 1u, enabled ? "analog" : "digital");
|
||||||
m_system->GetHostInterface()->AddFormattedOSDMessage(2.0f, "Controller switched to %s mode.",
|
m_system->GetHostInterface()->AddFormattedOSDMessage(2.0f, "Controller %u switched to %s mode.", m_index + 1u,
|
||||||
enabled ? "analog" : "digital");
|
enabled ? "analog" : "digital");
|
||||||
m_analog_mode = enabled;
|
m_analog_mode = enabled;
|
||||||
}
|
}
|
||||||
|
@ -393,9 +393,9 @@ bool AnalogController::Transfer(const u8 data_in, u8* data_out)
|
||||||
return ack;
|
return ack;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<AnalogController> AnalogController::Create(System* system)
|
std::unique_ptr<AnalogController> AnalogController::Create(System* system, u32 index)
|
||||||
{
|
{
|
||||||
return std::make_unique<AnalogController>(system);
|
return std::make_unique<AnalogController>(system, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<s32> AnalogController::StaticGetAxisCodeByName(std::string_view axis_name)
|
std::optional<s32> AnalogController::StaticGetAxisCodeByName(std::string_view axis_name)
|
||||||
|
|
|
@ -41,10 +41,10 @@ public:
|
||||||
|
|
||||||
static constexpr u8 NUM_MOTORS = 2;
|
static constexpr u8 NUM_MOTORS = 2;
|
||||||
|
|
||||||
AnalogController(System* system);
|
AnalogController(System* system, u32 index);
|
||||||
~AnalogController() override;
|
~AnalogController() override;
|
||||||
|
|
||||||
static std::unique_ptr<AnalogController> Create(System* system);
|
static std::unique_ptr<AnalogController> Create(System* system, u32 index);
|
||||||
static std::optional<s32> StaticGetAxisCodeByName(std::string_view axis_name);
|
static std::optional<s32> StaticGetAxisCodeByName(std::string_view axis_name);
|
||||||
static std::optional<s32> StaticGetButtonCodeByName(std::string_view button_name);
|
static std::optional<s32> StaticGetButtonCodeByName(std::string_view button_name);
|
||||||
static AxisList StaticGetAxisNames();
|
static AxisList StaticGetAxisNames();
|
||||||
|
@ -130,6 +130,7 @@ private:
|
||||||
void SetMotorState(u8 motor, u8 value);
|
void SetMotorState(u8 motor, u8 value);
|
||||||
|
|
||||||
System* m_system;
|
System* m_system;
|
||||||
|
u32 m_index;
|
||||||
|
|
||||||
bool m_analog_mode = false;
|
bool m_analog_mode = false;
|
||||||
bool m_analog_locked = false;
|
bool m_analog_locked = false;
|
||||||
|
|
|
@ -38,7 +38,7 @@ float Controller::GetVibrationMotorStrength(u32 motor)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Controller> Controller::Create(System* system, ControllerType type)
|
std::unique_ptr<Controller> Controller::Create(System* system, ControllerType type, u32 index)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ std::unique_ptr<Controller> Controller::Create(System* system, ControllerType ty
|
||||||
return DigitalController::Create();
|
return DigitalController::Create();
|
||||||
|
|
||||||
case ControllerType::AnalogController:
|
case ControllerType::AnalogController:
|
||||||
return AnalogController::Create(system);
|
return AnalogController::Create(system, index);
|
||||||
|
|
||||||
case ControllerType::NamcoGunCon:
|
case ControllerType::NamcoGunCon:
|
||||||
return NamcoGunCon::Create(system);
|
return NamcoGunCon::Create(system);
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
virtual float GetVibrationMotorStrength(u32 motor);
|
virtual float GetVibrationMotorStrength(u32 motor);
|
||||||
|
|
||||||
/// Creates a new controller of the specified type.
|
/// Creates a new controller of the specified type.
|
||||||
static std::unique_ptr<Controller> Create(System* system, ControllerType type);
|
static std::unique_ptr<Controller> Create(System* system, ControllerType type, u32 index);
|
||||||
|
|
||||||
/// Gets the integer code for an axis in the specified controller type.
|
/// Gets the integer code for an axis in the specified controller type.
|
||||||
static std::optional<s32> GetAxisCodeByName(ControllerType type, std::string_view axis_name);
|
static std::optional<s32> GetAxisCodeByName(ControllerType type, std::string_view axis_name);
|
||||||
|
|
|
@ -50,7 +50,7 @@ bool Pad::DoState(StateWrapper& sw)
|
||||||
|
|
||||||
m_controllers[i].reset();
|
m_controllers[i].reset();
|
||||||
if (state_controller_type != ControllerType::None)
|
if (state_controller_type != ControllerType::None)
|
||||||
m_controllers[i] = Controller::Create(m_system, state_controller_type);
|
m_controllers[i] = Controller::Create(m_system, state_controller_type, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_controllers[i])
|
if (m_controllers[i])
|
||||||
|
|
|
@ -787,7 +787,7 @@ void System::UpdateControllers()
|
||||||
const ControllerType type = settings.controller_types[i];
|
const ControllerType type = settings.controller_types[i];
|
||||||
if (type != ControllerType::None)
|
if (type != ControllerType::None)
|
||||||
{
|
{
|
||||||
std::unique_ptr<Controller> controller = Controller::Create(this, type);
|
std::unique_ptr<Controller> controller = Controller::Create(this, type, i);
|
||||||
if (controller)
|
if (controller)
|
||||||
m_pad->SetController(i, std::move(controller));
|
m_pad->SetController(i, std::move(controller));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue