Public bug reported: 1.) when i run the program, i get always "0" for CAPS LOCK LED status in ubuntu 9.04 2.6.28-15 generic. i toggled caps lock on-off and program gives "0".
2.) The code works in ubuntu 8.04 2.6.24-16 and other 8.04 releases. #include <stdio.h> #include <fcntl.h> #include <sys/stat.h> #include <linux/kd.h> /* Keyboard IOCTLs */ #include <sys/ioctl.h> /* ioctl() */ #include <sys/types.h> #define ERROR -1 int fd; /* Console fd (/dev/tty). Used as fd in ioctl() */ long int arg; /* Where the LED states will be put into. */ void checkleds(); void main() { /* To use as the fd in ioctl(). */ if ((fd = open("/dev/console", O_NOCTTY)) == ERROR) { perror("open"); exit(ERROR); } /* Value stored in arg. */ if (ioctl(fd, KDGETLED, &arg) == ERROR) { perror("ioctl"); close(fd); exit(ERROR); } /* Here we print out current LEDS. */ checkleds(); } void checkleds() { /* LED_SCR = 0x1, LED_NUM = 0x2, LED_CAP = 0x4 */ if (arg == LED_SCR) printf("Scroll Lock LED is on.\n"); else if (arg == LED_NUM) printf("Numeric Lock LED is on.\n"); else if (arg == LED_CAP) printf("Caps Lock LED is on.\n"); else if (arg == LED_NUM + LED_CAP) printf("Numeric Lock and Caps Lock LEDs are on.\n"); else if (arg == LED_NUM + LED_SCR) printf("Numeric Lock and Scroll Lock LEDs are on.\n"); else if (arg == LED_CAP + LED_SCR) printf("Caps Lock and Scroll Lock LEDs are on.\n"); else if (arg == LED_NUM + LED_SCR + LED_CAP) printf("Numeric Lock, Scroll Lock, and Caps Lock LEDs are on.\n"); } ** Affects: linux (Ubuntu) Importance: Undecided Assignee: Kernel Bugs (kernel-bugs) Status: New -- console_ioctl KDGETLED does not work ubuntu 9.04 2.6.28-15 https://bugs.launchpad.net/bugs/513650 You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs