Boris Gougeon
Boris Gougeon

Reputation: 874

Caps Lock State in Qt (or any mac API)

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

Upvotes: 1

Views: 1259

Answers (1)

ephemient
ephemient

Reputation: 204778

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.

Upvotes: 1

Related Questions