Advertisement
Guest User

conowner

a guest
Oct 31st, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <sys/kbio.h>
  2. #include <err.h>
  3. #include <fcntl.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <unistd.h>
  7.  
  8. int
  9. main(int argc, char *argv[]) {
  10.  
  11. //const char device[]="/dev/console";
  12. const char device[]="/dev/ttyv0";
  13. keyboard_info_t info;
  14. int fd;
  15.  
  16. fd = open(device, O_RDONLY);
  17. if (fd < 0) {
  18. warn("cannot open %s", device);
  19. return 1;
  20. }
  21. if (ioctl(fd, KDGKBINFO, &info) == -1) {
  22. warn("unable to obtain keyboard information");
  23. close(fd);
  24. return 1;
  25. }
  26.  
  27. printf("kbd%d: %.*s%d\n",
  28. info.kb_index, (int)sizeof(info.kb_name), info.kb_name,
  29. info.kb_unit);
  30.  
  31. close(fd);
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement