Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/kbio.h>
- #include <err.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <string.h>
- #include <unistd.h>
- int
- main(int argc, char *argv[]) {
- //const char device[]="/dev/console";
- const char device[]="/dev/ttyv0";
- keyboard_info_t info;
- int fd;
- fd = open(device, O_RDONLY);
- if (fd < 0) {
- warn("cannot open %s", device);
- return 1;
- }
- if (ioctl(fd, KDGKBINFO, &info) == -1) {
- warn("unable to obtain keyboard information");
- close(fd);
- return 1;
- }
- printf("kbd%d: %.*s%d\n",
- info.kb_index, (int)sizeof(info.kb_name), info.kb_name,
- info.kb_unit);
- close(fd);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement