• Advertisement
Sign in to follow this  
  • entries
    135
  • comments
    130
  • views
    52548

DirectInput

Sign in to follow this  

169 views

So, does anyone know how to determine if CapsLock is enabled/disabled with DirectInput? I can detect if the key was pressed, but I need to know in what state it currently is in.

Thanks.

Sign in to follow this  


3 Comments


Recommended Comments

The documentation for the Win32 API function GetKeyState - which fills a 256 character array with key states, just like DI - says:
When the function returns, each member of the array pointed to by the lpKeyState parameter contains status data for a virtual key. If the high-order bit is 1, the key is down; otherwise, it is up. If the key is a toggle key, for example CAPS LOCK, then the low-order bit is 1 when the key is toggled and is 0 if the key is untoggled. The low-order bit is meaningless for non-toggle keys. A toggle key is said to be toggled when it is turned on. 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.


So, it could be the same for DI. And maybe not.

Share this comment


Link to comment
This yielded this.

Search for DIK_CAPITAL on that page. Hopefully that helps, it's been ages since I've worked with DI.

Share this comment


Link to comment
Quote:

This yielded this.

Search for DIK_CAPITAL on that page. Hopefully that helps, it's been ages since I've worked with DI.


Yeah, the first thing I did when I couldn't find the answer in the DX docs was to try google, I found that same website and a few others, unfortunately they weren't very useful. Thanks though, I appreciate the reply.

Quote:

If the key is a toggle key, for example CAPS LOCK, then the low-order bit is 1 when the key is toggled and is 0 if the key is untoggled.


This look promising, I'll check it out in a sec, but when I previously set a breakpoint querying the array for the caps lock entry, it was returning 0x00 regardless of it being toggled or not. But I'll double check just in case I was doing something incorrectly.

Thanks for the reply, I hadn't thought of comparing against Win32.

Share this comment


Link to comment

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

  • Advertisement