DirectInput 8 Keyboard LEDs

Started by
4 comments, last by Headkaze 15 years, 5 months ago
Hi Everyone, I wrote a set of classes for using Direct Input 8. The classes are CInputManager, CKeyboard, and CMouse. They all work good. The application I am creating has an on screen keyboard. It contains a CapsLock key. When the CapsLock key is pressed on the onscreen keyboard or the physical keyboard, a capslock keydown event is sent to the input manager. This is all good and works the way I want it. The problem that I am having is that soft key and the hard key for the caps lock get out of sync. So when the soft key is pressed, I would like to turn on the physical keyboard caps lock light. I tried using SendDeviceData as stated in this example: http://msdn.microsoft.com/en-us/library/bb147251(VS.85).aspx Does anyone know how I can turn on/off the caps lock on the physical keyboard using direct input 8? I have an onscreen keyboard because there might not be a keyboard plugged into the computer. Thanks Hamfiend
Advertisement
Why not just avoid the problem and a million others and not use DirectInput for keyboard or mouse input? Does your system handle IMEs, foreign keyboards, and the million other things Windows already does for you?
Hi Steve,

So you are recommending not using direct into at all? I would use the WM_xxx messages then create the event and send it to my Input Manager.

How do you toggle the keyboard LEDs in windows?

Thanks for your fast response
Hamfiend
Quote:Original post by Hamfiend
Hi Steve,

So you are recommending not using direct into at all? I would use the WM_xxx messages then create the event and send it to my Input Manager.
Yep. It's really not a good idea to use DirectInput for keyboard or mouse input for the reasons mentioned in that post.

Quote:Original post by Hamfiend
How do you toggle the keyboard LEDs in windows?
You can use SendInput() apparently, but I doubt that'll just toggle the keyboard lights.

Wouldn't it be a better idea to not let the keyboard light and internal state get out of sync? You can use GetKeyState to get the current state of caps lock:
Quote:If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled.
Hi Steve,

I think that will do what I want.

Thanks
Hamfiend
Can I suggest you download the MAME source code and look in src\osd\windows\ledutil.c. It has code to get and set the numlock, capslock and scroll lock led's. It has 3 different methods, Win9x, usb and PS2.

This topic is closed to new replies.

Advertisement