line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Linux::Inputs; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
33178216
|
use strict; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
75
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
72
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
372
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
523
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
10
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{input}; |
11
|
0
|
|
|
|
|
|
return -r '/proc/bus/input/devices'; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub doInventory { |
15
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
18
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $handle = getFileHandle( |
21
|
|
|
|
|
|
|
file => '/proc/bus/input/devices', |
22
|
|
|
|
|
|
|
logger => $logger |
23
|
|
|
|
|
|
|
); |
24
|
0
|
0
|
|
|
|
|
return unless $handle; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my @inputs; |
27
|
|
|
|
|
|
|
my $device; |
28
|
0
|
|
|
|
|
|
my $in; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
31
|
0
|
0
|
|
|
|
|
if ($line =~ /^I: Bus=.*Vendor=(.*) Prod/) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$in = 1; |
33
|
0
|
|
|
|
|
|
$device->{vendor}=$1; |
34
|
|
|
|
|
|
|
} elsif ($line =~ /^$/) { |
35
|
0
|
|
|
|
|
|
$in = 0; |
36
|
0
|
0
|
0
|
|
|
|
if ($device->{phys} && $device->{phys} =~ "input") { |
37
|
0
|
|
|
|
|
|
push @inputs, { |
38
|
|
|
|
|
|
|
DESCRIPTION => $device->{name}, |
39
|
|
|
|
|
|
|
CAPTION => $device->{name}, |
40
|
|
|
|
|
|
|
TYPE => $device->{type}, |
41
|
|
|
|
|
|
|
}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$device = {}; |
45
|
|
|
|
|
|
|
} elsif ($in) { |
46
|
0
|
0
|
|
|
|
|
if ($line =~ /^P: Phys=.*(button).*/i) { |
|
|
0
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$device->{phys}="nodev"; |
48
|
|
|
|
|
|
|
} elsif ($line =~ /^P: Phys=.*(input).*/i) { |
49
|
0
|
|
|
|
|
|
$device->{phys}="input"; |
50
|
|
|
|
|
|
|
} |
51
|
0
|
0
|
|
|
|
|
if ($line =~ /^N: Name=\"(.*)\"/i) { |
52
|
0
|
|
|
|
|
|
$device->{name}=$1; |
53
|
|
|
|
|
|
|
} |
54
|
0
|
0
|
|
|
|
|
if ($line =~ /^H: Handlers=(\w+)/i) { |
55
|
0
|
0
|
|
|
|
|
if ($1 =~ ".*kbd.*") { |
|
|
0
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$device->{type}="Keyboard"; |
57
|
|
|
|
|
|
|
} elsif ($1 =~ ".*mouse.*") { |
58
|
0
|
|
|
|
|
|
$device->{type}="Pointing"; |
59
|
|
|
|
|
|
|
} else { |
60
|
|
|
|
|
|
|
# Keyboard ou Pointing |
61
|
0
|
|
|
|
|
|
$device->{type}=$1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
0
|
|
|
|
|
|
close $handle; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
foreach my $input (@inputs) { |
69
|
0
|
|
|
|
|
|
$inventory->addEntry( |
70
|
|
|
|
|
|
|
section => 'INPUTS', |
71
|
|
|
|
|
|
|
entry => $input |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |