Skip to content

Commit

Permalink
udev: Improve error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
garbear committed May 27, 2024
1 parent b361b9a commit b056eaf
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/api/udev/JoystickInterfaceUdev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "JoystickInterfaceUdev.h"
#include "JoystickUdev.h"
#include "api/JoystickTypes.h"
#include "log/Log.h"

#include <libudev.h>
#include <utility>
Expand Down Expand Up @@ -41,15 +42,22 @@ bool CJoystickInterfaceUdev::Initialize()
{
m_udev = udev_new();
if (!m_udev)
{
esyslog("Failed to initialize udev");
return false;
}

m_udev_mon = udev_monitor_new_from_netlink(m_udev, "udev");
if (m_udev_mon)
if (!m_udev_mon)
{
udev_monitor_filter_add_match_subsystem_devtype(m_udev_mon, "input", nullptr);
udev_monitor_enable_receiving(m_udev_mon);
esyslog("Failed to create udev monitor");
udev_unref(m_udev);
return false;
}

udev_monitor_filter_add_match_subsystem_devtype(m_udev_mon, "input", nullptr);
udev_monitor_enable_receiving(m_udev_mon);

return true;
}

Expand Down

0 comments on commit b056eaf

Please sign in to comment.