summaryrefslogtreecommitdiffstats
path: root/perl-install/detect_devices.pm
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-11-07 16:22:34 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-11-07 16:22:34 +0000
commit0f6426ea21fc3d00b7002e706feb1690fc1c67a8 (patch)
tree51693c8441f4ea08af88c3a6d4f6269e36c2d1d0 /perl-install/detect_devices.pm
parent205207c98ab68f83ef61bf77e36ed9bb11914b3b (diff)
downloaddrakx-0f6426ea21fc3d00b7002e706feb1690fc1c67a8.tar
drakx-0f6426ea21fc3d00b7002e706feb1690fc1c67a8.tar.gz
drakx-0f6426ea21fc3d00b7002e706feb1690fc1c67a8.tar.bz2
drakx-0f6426ea21fc3d00b7002e706feb1690fc1c67a8.tar.xz
drakx-0f6426ea21fc3d00b7002e706feb1690fc1c67a8.zip
(getUPS) return port/description couples
Diffstat (limited to 'perl-install/detect_devices.pm')
-rw-r--r--perl-install/detect_devices.pm21
1 files changed, 20 insertions, 1 deletions
diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm
index 11115cc35..a864a1db6 100644
--- a/perl-install/detect_devices.pm
+++ b/perl-install/detect_devices.pm
@@ -429,8 +429,27 @@ sub getNet() {
# mapgrep(sub {member (($_[0] =~ /\s*(\w*):/), @netdevices), $1 }, split(/\n/, cat_("/proc/net/dev")));
#}
+# heavily inspirated from hidups driver from nut:
sub getUPS() {
- grep { $_->{description} =~ /Ellipse UPS/ } usb_probe()
+ # nut/driver/hidups.h:
+ my $UPS_USAGE = 0x840004;
+ my $POWER_USAGE = 0x840020;
+ my $hiddev_find_application = sub {
+ my ($fd, $usage) = @_;
+ my ($i, $ret) = 0;
+ # HIDIOCAPPLICATION from /usr/include/linux/hiddev.h:
+ do { $i++ } while ($ret = ioctl($fd, 0x4802, $i)) && $ret != $usage;
+ return $ret == $usage ? 1 : 0;
+ };
+
+ map {
+ open(my $f, $_);
+ if_(!$hiddev_find_application->($f, $UPS_USAGE) && !$hiddev_find_application->($f, $POWER_USAGE),
+ { port => $_,
+ name => c::get_usb_ups_name(fileno($f))
+ }
+ );
+ } -e "/dev/.devfsd" ? glob("/dev/usb/hid/hiddev*") : glob("/dev/usb/hiddev*");
}
$pcitable_addons = <<'EOF';