Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
3.1 KiB

  1. <HEAD>
  2. <TITLE>Future Directions for DirectInput Keyboard Support</TITLE>
  3. </HEAD>
  4. <BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#000000 VLINK=#808080 ALINK=#000000>
  5. </BODY>
  6. <H2>Future Directions for DirectInput Keyboard Support</H2>
  7. <ADDRESS>
  8. Raymond Chen<br>
  9. Microsoft Corporation<br>
  10. 11 November 1997
  11. </ADDRESS>
  12. <h3>Abstract</h3>
  13. <p>
  14. Ideas for future versions of DirectInput keyboard support are presented.
  15. <h3>Exclusive Keyboard Access</h3>
  16. <p>
  17. Currently, keyboards are supported only in passive (non-exclusive) mode.
  18. Adding support for exclusive mode on the system keyboard
  19. (<code>GUID_SysKeyboard</code>)
  20. is extremely easy on Windows NT, and
  21. a bit tricky on Windows 9x.
  22. <p>
  23. On Windows NT, all that would need to be done is to have the
  24. <code>CEm_LL_KbdHook</code> function return 1 without calling
  25. <code>CallNexthookEx</code> in the situation where the keyboard
  26. has been acquired exclusively. This will prevent Windows
  27. applications (including the current application) from seeing
  28. keyboard activity, while not preventing the secure attention
  29. sequence (Ctrl+Alt+Del) from operating properly.
  30. <p>
  31. For Windows 9x, the change would be similar, but more annoying.
  32. The <code>DIKBD_Filter_Keyboard_Input</code>
  33. function would return carry set rather than clear if the
  34. keyboard is captured. Steal the basic idea from the
  35. <code>dimouse.asm</code> file, which already does this for
  36. mouse events. (I.e., handle the <code>DIKBD_Capture</code>
  37. notification, set a flag in the instance structure,
  38. and check the flag in the filter procedure.)
  39. <p>
  40. It's actually not quite that easy, because Windows 9x does not
  41. have a security manager. The low-level keyboard filter procedure
  42. would also need to track the virtual shift state and detect that
  43. the user has typed Ctrl+Alt+Del. Under such conditions, the filter
  44. would have to force-unacquire the device, then turn around and
  45. re-inject the Ctrl+Alt+Del sequence (now with the filter disabled)
  46. so the system can see it again.
  47. <p>
  48. Note also that
  49. <code>CKbd_SetCooperativeLevel</code> would need to be changed
  50. to understand which modes support exclusive access and which do not.
  51. <h3>Disabling the Windows Logo Key</h3>
  52. <p>
  53. This is a common request from game developers, because the Windows Logo Key
  54. sits right next to two extremely popular game keys - Ctrl and Alt.
  55. Accidentally pressing the Windows Logo key causes the Start Menu to open,
  56. which in turn causes the application to lose focus and possible even lose
  57. its display surfaces.
  58. <p>
  59. This can be solved as a restricted (and much easier)
  60. form of exclusive keyboard access. Again, on Windows NT,
  61. we would merely check if the incoming key is
  62. <code>VK_LWIN</code> or <code>VK_RWIN</code>; if so, then return 1
  63. immediately without chaining.
  64. On Windows 9x, the filter procedure would check for a scan code of
  65. E0/5B or E0/5C (or their release counterparts E0/DB and E0/DC);
  66. if so, convert the 5B or 5C (or DB or DC) to a harmless key like 00.
  67. <h3>References</h3>
  68. <p>
  69. <cite>
  70. <a href=http://www.microsoft.com/directx/resources/dx5ddk.htm>
  71. DirectX 5.0 DDK</a>
  72. </cite>, Microsoft Corporation.
  73. <p>
  74. <cite>
  75. <a href=http://www.microsoft.com/directx/resources/dx5sdk.htm>
  76. DirectX 5.0 SDK</a>
  77. </cite>, Microsoft Corporation.