File: lsinput.c

package info (click to toggle)
input-utils 1.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 380 kB
  • ctags: 1,091
  • sloc: ansic: 1,900; sh: 25; makefile: 6
file content (41 lines) | stat: -rw-r--r-- 921 bytes parent folder | download | duplicates (2)
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
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

#include "input.h"

/* ------------------------------------------------------------------ */

static void list_devices(void)
{
	int i,fd;
        char filename[32];
        struct stat statbuf;

	for (i = 0; i < 32; i++) {
                snprintf(filename,sizeof(filename), "/dev/input/event%d",i);
                if (stat(filename, &statbuf) == 0) {
                        /* try to open */
                        fd = device_open(i,1);
                        if (-1 == fd)
                                return;
                        device_info(fd);
                        close(fd);
                }
	}
	return;
}

int main(int argc, char *argv[])
{
	list_devices();
	exit(0);
}

/* ---------------------------------------------------------------------
 * Local variables:
 * c-basic-offset: 8
 * End:
 */