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.

732 lines
29 KiB

  1. /**INC+**********************************************************************/
  2. /* Header: ih.h */
  3. /* */
  4. /* Purpose: Input Handler external functyion prototypes. */
  5. /* */
  6. /* Copyright(C) Microsoft Corporation 1997-1999 */
  7. /* */
  8. /****************************************************************************/
  9. #ifndef _H_IH
  10. #define _H_IH
  11. extern "C" {
  12. #include <adcgdata.h>
  13. #include <at128.h>
  14. }
  15. #include "autil.h"
  16. #include "wui.h"
  17. #include "sl.h"
  18. #include "cd.h"
  19. #ifdef OS_WINCE
  20. #include <ceconfig.h>
  21. #endif
  22. class CUI;
  23. class CSL;
  24. class CUH;
  25. class CCD;
  26. class CIH;
  27. class COR;
  28. class CFS;
  29. class CUT;
  30. class CCC;
  31. class COP;
  32. #include "objs.h"
  33. #define TRC_GROUP TRC_GROUP_CORE
  34. #define TRC_FILE "ih"
  35. #define CHAR_BIT 8
  36. #define BITMASK(b) (1 << ((b) % CHAR_BIT))
  37. #define BITSLOT(b) ((b) / CHAR_BIT)
  38. #define BITSET(a, b) ((a)[BITSLOT(b)] |= BITMASK(b))
  39. #define BITTEST(a, b) ((a)[BITSLOT(b)] & BITMASK(b))
  40. #define BITCLEAR(a, b) ((a)[BITSLOT(b)] &= (0xFF ^ BITMASK(b)))
  41. //
  42. // Time interval for bbar hotzone detection
  43. // for unhide (in milliseconds)
  44. //
  45. #define IH_BBAR_UNHIDE_TIMEINTERVAL 250
  46. #define IH_BBAR_HOTZONE_HEIGHT 5
  47. //
  48. // We pass this around in dwExtraInfo for keys we inject
  49. // back into the local system.
  50. //
  51. #define IH_EXTRAINFO_IGNOREVALUE 0x13790DBA
  52. #define IH_WM_HANDLE_LOCKDESKTOP (WM_APP+1)
  53. /****************************************************************************/
  54. /* Structure: IH_GLOBAL_DATA */
  55. /* */
  56. /* Description: Input Handler global data */
  57. /****************************************************************************/
  58. typedef struct tagIH_GLOBAL_DATA
  59. {
  60. DCBOOL priorityEventsQueued;
  61. DCBOOL syncRequired;
  62. DCBOOL focusSyncRequired;
  63. HWND inputCaptureWindow;
  64. DCUINT32 lastInputPDUSendTime;
  65. DCUINT32 lastFlowPDUSendTime;
  66. DCUINT fsmState;
  67. INT_PTR timerID;
  68. DCUINT timerTickRate;
  69. PTS_INPUT_PDU pInputPDU;
  70. SL_BUFHND bufHandle;
  71. DCUINT32 minSendInterval; /* Min time between mousemove sends (ms)*/
  72. DCUINT32 eventsAtOnce; /* Max events to pull off in one go */
  73. DCUINT32 maxEventCount; /* Max number of events in InputPDU */
  74. DCUINT32 keepAliveInterval; /* keep-alive time (seconds) */
  75. #ifdef OS_WINCE
  76. DCUINT32 maxMouseMove; /* Send max MouseMove data for ink apps */
  77. #endif // OS_WINCE
  78. WNDCLASS wndClass;
  79. DCUINT16 leftButton;
  80. DCUINT16 rightButton;
  81. DCBOOL acceleratorPassthroughEnabled;
  82. PDCHOTKEY pHotkey;
  83. DCBOOL useScancodes;
  84. DCBOOL useXButtons;
  85. DCBOOL bUseFastPathInput;
  86. DCBOOL fUseVKPacket;
  87. DCBOOL sendZeroScanCode;
  88. DCBOOL inSizeMove;
  89. DWORD dwModifierKeyState;
  90. #define IH_LALT_DOWN 0x0001
  91. #define IH_RALT_DOWN 0x0002
  92. #define IH_ALT_MASK (IH_LALT_DOWN | IH_RALT_DOWN)
  93. #define IH_LCTRL_DOWN 0x0010
  94. #define IH_RCTRL_DOWN 0x0020
  95. #define IH_CTRL_MASK (IH_LCTRL_DOWN | IH_RCTRL_DOWN)
  96. #define IH_LWIN_DOWN 0x0100
  97. #define IH_RWIN_DOWN 0x0200
  98. #define IH_WIN_MASK (IH_LWIN_DOWN | IH_RWIN_DOWN)
  99. #define IH_LSHIFT_DOWN 0x1000
  100. #define IH_RSHIFT_DOWN 0x2000
  101. #define IH_SHIFT_MASK (IH_LSHIFT_DOWN | IH_RSHIFT_DOWN)
  102. DCBOOL NumLock;
  103. DCBOOL fWinEvilShiftHack;
  104. DCBOOL fCtrlEscHotkey;
  105. BOOL fLastKeyWasMenuDown;
  106. /************************************************************************/
  107. /* Visible area of the container window */
  108. /************************************************************************/
  109. DCRECT visibleArea;
  110. /************************************************************************/
  111. /* Fix for repeated WM_MOUSEMOVE problem. Save the last mouse position */
  112. /* here. */
  113. /************************************************************************/
  114. POINT lastMousePos;
  115. /************************************************************************/
  116. /* TRUE = continue to pass on input messages even if we don't have the */
  117. /* focus. */
  118. /************************************************************************/
  119. DCBOOL allowBackgroundInput;
  120. /************************************************************************/
  121. /* Maximum number of events in an InputPDU packet */
  122. /************************************************************************/
  123. #define IH_INPUTPDU_MAX_EVENTS 100
  124. /************************************************************************/
  125. /* InputPDU buffer size */
  126. /************************************************************************/
  127. #define IH_INPUTPDU_BUFSIZE \
  128. ((IH_INPUTPDU_MAX_EVENTS * sizeof(TS_INPUT_EVENT)) + sizeof(TS_INPUT_PDU))
  129. #ifdef OS_WIN32
  130. /************************************************************************/
  131. /* Variables to handle holding off of mouse button-downs. */
  132. /************************************************************************/
  133. DCBOOL pendMouseDown;
  134. DCUINT32 mouseDownTime;
  135. INT_PTR pendMouseTimer;
  136. #endif
  137. #ifdef OS_WINCE
  138. /************************************************************************/
  139. /* Used when trying to simulate Caps Lock keypresses (e.g., WinWord's */
  140. /* habit of flipping the state of that key when typing "tHE "). */
  141. /************************************************************************/
  142. DCUINT8 vkEatMe;
  143. #endif // OS_WINCE
  144. #ifdef OS_WINCE
  145. /************************************************************************/
  146. /* Tracks the state of the Left mouse button True = down, False = up */
  147. /************************************************************************/
  148. DCBOOL bLMouseButtonDown;
  149. #endif // OS_WINCE
  150. //For idle input timer, flag that indicates
  151. //input was sent since the last time the flag was reset
  152. BOOL fInputSentSinceCheckpoint;
  153. //
  154. // Current cursor
  155. //
  156. HCURSOR hCurrentCursor;
  157. //
  158. // Flag indicating we have to eat the next self-injected (VK_FF)
  159. // key as it's purely there for sync purposes
  160. //
  161. BOOL fDiscardSyncDownKey;
  162. BOOL fDiscardSyncUpKey;
  163. } IH_GLOBAL_DATA;
  164. /****************************************************************************/
  165. /* FSM definitions */
  166. /****************************************************************************/
  167. #define IH_FSM_INPUTS 9
  168. #define IH_FSM_STATES 5
  169. /****************************************************************************/
  170. /* FSM inputs */
  171. /****************************************************************************/
  172. #define IH_FSM_INIT 0
  173. #define IH_FSM_ENABLE 1
  174. #define IH_FSM_DISABLE 2
  175. #define IH_FSM_TERM 3
  176. #define IH_FSM_FOCUS_LOSE 4
  177. #define IH_FSM_FOCUS_GAIN 5
  178. #define IH_FSM_INPUT 6
  179. #define IH_FSM_BUFFERAVAILABLE 7
  180. #define IH_FSM_NOBUFFER 8
  181. /****************************************************************************/
  182. /* FSM states */
  183. /****************************************************************************/
  184. #define IH_STATE_RESET 0
  185. #define IH_STATE_INIT 1
  186. #define IH_STATE_ACTIVE 2
  187. #define IH_STATE_SUSPENDED 3
  188. #define IH_STATE_PENDACTIVE 4
  189. //
  190. // Used by the UI to decouple a request to inject a
  191. // set of VKEYS
  192. //
  193. typedef struct tagIH_INJECT_VKEYS_REQUEST
  194. {
  195. LONG numKeys;
  196. short* pfArrayKeyUp;
  197. LONG* plKeyData;
  198. //Callee sets this to notify caller
  199. BOOL fReturnStatus;
  200. } IH_INJECT_VKEYS_REQUEST, *PIH_INJECT_VKEYS_REQUEST;
  201. //
  202. // Internal
  203. //
  204. /****************************************************************************/
  205. /* This is best used for VKEYs that don't change by locale. Use caution. */
  206. /****************************************************************************/
  207. #define IHInjectVKey(message, vkey) \
  208. IHInjectKey(message, vkey, (DCUINT16)MapVirtualKey(vkey, 0))
  209. /****************************************************************************/
  210. /* Is a WM_ message an input event? */
  211. /* It is if: */
  212. /* - the message is any mouse message */
  213. /* - the message one of the keyboard messages generated without a call */
  214. /* to TranslateMessage. */
  215. /****************************************************************************/
  216. #define IH_IS_INPUTEVENT(m) (((m >= WM_MOUSEFIRST) && \
  217. (m <= WM_MOUSELAST)) || \
  218. ((m == WM_KEYDOWN) || \
  219. (m == WM_KEYUP) || \
  220. (m == WM_SYSKEYDOWN) || \
  221. (m == WM_SYSKEYUP)))
  222. /****************************************************************************/
  223. /* Timer tick rate in milliseconds */
  224. /****************************************************************************/
  225. #define IH_TIMER_TICK_RATE 1000
  226. /****************************************************************************/
  227. /* Max time to delay mouse down messages (ms) */
  228. /****************************************************************************/
  229. #ifdef OS_WIN32
  230. #define IH_PENDMOUSE_DELAY 200
  231. #endif
  232. /****************************************************************************/
  233. /* (arbitrary) timer IDs for IH timers ("IH"). */
  234. /****************************************************************************/
  235. #define IH_TIMER_ID 0x4849
  236. #ifdef OS_WIN32
  237. #define IH_PENDMOUSE_TIMER_ID 0x0410
  238. #endif
  239. /****************************************************************************/
  240. /* IH window class */
  241. /****************************************************************************/
  242. #define IH_CLASS_NAME _T("IHWindowClass")
  243. /****************************************************************************/
  244. /* Minimum and maximum times between requesting Flow Control tests */
  245. /****************************************************************************/
  246. #define IH_MIN_FC_INTERVAL 1000
  247. #define IH_MAX_FC_INTERVAL 10000
  248. /****************************************************************************/
  249. /* Keyboard state flags */
  250. /****************************************************************************/
  251. #define IH_KEYSTATE_TOGGLED 0x0001
  252. #define IH_KEYSTATE_DOWN 0x8000
  253. /****************************************************************************/
  254. /* Extended1 flag */
  255. /****************************************************************************/
  256. #define IH_KF_EXTENDED1 0x0200
  257. /****************************************************************************/
  258. /* Japanese keyboard layout */
  259. /****************************************************************************/
  260. #ifdef OS_WINCE
  261. #define JAPANESE_KBD_LAYOUT(hkl) ((LOBYTE(LOWORD(hkl))) == LANG_JAPANESE)
  262. #define KOREAN_KBD_LAYOUT(hkl) ((LOBYTE(LOWORD(hkl))) == LANG_KOREAN)
  263. #else
  264. #define JAPANESE_KBD_LAYOUT(hkl) ((LOBYTE(LOWORD((ULONG_PTR)hkl))) == LANG_JAPANESE)
  265. #define KOREAN_KBD_LAYOUT(hkl) ((LOBYTE(LOWORD((ULONG_PTR)hkl))) == LANG_KOREAN)
  266. #endif
  267. class CIH
  268. {
  269. public:
  270. CIH(CObjs* objs);
  271. ~CIH();
  272. //
  273. // API
  274. //
  275. static VOID IH_StaticInit(HINSTANCE hInstance);
  276. static VOID IH_StaticTerm();
  277. #define IH_CheckForInput(A)
  278. DCVOID DCAPI IH_Init(DCVOID);
  279. DCVOID DCAPI IH_Term(DCVOID);
  280. DCVOID DCAPI IH_Enable(DCVOID);
  281. DCVOID DCAPI IH_Disable(DCVOID);
  282. DCVOID DCAPI IH_BufferAvailable(DCVOID);
  283. HWND DCAPI IH_GetInputHandlerWindow(DCVOID);
  284. DCVOID DCAPI IH_SetAcceleratorPassthrough(ULONG_PTR enabled);
  285. EXPOSE_CD_SIMPLE_NOTIFICATION_FN( CIH,IH_SetAcceleratorPassthrough);
  286. DCVOID DCAPI IH_SetCursorPos(PDCVOID pData, DCUINT dataLen);
  287. EXPOSE_CD_NOTIFICATION_FN(CIH, IH_SetCursorPos);
  288. DCVOID DCAPI IH_SetCursorShape(ULONG_PTR data);
  289. EXPOSE_CD_SIMPLE_NOTIFICATION_FN(CIH, IH_SetCursorShape);
  290. DCVOID DCAPI IH_SetVisiblePos(PDCVOID pData, DCUINT dataLen);
  291. EXPOSE_CD_NOTIFICATION_FN(CIH,IH_SetVisiblePos);
  292. DCVOID DCAPI IH_SetVisibleSize(ULONG_PTR data);
  293. EXPOSE_CD_SIMPLE_NOTIFICATION_FN(CIH, IH_SetVisibleSize);
  294. DCVOID DCAPI IH_SetHotkey(PDCVOID pData, DCUINT len);
  295. EXPOSE_CD_NOTIFICATION_FN(CIH, IH_SetHotkey);
  296. DCVOID DCAPI IH_ProcessInputCaps(PTS_INPUT_CAPABILITYSET pInputCaps);
  297. DCVOID DCAPI IH_UpdateKeyboardIndicators(DCUINT16 UnitId, DCUINT16 LedFlags);
  298. DCVOID DCAPI IH_InputEvent(ULONG_PTR msg);
  299. EXPOSE_CD_SIMPLE_NOTIFICATION_FN(CIH,IH_InputEvent);
  300. DCVOID DCAPI IH_InjectMultipleVKeys(ULONG_PTR ihRequestPacket);
  301. EXPOSE_CD_SIMPLE_NOTIFICATION_FN( CIH,IH_InjectMultipleVKeys);
  302. DCVOID DCAPI IH_SetKeyboardImeStatus(DCUINT32 ImeOpen, DCUINT32 ImeConvMode);
  303. #ifndef OS_WINCE
  304. BOOL DCAPI IH_SetEnableKeyboardHooking() {return _fUseHookBypass;}
  305. BOOL DCAPI IH_GetEnableKeyboardHooking(BOOL bEnableHook)
  306. {_fUseHookBypass=bEnableHook;}
  307. #else
  308. BOOL DCAPI IH_GetEnableKeyboardHooking() {return _fUseHookBypass;}
  309. VOID DCAPI IH_SetEnableKeyboardHooking(BOOL bEnableHook)
  310. {_fUseHookBypass=bEnableHook;}
  311. #endif
  312. #ifdef SMART_SIZING
  313. DCVOID DCAPI IH_MainWindowSizeChange(ULONG_PTR msg);
  314. EXPOSE_CD_SIMPLE_NOTIFICATION_FN(CIH,IH_MainWindowSizeChange);
  315. #endif // SMART_SIZING
  316. //
  317. // Notifications to the IH of fullscreen events
  318. //
  319. VOID DCAPI IH_NotifyEnterFullScreen();
  320. VOID DCAPI IH_NotifyLeaveFullScreen();
  321. //
  322. // Public data members
  323. //
  324. IH_GLOBAL_DATA _IH;
  325. static DWORD TlsIndex;
  326. //
  327. // Internal functions
  328. //
  329. static LRESULT CALLBACK IHStaticInputCaptureWndProc(HWND hwnd,
  330. UINT message,
  331. WPARAM wParam,
  332. LPARAM lParam);
  333. LRESULT CALLBACK IHInputCaptureWndProc(HWND hwnd,
  334. UINT message,
  335. WPARAM wParam,
  336. LPARAM lParam);
  337. VOID IH_ResetInputWasSentFlag()
  338. {
  339. _IH.fInputSentSinceCheckpoint = FALSE;
  340. }
  341. BOOL IH_GetInputWasSentFlag()
  342. {
  343. return _IH.fInputSentSinceCheckpoint;
  344. }
  345. VOID IH_SetInputWasSentFlag(BOOL b)
  346. {
  347. _IH.fInputSentSinceCheckpoint = b;
  348. }
  349. private:
  350. /****************************************************************************/
  351. /* Function Prototypes */
  352. /****************************************************************************/
  353. DCBOOL DCINTERNAL IHFSMProc(DCUINT32 event, ULONG_PTR data);
  354. DCBOOL DCINTERNAL IHAddEventToPDU(PMSG inputMsg);
  355. DCVOID DCINTERNAL IHMaybeSendPDU(DCVOID);
  356. DCVOID DCINTERNAL IHSync(DCVOID);
  357. DCVOID DCINTERNAL IHInitPacket(DCVOID);
  358. DCVOID DCINTERNAL IHSetMouseHandedness(DCVOID);
  359. DCVOID DCINTERNAL IHDiscardMsg(PMSG pMsg);
  360. DCBOOL DCINTERNAL IHCheckForHotkey(PMSG pNextMsg);
  361. DCBOOL DCINTERNAL IHProcessKoreanVKHangulHanja(PWORD scancode, PWORD flags);
  362. DCBOOL DCINTERNAL IHProcessMouseEvent(PMSG pMsg);
  363. DCBOOL DCINTERNAL IHProcessKeyboardEvent(PMSG pMsg);
  364. DCBOOL DCINTERNAL IHMassageZeroScanCode(PMSG pMsg);
  365. #ifdef OS_WINCE
  366. DCBOOL DCINTERNAL IHAddMultipleEventsToPDU(POINT *ppt, int cpt);
  367. #endif
  368. VOID IHMaintainModifierKeyState(int vkKey);
  369. unsigned DCINTERNAL IHTranslateInputToFastPath(unsigned *);
  370. LRESULT IHLowLevelKeyboardProc(int nCode, WPARAM wParam,
  371. LPARAM lParam);
  372. static LRESULT CALLBACK IHStaticLowLevelKeyboardProc(int nCode, WPARAM wParam,
  373. LPARAM lParam);
  374. VOID IHGatherKeyState();
  375. BOOL IHIsForegroundWindow();
  376. /****************************************************************************/
  377. /* Name: IHPostMessageToMainWindow */
  378. /* */
  379. /* Purpose: Sees if the message passed in needs to be passed to the main UI */
  380. /* window. If so pass it the window and return true. */
  381. /* */
  382. /* Returns: TRUE - if message successfully passed to the UI main window */
  383. /* FALSE - otherwsie */
  384. /* */
  385. /* Params: msg - IN - Message to be considered */
  386. /****************************************************************************/
  387. DCBOOL DCINTERNAL IHPostMessageToMainWindow(DCUINT message,
  388. WPARAM wParam,
  389. LPARAM lParam)
  390. {
  391. DCBOOL rc = FALSE;
  392. DCBOOL normalKeyPress;
  393. DCBOOL altKeyPress;
  394. DCBOOL isFullScreenToggle;
  395. DCBOOL isNeededAccelerator;
  396. DCBOOL isAltTab;
  397. DCBOOL isAltSpace;
  398. DCBOOL isSpecialFilterSequence;
  399. DC_BEGIN_FN("IHPostMessageToMainWindow");
  400. if (_IH.inSizeMove)
  401. {
  402. if ((message != WM_TIMER) && (message != WM_PAINT))
  403. {
  404. TRC_NRM((TB, _T("In Size/Move - post to frame")));
  405. PostMessage( _pUi->UI_GetUIMainWindow(),
  406. message,
  407. wParam,
  408. lParam );
  409. }
  410. rc = TRUE;
  411. DC_QUIT;
  412. }
  413. normalKeyPress = ((message == WM_KEYDOWN) || (message == WM_KEYUP));
  414. altKeyPress = ((message == WM_SYSKEYDOWN) || (message == WM_SYSKEYUP));
  415. isFullScreenToggle = normalKeyPress &&
  416. (wParam == _IH.pHotkey->fullScreen) &&
  417. TEST_FLAG(GetKeyState(VK_MENU), IH_KEYSTATE_DOWN);
  418. isNeededAccelerator = (!_IH.acceleratorPassthroughEnabled) && altKeyPress;
  419. isAltTab = (message == WM_SYSKEYDOWN) && (wParam == VK_TAB);
  420. isAltSpace = altKeyPress && (wParam == VK_SPACE);
  421. isSpecialFilterSequence = isAltTab || isAltSpace;
  422. /************************************************************************/
  423. /* Some messages must not be passed to server, and are just passed to */
  424. /* the UI's Main Window. */
  425. /* */
  426. /* These are: */
  427. /* 1. Screen Mode toggle keys - these must be of the form ALT + VK - */
  428. /* for example ALT+Ctrl+Pause. */
  429. /* 2. ALT keystrokes sent when accelerator pass-through is disabled. */
  430. /* 3. ALT-TAB keystrokes (although we actually only see these on */
  431. /* Win 3.1). We actually send alt-tab up keys because the server */
  432. /* then recognizes that alt tabbing is going on and doesn't do the */
  433. /* menu highlighting thing. */
  434. /************************************************************************/
  435. if (isFullScreenToggle ||
  436. ((isNeededAccelerator ||
  437. isSpecialFilterSequence) && !_fUseHookBypass))
  438. {
  439. TRC_NRM((TB, _T("Post to Frame msg(%#x) wParam(%#x) "), message, wParam));
  440. if (PostMessage( _pUi->UI_GetUIMainWindow(),
  441. message,
  442. wParam,
  443. lParam ) == 0)
  444. {
  445. TRC_ABORT((TB, _T("Failed to post message to main window")));
  446. }
  447. if ( (!_IH.acceleratorPassthroughEnabled) &&
  448. (message == WM_SYSKEYUP) )
  449. {
  450. /****************************************************************/
  451. /* When we use the full-screen hotkey, we can get asymmetric */
  452. /* sequences such as: */
  453. /* */
  454. /* WM_KEYDOWN (VK_CONTROL) */
  455. /* WM_KEYDOWN (VK_MENU) */
  456. /* WM_KEYDOWN (VK_CANCEL) */
  457. /* WM_KEYUP (VK_CANCEL) */
  458. /* WM_SYSKEYUP (VK_CONTROL) <- asymmetric */
  459. /* WM_KEYUP (VK_MENU) */
  460. /* */
  461. /* When accelerator passthrough is off, the WM_SYSKEYUP doesn't */
  462. /* get passed through to the server, which then thinks that the */
  463. /* Ctrl key is still down. */
  464. /* */
  465. /* This branch means that the WM_SYSKEYUP is both passed to the */
  466. /* UI's main window AND processed by whoever called this */
  467. /* function. */
  468. /****************************************************************/
  469. TRC_ALT((TB,
  470. "Passed WM_SYSKEYUP to UI main window, but lying about it."));
  471. DC_QUIT;
  472. }
  473. rc = TRUE;
  474. }
  475. DC_EXIT_POINT:
  476. DC_END_FN();
  477. return(rc);
  478. } /* IHPostMessageToMainWindow */
  479. /****************************************************************************/
  480. /* Name: IHSetCursorShape */
  481. /* */
  482. /* Purpose: Set the cursor shape */
  483. /* */
  484. /* Params: IN cursorHandle */
  485. /****************************************************************************/
  486. DCVOID DCINTERNAL IHSetCursorShape(HCURSOR cursorHandle)
  487. {
  488. DC_BEGIN_FN("IHSetCursorShape");
  489. //
  490. // Store the cursor for future WM_SETCURSOR's
  491. //
  492. _IH.hCurrentCursor = cursorHandle;
  493. //
  494. // Also set the cursor directly - just to be sure the cursor is in sync
  495. // during reconnection.
  496. //
  497. SetCursor(cursorHandle);
  498. DC_END_FN();
  499. return;
  500. } /* IHSetCursorShape */
  501. /****************************************************************************/
  502. /* Name: IHUpdateKeyboardIndicator */
  503. /* */
  504. /* Purpose: Set the specified keyboard indicator */
  505. /* */
  506. /* Params: IN pKeyState - keyStates array */
  507. /* IN bState - key state to set */
  508. /* IN vkKey - virtual key */
  509. /****************************************************************************/
  510. DCVOID DCINTERNAL IHUpdateKeyboardIndicator(PDCUINT8 pKeyStates,
  511. DCUINT8 bState,
  512. DCUINT8 vkKey)
  513. {
  514. DC_BEGIN_FN("IHUpdateKeyboardIndicator");
  515. if ((bState && !(pKeyStates[vkKey] & 1)) ||
  516. (!bState && (pKeyStates[vkKey] & 1)))
  517. {
  518. {
  519. /****************************************************************/
  520. /* Scancode of zero will be recognized by WM_KEY* processing */
  521. /* code and will not forward the events on to the server */
  522. /****************************************************************/
  523. #ifndef OS_WINCE
  524. keybd_event(vkKey, (DCUINT8) 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
  525. keybd_event(vkKey, (DCUINT8) 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
  526. #else
  527. /****************************************************************/
  528. /* Save this key for later ignoring. */
  529. /* (The default TSC method of ignoring a key is to send a scan- */
  530. /* code of 0. That does not work on WINCE_HPC because it */
  531. /* interprets that condition to mean that the keyboard driver */
  532. /* has not supplied a scan-code and so inserts the scan-code */
  533. /* from the VK identifier.) */
  534. /****************************************************************/
  535. if (! g_CEUseScanCodes)
  536. {
  537. _IH.vkEatMe = vkKey;
  538. }
  539. keybd_event(vkKey, (DCUINT8) 0, KEYEVENTF_SILENT, 0);
  540. keybd_event(vkKey, (DCUINT8) 0, KEYEVENTF_SILENT | KEYEVENTF_KEYUP, 0);
  541. #endif
  542. }
  543. }
  544. DC_END_FN();
  545. }
  546. /****************************************************************************/
  547. /* Name: IHInjectKey */
  548. /* */
  549. /* Purpose: Send the specified key to the server */
  550. /* */
  551. /* Params: IN message - keyboard message */
  552. /* IN vKey - virtual key code, should mean very little */
  553. /* IN scancode - scancode to send */
  554. /****************************************************************************/
  555. DCVOID DCINTERNAL IHInjectKey(UINT message, WPARAM vKey, DCUINT16 scancode)
  556. {
  557. MSG msg;
  558. DC_BEGIN_FN("IHInjectKey");
  559. TRC_ASSERT(message == WM_KEYDOWN || message == WM_KEYUP ||
  560. message == WM_SYSKEYDOWN || message == WM_SYSKEYUP,
  561. (TB, _T("Message %#x should be a keyboard message"), message));
  562. TRC_DBG((TB, _T("Injecting %s vkey: 0x%8.8x, scancode: 0x%8.8x"),
  563. (message == WM_KEYDOWN ? "WM_KEYDOWN" :
  564. (message == WM_KEYUP ? "WM_KEYUP" :
  565. (message == WM_SYSKEYDOWN ? "WM_SYSKEYDOWN" :
  566. (message == WM_SYSKEYUP ? "WM_SYSKEYUP" : "WM_WHATSWRONGWITHYOU")))),
  567. vKey, scancode));
  568. msg.hwnd = NULL;
  569. msg.message = message;
  570. msg.wParam = vKey;
  571. msg.lParam = MAKELONG(0, scancode);
  572. IHAddEventToPDU(&msg);
  573. DC_END_FN();
  574. }
  575. #ifdef USE_BBAR
  576. VOID IHSetBBarUnhideTimer(LONG x, LONG y);
  577. #endif
  578. #ifdef OS_WINNT
  579. VOID IHHandleLocalLockDesktop();
  580. #endif // OS_WINNT
  581. private:
  582. CUT* _pUt;
  583. CUI* _pUi;
  584. CSL* _pSl;
  585. CUH* _pUh;
  586. CCD* _pCd;
  587. CIH* _pIh;
  588. COR* _pOr;
  589. CFS* _pFs;
  590. CCC* _pCc;
  591. COP* _pOp;
  592. HHOOK _hKeyboardHook;
  593. BOOL _fUseHookBypass;
  594. BOOL _fCanUseKeyboardHook;
  595. BYTE _KeyboardState[32];
  596. #ifdef SMART_SIZING
  597. DCSIZE _scaleSize;
  598. #endif // SMART_SIZING
  599. private:
  600. CObjs* _pClientObjects;
  601. };
  602. #undef TRC_FILE
  603. #undef TRC_GROUP
  604. #endif //_H_IH