Future Directions for DirectInput Keyboard Support

Raymond Chen
Microsoft Corporation
11 November 1997

Abstract

Ideas for future versions of DirectInput keyboard support are presented.

Exclusive Keyboard Access

Currently, keyboards are supported only in passive (non-exclusive) mode. Adding support for exclusive mode on the system keyboard (GUID_SysKeyboard) is extremely easy on Windows NT, and a bit tricky on Windows 9x.

On Windows NT, all that would need to be done is to have the CEm_LL_KbdHook function return 1 without calling CallNexthookEx in the situation where the keyboard has been acquired exclusively. This will prevent Windows applications (including the current application) from seeing keyboard activity, while not preventing the secure attention sequence (Ctrl+Alt+Del) from operating properly.

For Windows 9x, the change would be similar, but more annoying. The DIKBD_Filter_Keyboard_Input function would return carry set rather than clear if the keyboard is captured. Steal the basic idea from the dimouse.asm file, which already does this for mouse events. (I.e., handle the DIKBD_Capture notification, set a flag in the instance structure, and check the flag in the filter procedure.)

It's actually not quite that easy, because Windows 9x does not have a security manager. The low-level keyboard filter procedure would also need to track the virtual shift state and detect that the user has typed Ctrl+Alt+Del. Under such conditions, the filter would have to force-unacquire the device, then turn around and re-inject the Ctrl+Alt+Del sequence (now with the filter disabled) so the system can see it again.

Note also that CKbd_SetCooperativeLevel would need to be changed to understand which modes support exclusive access and which do not.

Disabling the Windows Logo Key

This is a common request from game developers, because the Windows Logo Key sits right next to two extremely popular game keys - Ctrl and Alt. Accidentally pressing the Windows Logo key causes the Start Menu to open, which in turn causes the application to lose focus and possible even lose its display surfaces.

This can be solved as a restricted (and much easier) form of exclusive keyboard access. Again, on Windows NT, we would merely check if the incoming key is VK_LWIN or VK_RWIN; if so, then return 1 immediately without chaining. On Windows 9x, the filter procedure would check for a scan code of E0/5B or E0/5C (or their release counterparts E0/DB and E0/DC); if so, convert the 5B or 5C (or DB or DC) to a harmless key like 00.

References

DirectX 5.0 DDK , Microsoft Corporation.

DirectX 5.0 SDK , Microsoft Corporation.