File: Inputs.pm

package info (click to toggle)
ocsinventory-agent 2%3A2.10.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,424 kB
  • sloc: perl: 26,492; xml: 773; objc: 528; sh: 386; ansic: 333; makefile: 12
file content (57 lines) | stat: -rw-r--r-- 1,445 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package Ocsinventory::Agent::Backend::OS::Linux::Inputs;

use strict;
use warnings;


sub run {

    my $params = shift;
    my $common = $params->{common};
    my $logger = $params->{logger};
    
    my $in;
    my $vendor;
    my $phys;
    my $name;
    my $type;
    
    if (open INPUTS, "</proc/bus/input/devices") {
        foreach (<INPUTS>) {
            if (/^I: Bus=.*Vendor=(.*) Prod/){
               $in=1;
               $vendor=$1;
            } elsif ($_ =~ /^$/) {
                $in=0;
                if ($phys && $phys =~ "input"){
                    $common->addInput({
                        DESCRIPTION=>$name, 
                        CAPTION=>$name,
                        TYPE=>$type
                    });
                }
            } elsif ($in) {
                if (/^P: Phys=.*(button).*/i) {
                    $phys="nodev";
                } elsif (/^P: Phys=.*(input).*/i) {
                    $phys="input";
                }
                if (/^N: Name=\"(.*)\"/i){
                    $name=$1;
                }
                if (/^H: Handlers=(\w+)/i) {
                    if ($1 =~ ".*kbd.*") {
                       $type="Keyboard";
                    } elsif ($1 =~ ".*mouse.*") {
                       $type="Pointing";
                    } else {
                       $type=$1;
                    }
                }
            }
        }
        close INPUTS;
    }
}

1;