dswartz
12th September 2011, 16:18
Hi, I'm very new to Qt, but I have been recently been assigned to a project involving Qt & X11 in Linux (a flavor of Ubuntu). One of my tasks is to write a function to detect the state of caps lock, number lock, scroll lock, and Kana lock. So far, I have been able to detect caps, number, and scroll lock, but can't seem to figure out Kana lock. Does anyone know how to use XkbGetIndicatorState() to detect Kana lock? If not, does anyone know a better, or different, method that is capable of detecting the state of all four?
My code for the other three is:
//---------------------------------------------------
#include <iostream>
#include <X11/KBlib.h>
#include <X11/Xlib.h>
using namespace std;
int main( int argc, char *argv[] ){
unsigned kbd_state, led_state=0;
XkbGetIndicatorState( NULL, XkbUseCoreKbd, &kbd_state );
// here is the logic for lock detection
if( (kbd_state & 0x01) == 1 ) led_state += 1; // if caps lock is on
if( (kbd_state & 0x02) == 2 ) led_state += 2; // if number lock is on
if( (kbd_state & 0x04) == 4 ) led_state += 4; // if scroll lock is on
// if( (kbd_state & ????) == ? ) led_state += ?; // is kana lock on??????
return 0;
}
//---------------------------------------------------
Any help would be really appreciated! Thanks!
My code for the other three is:
//---------------------------------------------------
#include <iostream>
#include <X11/KBlib.h>
#include <X11/Xlib.h>
using namespace std;
int main( int argc, char *argv[] ){
unsigned kbd_state, led_state=0;
XkbGetIndicatorState( NULL, XkbUseCoreKbd, &kbd_state );
// here is the logic for lock detection
if( (kbd_state & 0x01) == 1 ) led_state += 1; // if caps lock is on
if( (kbd_state & 0x02) == 2 ) led_state += 2; // if number lock is on
if( (kbd_state & 0x04) == 4 ) led_state += 4; // if scroll lock is on
// if( (kbd_state & ????) == ? ) led_state += ?; // is kana lock on??????
return 0;
}
//---------------------------------------------------
Any help would be really appreciated! Thanks!