From 941ff16f3ed9a9a8bef8f23e813ab3d0d5c0a0ea Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke <grumbel@gmx.de> Date: Wed, 26 Jan 2011 04:32:30 +0100 Subject: [PATCH] Some minor cleanup, added manual filtering for devtype == usb_device --- src/controller_match_rule.cpp | 6 +++--- src/controller_match_rule.hpp | 6 +++--- src/options.cpp | 6 +++--- src/xboxdrv_daemon.cpp | 15 +++++++++------ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/controller_match_rule.cpp b/src/controller_match_rule.cpp index aab5e9f..cea7a0b 100644 --- a/src/controller_match_rule.cpp +++ b/src/controller_match_rule.cpp @@ -46,7 +46,7 @@ ControllerMatchRule::match(int vendor, int product, } ControllerMatchRule -ControllerMatchRule::match_usb_id(int vendor, int product) +ControllerMatchRule::create_usb_id(int vendor, int product) { ControllerMatchRule rule; rule.m_type = kMatchUSBId; @@ -56,7 +56,7 @@ ControllerMatchRule::match_usb_id(int vendor, int product) } ControllerMatchRule -ControllerMatchRule::match_usb_path(int bus, int dev) +ControllerMatchRule::create_usb_path(int bus, int dev) { ControllerMatchRule rule; rule.m_type = kMatchUSBPath; @@ -66,7 +66,7 @@ ControllerMatchRule::match_usb_path(int bus, int dev) } ControllerMatchRule -ControllerMatchRule::match_evdev_path(const std::string& path) +ControllerMatchRule::create_evdev_path(const std::string& path) { ControllerMatchRule rule; rule.m_type = kMatchEvdevPath; diff --git a/src/controller_match_rule.hpp b/src/controller_match_rule.hpp index 5594eeb..8fe5829 100644 --- a/src/controller_match_rule.hpp +++ b/src/controller_match_rule.hpp @@ -51,9 +51,9 @@ public: bool match(int vendor, int product, int bus, int dev) const; - static ControllerMatchRule match_usb_id(int vendor, int product); - static ControllerMatchRule match_usb_path(int bus, int dev); - static ControllerMatchRule match_evdev_path(const std::string& path); + static ControllerMatchRule create_usb_id(int vendor, int product); + static ControllerMatchRule create_usb_path(int bus, int dev); + static ControllerMatchRule create_evdev_path(const std::string& path); }; #endif diff --git a/src/options.cpp b/src/options.cpp index e4008f8..6043daf 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -216,7 +216,7 @@ Options::add_match(const std::string& lhs, const std::string& rhs) { int vendor = hexstr2int(args[0]); int product = hexstr2int(args[1]); - get_controller_slot().add_match_rule(ControllerMatchRule::match_usb_id(vendor, product)); + get_controller_slot().add_match_rule(ControllerMatchRule::create_usb_id(vendor, product)); } } else if (lhs == "usbpath") @@ -229,7 +229,7 @@ Options::add_match(const std::string& lhs, const std::string& rhs) { int bus = boost::lexical_cast<int>(args[0]); int dev = boost::lexical_cast<int>(args[1]); - get_controller_slot().add_match_rule(ControllerMatchRule::match_usb_path(bus, dev)); + get_controller_slot().add_match_rule(ControllerMatchRule::create_usb_path(bus, dev)); } } else if (lhs == "evdev") @@ -240,7 +240,7 @@ Options::add_match(const std::string& lhs, const std::string& rhs) } else { - get_controller_slot().add_match_rule(ControllerMatchRule::match_evdev_path(args[0])); + get_controller_slot().add_match_rule(ControllerMatchRule::create_evdev_path(args[0])); } } else diff --git a/src/xboxdrv_daemon.cpp b/src/xboxdrv_daemon.cpp index d1ccd7a..5497f83 100644 --- a/src/xboxdrv_daemon.cpp +++ b/src/xboxdrv_daemon.cpp @@ -138,7 +138,7 @@ XboxdrvDaemon::cleanup_threads() void XboxdrvDaemon::process_match(const Options& opts, struct udev_device* device) { - if (true) + if (false) { print_info(device); } @@ -277,13 +277,16 @@ XboxdrvDaemon::init_udev_monitor(const Options& opts) udev_list_entry_foreach(dev_list_entry, devices) { // name is path, value is NULL - const char* path = udev_list_entry_get_name(dev_list_entry) ; - //const char* value = udev_list_entry_get_value(dev_list_entry); - - //std::cout << "Enum: " << path << std::endl; + const char* path = udev_list_entry_get_name(dev_list_entry); struct udev_device* device = udev_device_new_from_syspath(m_udev, path); - process_match(opts, device); + + // manually filter for devtype, as udev enumerate can't do it by itself + const char* devtype = udev_device_get_devtype(device); + if (devtype && strcmp(devtype, "usb_device") == 0) + { + process_match(opts, device); + } udev_device_unref(device); } udev_enumerate_unref(enumerate);