mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 12:32:43 +00:00
MMJOYSTICK: fix nullpointer crash in GetMMJOYDevice
This commit is contained in:
parent
d13e71eeb8
commit
8b693ed7bb
@ -753,7 +753,7 @@ bool ds4_pad_handler::Init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (controllers.size() == 0)
|
if (controllers.size() == 0)
|
||||||
LOG_ERROR(HLE, "[DS4] No controllers found!");
|
LOG_WARNING(HLE, "[DS4] No controllers found!");
|
||||||
else
|
else
|
||||||
LOG_SUCCESS(HLE, "[DS4] Controllers found: %d", controllers.size());
|
LOG_SUCCESS(HLE, "[DS4] Controllers found: %d", controllers.size());
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ bool mm_joystick_handler::Init()
|
|||||||
{
|
{
|
||||||
MMJOYDevice dev;
|
MMJOYDevice dev;
|
||||||
|
|
||||||
if (GetMMJOYDevice(i, dev) == false)
|
if (GetMMJOYDevice(i, &dev) == false)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
m_devices.emplace(i, dev);
|
m_devices.emplace(i, dev);
|
||||||
@ -226,7 +226,7 @@ void mm_joystick_handler::ThreadProc()
|
|||||||
|
|
||||||
if (last_connection_status[i] == false)
|
if (last_connection_status[i] == false)
|
||||||
{
|
{
|
||||||
if (GetMMJOYDevice(m_dev->device_id, *m_dev) == false)
|
if (GetMMJOYDevice(m_dev->device_id, m_dev.get()) == false)
|
||||||
continue;
|
continue;
|
||||||
LOG_SUCCESS(HLE, "MMJOY Device %d reconnected.", m_dev->device_id);
|
LOG_SUCCESS(HLE, "MMJOY Device %d reconnected.", m_dev->device_id);
|
||||||
pad->m_port_status |= CELL_PAD_STATUS_CONNECTED;
|
pad->m_port_status |= CELL_PAD_STATUS_CONNECTED;
|
||||||
@ -558,8 +558,13 @@ int mm_joystick_handler::GetIDByName(const std::string& name)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mm_joystick_handler::GetMMJOYDevice(int index, MMJOYDevice& dev)
|
bool mm_joystick_handler::GetMMJOYDevice(int index, MMJOYDevice* dev)
|
||||||
{
|
{
|
||||||
|
if (!dev)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
JOYINFOEX js_info;
|
JOYINFOEX js_info;
|
||||||
JOYCAPS js_caps;
|
JOYCAPS js_caps;
|
||||||
js_info.dwSize = sizeof(js_info);
|
js_info.dwSize = sizeof(js_info);
|
||||||
@ -574,10 +579,10 @@ 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 = m_name_string + std::to_string(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;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ private:
|
|||||||
void TranslateButtonPress(u64 keyCode, bool& pressed, u16& val, bool ignore_threshold = false) override;
|
void TranslateButtonPress(u64 keyCode, bool& pressed, u16& val, bool ignore_threshold = false) override;
|
||||||
std::unordered_map<u64, u16> GetButtonValues(const JOYINFOEX& js_info, const JOYCAPS& js_caps);
|
std::unordered_map<u64, u16> GetButtonValues(const JOYINFOEX& js_info, const JOYCAPS& js_caps);
|
||||||
int GetIDByName(const std::string& name);
|
int GetIDByName(const std::string& name);
|
||||||
bool GetMMJOYDevice(int index, MMJOYDevice& dev);
|
bool GetMMJOYDevice(int index, MMJOYDevice* dev);
|
||||||
|
|
||||||
bool is_init = false;
|
bool is_init = false;
|
||||||
u32 m_supported_joysticks = 0;
|
u32 m_supported_joysticks = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user