From 35b3e29a230bd961e45a1e498563f323a72640f9 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 9 Jul 2007 17:17:03 +0000 Subject: - wacom configuration: o enhance configuration by using /dev/input/by-id/xxx (backport from trunk, including some functions copied from detect_devices) --- NEWS | 4 +- lib/mouse.pm | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 114 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index c08454c..5c1a04c 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ -- wacom configuration: add "pad" InputDevice section +- wacom configuration: + o enhance configuration by using /dev/input/by-id/xxx + o add "pad" InputDevice section - fix displaying "3D hardware acceleration: no" for nvidia proprietary driver (#31326) diff --git a/lib/mouse.pm b/lib/mouse.pm index 33716e8..c0fa3c3 100644 --- a/lib/mouse.pm +++ b/lib/mouse.pm @@ -239,15 +239,21 @@ sub write { } sub probe_usb_wacom_devices() { - my (@l) = detect_devices::usbWacom() or return; + detect_devices_::hasWacom() or return; #- for the special detect_devices_:: functions, see at the end of the file + + eval { modules::load("wacom", "evdev") }; + + map { + my $ID_SERIAL = chomp_(run_program::get_stdout('/lib/udev/usb_id', $_->{sysfs_path})); + my $sysfs_device = "input/by-id/usb-$ID_SERIAL-event-mouse"; #- from /etc/udev/rules.d/60-persistent-input.rules + if ($::isInstall || -e "/dev/$sysfs_device") { + $sysfs_device; + } else { + log::l("$sysfs_device missing"); + (); + } + } detect_devices_::usbWacom(); #- for the special detect_devices_:: functions, see at the end of the file - log::l("found usb wacom $_->{driver} $_->{description} ($_->{type})") foreach @l; - my @wacom = eval { - modules::load("wacom", "evdev"); - grep { detect_devices::tryOpen($_) } map_index { "input/event$::i" } @l; - }; - @wacom or eval { modules::unload("evdev", "wacom") }; - @wacom; } sub detect_serial() { @@ -676,3 +682,100 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. =cut + + +#- functions copied to avoid the need to update drakxtools-backend +package detect_devices_; + +use common; + +sub hasWacom() { find { $_->{vendor} == 0x056a || $_->{driver} =~ /wacom/ } detect_devices::usb_probe() } +sub usbWacom() { grep { $_->{vendor} eq '056a' } getInputDevices() } + +sub getInputDevices() { + my (@devices, $device); + foreach (cat_('/proc/bus/input/devices')) { + if (/^I:/) { + $device = {}; + $device->{vendor} = /Vendor=(\w+)/ && $1; + $device->{id} = /Product=(\w+)/ && $1; + } elsif (/N: Name="(.*)"/) { + my $descr = $1; + $device->{description} = "|$descr"; + + #- I: Bus=0011 Vendor=0002 Product=0008 Version=7321 + #- N: Name="AlpsPS/2 ALPS GlidePoint" + #- P: Phys=isa0060/serio1/input0 + #- H: Handlers=mouse1 event2 ts1 + #- B: EV=f + #- B: KEY=420 0 70000 0 0 0 0 0 0 0 0 #=> BTN_LEFT BTN_RIGHT BTN_MIDDLE BTN_TOOL_FINGER BTN_TOUCH + #- or B: KEY=420 0 670000 0 0 0 0 0 0 0 0 #=> same with BTN_BACK + #- B: REL=3 #=> X Y + #- B: ABS=1000003 #=> X Y PRESSURE + + #- I: Bus=0011 Vendor=0002 Product=0008 Version=2222 + #- N: Name="AlpsPS/2 ALPS DualPoint TouchPad" + #- P: Phys=isa0060/serio1/input0 + #- S: Sysfs=/class/input/input2 + #- H: Handlers=mouse1 ts1 event2 + #- B: EV=f + #- B: KEY=420 0 70000 0 0 0 0 0 0 0 0 + #- B: REL=3 + #- B: ABS=1000003 + + #- I: Bus=0011 Vendor=0002 Product=0007 Version=0000 + #- N: Name="SynPS/2 Synaptics TouchPad" + #- P: Phys=isa0060/serio1/input0 + #- S: Sysfs=/class/input/input1 + #- H: Handlers=mouse0 event1 ts0 + #- B: EV=b + #- B: KEY=6420 0 70000 0 0 0 0 0 0 0 0 #=> BTN_LEFT BTN_RIGHT BTN_MIDDLE BTN_TOOL_FINGER BTN_TOUCH BTN_TOOL_DOUBLETAP BTN_TOOL_TRIPLETAP + #- or B: KEY=6420 0 670000 0 0 0 0 0 0 0 0 #=> same with BTN_BACK + #- or B: KEY=420 30000 670000 0 0 0 0 0 0 0 0 #=> same without BTN_TOOL_TRIPLETAP but with BTN_B + #- B: ABS=11000003 #=> X Y PRESSURE TOOL_WIDTH + + #- KEY=1c63 0 70033 0 0 0 0 0 0 0 0 #=> BTN_0 BTN_1 BTN_4 BTN_5 BTN_LEFT BTN_RIGHT BTN_MIDDLE TOOL_PEN TOOL_RUBBER TOOL_BRUSH TOOL_FINGER TOOL_MOUSE TOUCH STYLUS STYLUS2 + #- ABS=100 3000103 #=> X Y WHEEL PRESSURE DISTANCE MISC + + #- KEY=1c43 0 70000 0 0 0 0 0 0 0 0 #=> BTN_LEFT BTN_RIGHT BTN_MIDDLE TOOL_PEN TOOL_RUBBER TOOL_FINGER TOOL_MOUSE TOUCH STYLUS STYLUS2 + #- ABS=100 3000003 #=> X Y PRESSURE DISTANCE MISC + + $device->{Synaptics} = $descr eq 'SynPS/2 Synaptics TouchPad'; + $device->{ALPS} = $descr =~ m!^AlpsPS/2 ALPS!; + + } elsif (/H: Handlers=(.*)/) { + my @l = split(' ', $1); + $device->{driver} = $l[0]; #- keep it for compatibility + $device->{Handlers} = +{ map { (/^(.*?)\d*$/ ? $1 : $_, $_) } split(' ', $1) }; + } elsif (/S: Sysfs=(.+)/) { + $device->{sysfs_path} = $1; + } elsif (/P: Phys=(.*)/) { + $device->{location} = $1; + $device->{bus} = 'isa' if $device->{location} =~ /^isa/; + $device->{bus} = 'usb' if $device->{location} =~ /^usb/i; + } elsif (/B: REL=(.* )?(.*)/) { + #- REL=3 #=> X Y + #- REL=103 #=> X Y WHEEL + #- REL=143 #=> X Y HWHEEL WHEEL + #- REL=1c3 #=> X Y HWHEEL DIAL WHEEL + my $REL = hex($2); + $device->{HWHEEL} = 1 if $REL & (1 << 6); + $device->{WHEEL} = 1 if $REL & (1 << 8); #- not reliable ("Mitsumi Apple USB Mouse" says REL=103 and KEY=1f0000 ...) + + } elsif (/B: KEY=(\S+)/) { + #- some KEY explained: + #- (but note that BTN_MIDDLE can be reported even if missing) + #- (and "Mitsumi Apple USB Mouse" reports 1f0000) + #- KEY=30000 0 0 0 0 0 0 0 0 #=> BTN_LEFT BTN_RIGHT + #- KEY=70000 0 0 0 0 0 0 0 0 #=> BTN_LEFT BTN_RIGHT BTN_MIDDLE + #- KEY=1f0000 0 0 0 0 0 0 0 0 #=> BTN_LEFT BTN_RIGHT BTN_MIDDLE BTN_SIDE BTN_EXTRA + my $KEY = hex($1); + $device->{SIDE} = 1 if $KEY & (1 << 0x13); + + } elsif (/^\s*$/) { + push @devices, $device if $device; + undef $device; + } + } + @devices; +} -- cgit v1.2.1