From: Brad H. <bh...@bi...> - 2002-10-08 08:38:54
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tue, 8 Oct 2002 18:33, Vojtech Pavlik wrote: > No, but they have the "PHYS" value readable from either /dev/input/event > devices using an ioctl, or from /proc/bus/input/devices. This reflects > which connector on the USB Hub they're connected to. #include <stdlib.h> #include <stdio.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <asm/types.h> #include <fcntl.h> #include <unistd.h> #include <stdint.h> #include <linux/input.h> int main (int argc, char **argv) { int fd = -1; char phys[256]= "Unknown"; /* ioctl() requires a file descriptor, so we check we got one, and then open it */ if (argc != 2) { fprintf(stderr, "usage: %s event-device - probably /dev/input/event0\n", argv[0]); exit(1); } if ((fd = open(argv[1], O_RDONLY)) < 0) { perror("evdev open"); exit(1); } /* suck out the name information * return value is the length of the physical path, for success * or -EFAULT for failure */ if(ioctl(fd, EVIOCGPHYS(sizeof(phys)), phys) < 0) { perror("event ioctl"); } printf("The device on %s says it's physical path is %s\n", argv[1], phys); close(fd); exit(0); } Brad - -- http://linux.conf.au. 22-25Jan2003. Perth, Aust. I'm registered. Are you? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9opfSW6pHgIdAuOMRAvC0AJsGTChZT5VGaDx6pbzvBgD5wV6BNQCglr0T Ad1WtJN+Wm7GsKRZ5SGK1fM= =WWBh -----END PGP SIGNATURE----- |