mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 14:01:25 +12:00
Qt/Input: use name_string instead of hard coded strings
hopefully prevents any more need for fixups like this lol + tend to some warnings for rebase
This commit is contained in:
parent
d6c4d8eec0
commit
7aa1707c2c
8 changed files with 24 additions and 7 deletions
|
@ -248,6 +248,11 @@ std::tuple<u16, u16> PadHandlerBase::ConvertToSquirclePoint(u16 inX, u16 inY, in
|
||||||
return std::tuple<u16, u16>(newX, newY);
|
return std::tuple<u16, u16>(newX, newY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string PadHandlerBase::name_string()
|
||||||
|
{
|
||||||
|
return m_name_string;
|
||||||
|
}
|
||||||
|
|
||||||
int PadHandlerBase::max_devices()
|
int PadHandlerBase::max_devices()
|
||||||
{
|
{
|
||||||
return m_max_devices;
|
return m_max_devices;
|
||||||
|
|
|
@ -363,6 +363,7 @@ protected:
|
||||||
|
|
||||||
std::array<bool, MAX_GAMEPADS> last_connection_status{{ false, false, false, false, false, false, false }};
|
std::array<bool, MAX_GAMEPADS> last_connection_status{{ false, false, false, false, false, false, false }};
|
||||||
|
|
||||||
|
std::string m_name_string;
|
||||||
int m_max_devices = 0;
|
int m_max_devices = 0;
|
||||||
int m_trigger_threshold = 0;
|
int m_trigger_threshold = 0;
|
||||||
int m_thumb_threshold = 0;
|
int m_thumb_threshold = 0;
|
||||||
|
@ -436,6 +437,7 @@ public:
|
||||||
|
|
||||||
pad_handler m_type = pad_handler::null;
|
pad_handler m_type = pad_handler::null;
|
||||||
|
|
||||||
|
std::string name_string();
|
||||||
int max_devices();
|
int max_devices();
|
||||||
bool has_config();
|
bool has_config();
|
||||||
bool has_rumble();
|
bool has_rumble();
|
||||||
|
|
|
@ -96,6 +96,8 @@ ds4_pad_handler::ds4_pad_handler() : PadHandlerBase(pad_handler::ds4)
|
||||||
b_has_rumble = true;
|
b_has_rumble = true;
|
||||||
b_has_deadzones = true;
|
b_has_deadzones = true;
|
||||||
|
|
||||||
|
m_name_string = "Ds4 Pad #";
|
||||||
|
|
||||||
m_trigger_threshold = trigger_max / 2;
|
m_trigger_threshold = trigger_max / 2;
|
||||||
m_thumb_threshold = thumb_max / 2;
|
m_thumb_threshold = thumb_max / 2;
|
||||||
}
|
}
|
||||||
|
@ -252,7 +254,7 @@ std::shared_ptr<ds4_pad_handler::DS4Device> ds4_pad_handler::GetDevice(const std
|
||||||
if (!Init())
|
if (!Init())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
size_t pos = padId.find("Ds4 Pad #");
|
size_t pos = padId.find(m_name_string);
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -768,7 +770,7 @@ std::vector<std::string> ds4_pad_handler::ListDevices()
|
||||||
|
|
||||||
for (auto& pad : controllers)
|
for (auto& pad : controllers)
|
||||||
{
|
{
|
||||||
ds4_pads_list.emplace_back("Ds4 Pad #" + pad.first);
|
ds4_pads_list.emplace_back(m_name_string + pad.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ds4_pads_list;
|
return ds4_pads_list;
|
||||||
|
|
|
@ -18,6 +18,8 @@ mm_joystick_handler::mm_joystick_handler() : PadHandlerBase(pad_handler::mm)
|
||||||
b_has_rumble = true;
|
b_has_rumble = true;
|
||||||
b_has_deadzones = true;
|
b_has_deadzones = true;
|
||||||
|
|
||||||
|
m_name_string = "Joystick #";
|
||||||
|
|
||||||
m_trigger_threshold = trigger_max / 2;
|
m_trigger_threshold = trigger_max / 2;
|
||||||
m_thumb_threshold = thumb_max / 2;
|
m_thumb_threshold = thumb_max / 2;
|
||||||
}
|
}
|
||||||
|
@ -573,7 +575,7 @@ bool mm_joystick_handler::GetMMJOYDevice(int index, MMJOYDevice& dev)
|
||||||
LOG_NOTICE(GENERAL, "Joystick nr.%d found. Driver: %s", index, drv);
|
LOG_NOTICE(GENERAL, "Joystick nr.%d found. Driver: %s", index, drv);
|
||||||
|
|
||||||
dev.device_id = index;
|
dev.device_id = index;
|
||||||
dev.device_name = fmt::format("Joystick #%d", index);
|
dev.device_name = m_name_string + std::to_string(index);
|
||||||
dev.device_info = js_info;
|
dev.device_info = js_info;
|
||||||
dev.device_caps = js_caps;
|
dev.device_caps = js_caps;
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,8 @@ void pad_thread::Init(const u32 max_connect)
|
||||||
cur_pad_handler = std::make_shared<evdev_joystick_handler>();
|
cur_pad_handler = std::make_shared<evdev_joystick_handler>();
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
handlers.emplace(handler_type, cur_pad_handler);
|
handlers.emplace(handler_type, cur_pad_handler);
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,11 +331,14 @@ void gamepads_settings_dialog::ChangeInputType(int player)
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
case pad_handler::xinput:
|
case pad_handler::xinput:
|
||||||
|
{
|
||||||
|
QString name_string = qstr(cur_pad_handler->name_string());
|
||||||
for (int i = 0; i < cur_pad_handler->max_devices(); i++)
|
for (int i = 0; i < cur_pad_handler->max_devices(); i++)
|
||||||
{
|
{
|
||||||
co_deviceID[player]->addItem(QString("XInput Pad #%1").arg(i), i);
|
co_deviceID[player]->addItem(name_string + QString::number(i), i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
for (int i = 0; i < list_devices.size(); i++)
|
for (int i = 0; i < list_devices.size(); i++)
|
||||||
|
|
|
@ -32,7 +32,7 @@ Q_SIGNALS:
|
||||||
void LogFrameClosed();
|
void LogFrameClosed();
|
||||||
protected:
|
protected:
|
||||||
/** Override inherited method from Qt to allow signalling when close happened.*/
|
/** Override inherited method from Qt to allow signalling when close happened.*/
|
||||||
void closeEvent(QCloseEvent* event);
|
void closeEvent(QCloseEvent* event) override;
|
||||||
bool eventFilter(QObject* object, QEvent* event) override;
|
bool eventFilter(QObject* object, QEvent* event) override;
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void UpdateUI();
|
void UpdateUI();
|
||||||
|
|
|
@ -19,6 +19,7 @@ xinput_pad_handler::xinput_pad_handler() : PadHandlerBase(pad_handler::xinput)
|
||||||
b_has_rumble = true;
|
b_has_rumble = true;
|
||||||
b_has_deadzones = true;
|
b_has_deadzones = true;
|
||||||
|
|
||||||
|
m_name_string = "XInput Pad #";
|
||||||
m_max_devices = XUSER_MAX_COUNT;
|
m_max_devices = XUSER_MAX_COUNT;
|
||||||
|
|
||||||
m_trigger_threshold = trigger_max / 2;
|
m_trigger_threshold = trigger_max / 2;
|
||||||
|
@ -192,7 +193,7 @@ int xinput_pad_handler::GetDeviceNumber(const std::string& padId)
|
||||||
if (!Init())
|
if (!Init())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
size_t pos = padId.find("Xinput Pad #");
|
size_t pos = padId.find(m_name_string);
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -453,7 +454,7 @@ std::vector<std::string> xinput_pad_handler::ListDevices()
|
||||||
XINPUT_STATE state;
|
XINPUT_STATE state;
|
||||||
DWORD result = (*xinputGetState)(i, &state);
|
DWORD result = (*xinputGetState)(i, &state);
|
||||||
if (result == ERROR_SUCCESS)
|
if (result == ERROR_SUCCESS)
|
||||||
xinput_pads_list.push_back(fmt::format("XInput Pad #%d", i));
|
xinput_pads_list.push_back(m_name_string + std::to_string(i));
|
||||||
}
|
}
|
||||||
return xinput_pads_list;
|
return xinput_pads_list;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue