Input/Qt: Check if gui callbacks are nullptr

This commit is contained in:
Megamouse 2020-07-04 13:18:45 +02:00
parent ea4cc0b395
commit f1b1c9053c
3 changed files with 47 additions and 18 deletions

View file

@ -281,7 +281,11 @@ void evdev_joystick_handler::get_next_button_press(const std::string& padId, con
// Get our evdev device
auto device = get_evdev_device(padId);
if (!device || device->device == nullptr)
return fail_callback(padId);
{
if (fail_callback)
fail_callback(padId);
return;
}
libevdev* dev = device->device;
// Try to query the latest event from the joystick.
@ -320,7 +324,11 @@ void evdev_joystick_handler::get_next_button_press(const std::string& padId, con
// return if nothing new has happened. ignore this to get the current state for blacklist
if (!get_blacklist && ret < 0)
return callback(0, "", padId, 0, preview_values);
{
if (callback)
callback(0, "", padId, 0, preview_values);
return;
}
std::pair<u16, std::string> pressed_button = { 0, "" };
@ -401,10 +409,13 @@ void evdev_joystick_handler::get_next_button_press(const std::string& padId, con
return;
}
if (pressed_button.first > 0)
return callback(pressed_button.first, pressed_button.second, padId, 0, preview_values);
else
return callback(0, "", padId, 0, preview_values);
if (callback)
{
if (pressed_button.first > 0)
return callback(pressed_button.first, pressed_button.second, padId, 0, preview_values);
else
return callback(0, "", padId, 0, preview_values);
}
}
// https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp