From 21528c3e7280241cf8566b7602bb3dcd16f986d8 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Tue, 7 Jan 2020 12:46:24 +1300 Subject: [PATCH 1/2] Document the evdev "interesting" heuristic Was checking over this old code, and saw a comment calling me out for a lack of documentation. It might be half a decade late, but better late then never. --- .../ControllerInterface/evdev/evdev.cpp | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 824e5ef0c1..3f653f3d60 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -410,8 +410,39 @@ evdevDevice::evdevDevice(const std::string& devnode) : m_devfile(devnode) // TODO: Add leds as output devices - // Was there some reasoning behind these numbers? + // Filter out interesting devices (see description below) m_interesting = num_motion_axis != 0 || num_axis >= 2 || num_buttons >= 8; + + // On modern linux systems, there are a lot of event devices that aren't controllers. + // For example, the PC Speaker is an event device. Webcams sometimes show up as + // event devices. The power button is an event device. + + // We don't want these showing up in the list of controllers, so we use this + // heuristic to filter out anything that doesn't smell like a controller: + // + // More than two analog axis: + // Most controllers have at least one stick. This rule will catch all such + // controllers, while ignoring anything with a single axis (like the mouse + // scroll-wheel) + // + // --- OR --- + // + // More than 8 buttons: + // The user might be using a digital only pad such as a NES controller. + // This rule caches such controllers, while eliminating any device with + // only a few buttons, like the power button. Sometimes laptops have devices + // with 5 or 6 special buttons, which is why the threshold is set to 8 to + // match a NES controller. + // + // --- OR --- + // + // Any Motion Axis: + // This rule is to catch any theoretical motion controllers with only a few + // buttons that the user might want to use as a controller. + // + // This heuristic is quite loose. The user may still see weird devices showing up + // as controllers, but it hopefully shouldn't filter out anything they actually + // want to use. } evdevDevice::~evdevDevice() From a8c33f4ef60c97dfaedddad206971bfa463f7c8d Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Tue, 7 Jan 2020 12:52:05 +1300 Subject: [PATCH 2/2] Fix trailing whitespace --- .../ControllerInterface/evdev/evdev.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 3f653f3d60..d6a2f7224f 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -412,17 +412,17 @@ evdevDevice::evdevDevice(const std::string& devnode) : m_devfile(devnode) // Filter out interesting devices (see description below) m_interesting = num_motion_axis != 0 || num_axis >= 2 || num_buttons >= 8; - + // On modern linux systems, there are a lot of event devices that aren't controllers. // For example, the PC Speaker is an event device. Webcams sometimes show up as // event devices. The power button is an event device. - + // // We don't want these showing up in the list of controllers, so we use this // heuristic to filter out anything that doesn't smell like a controller: // - // More than two analog axis: + // More than two analog axis: // Most controllers have at least one stick. This rule will catch all such - // controllers, while ignoring anything with a single axis (like the mouse + // controllers, while ignoring anything with a single axis (like the mouse // scroll-wheel) // // --- OR --- @@ -433,16 +433,16 @@ evdevDevice::evdevDevice(const std::string& devnode) : m_devfile(devnode) // only a few buttons, like the power button. Sometimes laptops have devices // with 5 or 6 special buttons, which is why the threshold is set to 8 to // match a NES controller. - // + // // --- OR --- // // Any Motion Axis: // This rule is to catch any theoretical motion controllers with only a few - // buttons that the user might want to use as a controller. + // buttons that the user might want to use as a controller. // // This heuristic is quite loose. The user may still see weird devices showing up // as controllers, but it hopefully shouldn't filter out anything they actually - // want to use. + // want to use. } evdevDevice::~evdevDevice()