Sign in to follow this  

DirectInput 8 Keyboard LEDs

This topic is 3315 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3315 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this