AnalogController: Show controller number in OSD messages
This commit is contained in:
parent
95468901f2
commit
9539ce032b
|
@ -5,7 +5,7 @@
|
|||
#include "system.h"
|
||||
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);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ bool AnalogController::DoState(StateWrapper& sw)
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
@ -90,8 +90,8 @@ void AnalogController::SetButtonState(Button button, bool pressed)
|
|||
{
|
||||
if (m_analog_locked)
|
||||
{
|
||||
m_system->GetHostInterface()->AddFormattedOSDMessage(2.0f, "Controller is locked to %s mode by the game.",
|
||||
m_analog_mode ? "analog" : "digital");
|
||||
m_system->GetHostInterface()->AddFormattedOSDMessage(2.0f, "Controller %u is locked to %s mode by the game.",
|
||||
m_index + 1u, m_analog_mode ? "analog" : "digital");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -149,8 +149,8 @@ void AnalogController::SetAnalogMode(bool enabled)
|
|||
if (m_analog_mode == enabled)
|
||||
return;
|
||||
|
||||
Log_InfoPrintf("Controller switched to %s mode.", enabled ? "analog" : "digital");
|
||||
m_system->GetHostInterface()->AddFormattedOSDMessage(2.0f, "Controller switched to %s mode.",
|
||||
Log_InfoPrintf("Controller %u switched to %s mode.", m_index + 1u, enabled ? "analog" : "digital");
|
||||
m_system->GetHostInterface()->AddFormattedOSDMessage(2.0f, "Controller %u switched to %s mode.", m_index + 1u,
|
||||
enabled ? "analog" : "digital");
|
||||
m_analog_mode = enabled;
|
||||
}
|
||||
|
@ -393,9 +393,9 @@ bool AnalogController::Transfer(const u8 data_in, u8* data_out)
|
|||
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)
|
||||
|
|
|
@ -41,10 +41,10 @@ public:
|
|||
|
||||
static constexpr u8 NUM_MOTORS = 2;
|
||||
|
||||
AnalogController(System* system);
|
||||
AnalogController(System* system, u32 index);
|
||||
~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> StaticGetButtonCodeByName(std::string_view button_name);
|
||||
static AxisList StaticGetAxisNames();
|
||||
|
@ -130,6 +130,7 @@ private:
|
|||
void SetMotorState(u8 motor, u8 value);
|
||||
|
||||
System* m_system;
|
||||
u32 m_index;
|
||||
|
||||
bool m_analog_mode = false;
|
||||
bool m_analog_locked = false;
|
||||
|
|
|
@ -38,7 +38,7 @@ float Controller::GetVibrationMotorStrength(u32 motor)
|
|||
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)
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ std::unique_ptr<Controller> Controller::Create(System* system, ControllerType ty
|
|||
return DigitalController::Create();
|
||||
|
||||
case ControllerType::AnalogController:
|
||||
return AnalogController::Create(system);
|
||||
return AnalogController::Create(system, index);
|
||||
|
||||
case ControllerType::NamcoGunCon:
|
||||
return NamcoGunCon::Create(system);
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
virtual float GetVibrationMotorStrength(u32 motor);
|
||||
|
||||
/// 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.
|
||||
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();
|
||||
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])
|
||||
|
|
|
@ -787,7 +787,7 @@ void System::UpdateControllers()
|
|||
const ControllerType type = settings.controller_types[i];
|
||||
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)
|
||||
m_pad->SetController(i, std::move(controller));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue