mmjoy: fix connection update spam

This commit is contained in:
Megamouse 2019-10-04 15:26:42 +02:00
parent df5af50866
commit f7ec679242
2 changed files with 7 additions and 3 deletions

View File

@ -440,7 +440,8 @@ bool mm_joystick_handler::GetMMJOYDevice(int index, MMJOYDevice* dev)
js_info.dwFlags = JOY_RETURNALL;
joyGetDevCaps(index, &js_caps, sizeof(js_caps));
if (joyGetPosEx(index, &js_info) != JOYERR_NOERROR)
dev->device_status = joyGetPosEx(index, &js_info);
if (dev->device_status != JOYERR_NOERROR)
return false;
char drv[32];
@ -495,8 +496,10 @@ PadHandlerBase::connection mm_joystick_handler::update_connection(const std::sha
if (!dev)
return connection::disconnected;
MMRESULT status = joyGetPosEx(dev->device_id, &dev->device_info);
if (status == JOYERR_NOERROR && GetMMJOYDevice(dev->device_id, dev.get()))
const auto old_status = dev->device_status;
dev->device_status = joyGetPosEx(dev->device_id, &dev->device_info);
if (dev->device_status == JOYERR_NOERROR && (old_status == JOYERR_NOERROR || GetMMJOYDevice(dev->device_id, dev.get())))
{
return connection::connected;
}

View File

@ -92,6 +92,7 @@ class mm_joystick_handler final : public PadHandlerBase
std::string device_name{ "" };
JOYINFOEX device_info{};
JOYCAPS device_caps{};
MMRESULT device_status = JOYERR_UNPLUGGED;
u64 trigger_left = 0;
u64 trigger_right = 0;
std::vector<u64> axis_left = { 0,0,0,0 };