3 # Input - a single device from the input layer
4 # Copyright (C) 2005 Erik van Konijnenburg
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # info - info provided by low level driver for module matching
21 # name - provided by driver
22 # phys - provided by driver, no relation to sysfs location
23 # handlers - input layer handlers
24 # capabilities - kind of events that can be generated
27 # Handler 'kbd' indicates the device is used for console;
28 # there is also a generic handler for each device, event\d+,
29 # that may have a link to underlying sysfs device.
30 # Capability KEY indicates there are buttons, this includes
31 # both qwerty keys and the fire button on a joystick.
44 $self->takeArgs ('info', 'name', 'phys', 'handlers', 'capabilities');
47 # Find hardware link, if any.
50 for my $handler (keys %{$self->handlers}) {
51 if ($handler !~ /^event\d+$/) {
54 my $devLink = Conf::get('sysFs')
55 . "/class/input/$handler/device";
56 my $hw = readlink ($devLink);
58 unless ($hw =~ s!^(\.\./)+devices/!!) {
59 # imagine localised linux (/sys/geraete ...)
60 Base::fatal ("bad device link in $devLink");
67 sub info { return $_[0]->{info}; }
68 sub name { return $_[0]->{name}; }
69 sub phys { return $_[0]->{phys}; }
70 sub handlers { return $_[0]->{handlers}; }
71 sub capabilities { return $_[0]->{capabilities}; }
72 sub hw { return $_[0]->{hw}; }
76 my $name = $self->name;
77 my $phys = $self->phys;
79 $hw = "--" unless defined $hw;
80 my $h = join (",", keys %{$self->handlers});
81 my $c = join (",", keys %{$self->capabilities});
82 my $kbd = $self->isKbd ? " (KBD)" : "";
83 my $str = "$name is $phys at $hw [$h] [$c]$kbd";
88 # isKbd -- device may be useful to get an operational keyboard.
89 # This is conservative: there are two input devices for a DELL USB
90 # keyboard for example, and we make no effort to determine if
91 # we can leave one of them out.
95 if (! exists ($self->capabilities->{KEY})) {
98 if (! exists ($self->handlers->{kbd})) {