Some minor cleanup, added manual filtering for devtype == usb_device

This commit is contained in:
Ingo Ruhnke 2011-01-26 04:32:30 +01:00
parent c7b7342716
commit 941ff16f3e
4 changed files with 18 additions and 15 deletions

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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);