tags:

views:

292

answers:

1

Hi!

I'm trying to figure out how to get the caps lock state in Qt (4.5) but the only thing I managed to get from qt is either or not the CAPS LOCK was pressed or released, and then could't get the actual state.

In order to solve that I've tried platform dependent and I got something working on xp. But now I'm looking for a solution on mac. I googled a lot without success (or maybe some objective C API or HID Api).

So it would be great if someone had any id how to do that either with qt, or on mac. Thanks in advance,

Boris

+1  A: 

If looking at GPL code doesn't taint you, see VirtualBox/src/VBox/Frontends/VirtualBox/src/darwin/DarwinKeyboard.cpp.

In particular, its darwinHIDKeyboardCacheDoUpdate finds all keyboards, and darwinQueryHIDModifiers iterates over keyboards looking for held modifier keys.

As the comments say: for some reason, this all seems to be pretty poorly documented...

I don't have a running Mac myself, but VirtualBox uses Qt 4 for its GUI and still has to dig down into IOKit itself to get at keyboard modifier keys on a Mac, so I would guess that this isn't possible with just plain Qt.

ephemient
I checked and it does look quite complicated, I need to go more deeply into their code. I'm really surprised apple didn't do something more accessible, and didn't document anything...Thanks anyway for your answer, much appreciated!
Boris Gougeon