DirectX - how to get DirectInput keyboard CapsLock state ?

10 views
Skip to first unread message

R.Wieser

unread,
Oct 30, 2022, 2:02:36 PM10/30/22
to
Hello all,

I'm doing some DirectX using DirectInput, which works nicely. But I would
like to be able to get the current state of the, for instance, CapsLock key.

I came as far as the DIOBJECTDATAFORMAT struct and its flags
(DIDFT_PSHBUTTON, DIDFT_TGLBUTTON and DIDFT_BUTTON), but have not been able
to figure out how to use them to retrieve (or create!) a toggle key.

Hence my question :

1) Is it actually possible to access (or create) a toggle key thru
DirectX-es DirectInput mechanism ?

2) If so, how do I go about it ?

Mind you, I already got some code to create a toggle from a non-toggeling
key. Thats not what I'm asking for. :-)

Regards,
Rudy Wieser


JJ

unread,
Oct 30, 2022, 9:43:50 PM10/30/22
to
Haven't actually tested it, but isn't DInput's `GetDeviceState()` return the
same data as WinAPI's `GetKeyboardState()`? i.e. MSB = pressed, LSB =
toggle.

R.Wieser

unread,
Oct 31, 2022, 2:39:47 AM10/31/22
to
JJ,

>> 1) Is it actually possible to access (or create) a toggle key thru
>> DirectX-es DirectInput mechanism ?
>>
>> 2) If so, how do I go about it ?
...
> Haven't actually tested it, but isn't DInput's `GetDeviceState()` return
> the same data as WinAPI's `GetKeyboardState()`? i.e. MSB = pressed, LSB =
> toggle.

Thats what I assumed too. But as I did not get the expected result I
displayed the involved byte. Alas, no change of any bit other than the MSB.

Double checked it with DIK_SCROLL and DIK_NUMLOCK and got the same result.

Hence my idea that I should perhaps change something in the
DIOBJECTDATAFORMAT declaration of the involved key(s).

Regards,
Rudy Wieser


Reply all
Reply to author
Forward
0 new messages