Leaked source code of windows server 2003
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.

122 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1985 - 1999, Microsoft Corporation
  3. Module Name:
  4. input.h
  5. Abstract:
  6. This module contains the internal structures and definitions used
  7. by the input (keyboard and mouse) component of the NT console subsystem.
  8. Author:
  9. Therese Stowell (thereses) 12-Nov-1990
  10. Revision History:
  11. --*/
  12. #define DEFAULT_NUMBER_OF_EVENTS 50
  13. #define INPUT_BUFFER_SIZE_INCREMENT 10
  14. typedef struct _INPUT_INFORMATION {
  15. PINPUT_RECORD InputBuffer;
  16. DWORD InputBufferSize; // size in events
  17. CONSOLE_SHARE_ACCESS ShareAccess; // share mode
  18. DWORD InputMode;
  19. ULONG RefCount; // number of handles to input buffer
  20. ULONG_PTR First; // ptr to base of circular buffer
  21. ULONG_PTR In; // ptr to next free event
  22. ULONG_PTR Out; // ptr to next available event
  23. ULONG_PTR Last; // ptr to end+1 of buffer
  24. LIST_ENTRY ReadWaitQueue;
  25. HANDLE InputWaitEvent;
  26. #if defined(FE_SB)
  27. #if defined(FE_IME)
  28. struct {
  29. DWORD Disable : 1; // High : specifies input code page or enable/disable in NLS state
  30. DWORD Unavailable : 1; // Middle : specifies console window doing menu loop or size move
  31. DWORD Open : 1; // Low : specifies open/close in NLS state or IME hot key
  32. DWORD ReadyConversion:1;// if conversion mode is ready by succeed communicate to ConIME.
  33. // then this field is TRUE.
  34. DWORD Conversion; // conversion mode of ime (i.e IME_CMODE_xxx).
  35. // this field uses by GetConsoleNlsMode
  36. } ImeMode;
  37. HWND hWndConsoleIME; // validate hWnd when open property window by ImmConfigureIME
  38. #endif // FE_IME
  39. struct _CONSOLE_INFORMATION *Console;
  40. INPUT_RECORD ReadConInpDbcsLeadByte;
  41. INPUT_RECORD WriteConInpDbcsLeadByte[2];
  42. #endif
  43. } INPUT_INFORMATION, *PINPUT_INFORMATION;
  44. typedef struct _INPUT_READ_HANDLE_DATA {
  45. //
  46. // the following seven fields are solely used for input reads.
  47. //
  48. CRITICAL_SECTION ReadCountLock; // serializes access to read count
  49. ULONG ReadCount; // number of reads waiting
  50. ULONG InputHandleFlags;
  51. //
  52. // the following four fields are used to remember input data that
  53. // wasn't returned on a cooked-mode read. we do our own buffering
  54. // and don't return data until the user hits enter so that she can
  55. // edit the input. as a result, there is often data that doesn't fit
  56. // into the caller's buffer. we save it so we can return it on the
  57. // next cooked-mode read to this handle.
  58. //
  59. ULONG BytesAvailable;
  60. PWCHAR CurrentBufPtr;
  61. PWCHAR BufPtr;
  62. } INPUT_READ_HANDLE_DATA, *PINPUT_READ_HANDLE_DATA;
  63. #define UNICODE_BACKSPACE ((WCHAR)0x08)
  64. #define UNICODE_BACKSPACE2 ((WCHAR)0x25d8)
  65. #define UNICODE_CARRIAGERETURN ((WCHAR)0x0d)
  66. #define UNICODE_LINEFEED ((WCHAR)0x0a)
  67. #define UNICODE_BELL ((WCHAR)0x07)
  68. #define UNICODE_TAB ((WCHAR)0x09)
  69. #define UNICODE_SPACE ((WCHAR)0x20)
  70. #define TAB_SIZE 8
  71. #define TAB_MASK (TAB_SIZE-1)
  72. #define NUMBER_OF_SPACES_IN_TAB(POSITION) (TAB_SIZE - ((POSITION) & TAB_MASK))
  73. #define AT_EOL(COOKEDREADDATA) ((COOKEDREADDATA)->BytesRead == ((COOKEDREADDATA)->CurrentPosition*2))
  74. #define INSERT_MODE(COOKEDREADDATA) ((COOKEDREADDATA)->InsertMode)
  75. #define VIRTUAL_KEY_CODE_S 0x53
  76. #define VIRTUAL_KEY_CODE_C 0x43
  77. #define VK_OEM_SCROLL 0x91
  78. #define KEY_PRESSED 0x8000
  79. #define KEY_TOGGLED 0x01
  80. #define KEY_ENHANCED 0x01000000
  81. #define KEY_UP_TRANSITION 1
  82. #define KEY_PREVIOUS_DOWN 0x40000000
  83. #define KEY_TRANSITION_UP 0x80000000
  84. #define CONSOLE_CTRL_C_SEEN 1
  85. #define CONSOLE_CTRL_BREAK_SEEN 2
  86. #define LockReadCount(HANDLEPTR) RtlEnterCriticalSection(&(HANDLEPTR)->InputReadData->ReadCountLock)
  87. #define UnlockReadCount(HANDLEPTR) RtlLeaveCriticalSection(&(HANDLEPTR)->InputReadData->ReadCountLock)
  88. #define LoadKeyEvent(PEVENT,KEYDOWN,CHAR,KEYCODE,SCANCODE,KEYSTATE) { \
  89. (PEVENT)->EventType = KEY_EVENT; \
  90. (PEVENT)->Event.KeyEvent.bKeyDown = KEYDOWN; \
  91. (PEVENT)->Event.KeyEvent.wRepeatCount = 1; \
  92. (PEVENT)->Event.KeyEvent.uChar.UnicodeChar = CHAR; \
  93. (PEVENT)->Event.KeyEvent.wVirtualKeyCode = KEYCODE; \
  94. (PEVENT)->Event.KeyEvent.wVirtualScanCode = SCANCODE; \
  95. (PEVENT)->Event.KeyEvent.dwControlKeyState = KEYSTATE; \
  96. }