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.

198 lines
6.2 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: cdiacpage.h
  3. //
  4. // Desc: CDIDeviceActionConfigPage implements the page object used by the UI.
  5. // A page covers the entire UI minus the device tabs and the bottons at
  6. // the bottom. The information window, player combo-box, genre combo-
  7. // box, action list tree, and device view window are all managed by
  8. // the page.
  9. //
  10. // Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
  11. //-----------------------------------------------------------------------------
  12. #ifdef FORWARD_DECLS
  13. class CDIDeviceActionConfigPage;
  14. #else // FORWARD_DECLS
  15. #ifndef __CDIACPAGE_H__
  16. #define __CDIACPAGE_H__
  17. // For WINMM.DLL
  18. typedef MMRESULT (WINAPI *FUNCTYPE_timeSetEvent)(UINT, UINT, LPTIMECALLBACK, DWORD_PTR, UINT);
  19. extern HINSTANCE g_hWinMmDLL;
  20. extern FUNCTYPE_timeSetEvent g_fptimeSetEvent;
  21. //implementation class
  22. class CDIDeviceActionConfigPage : public IDIDeviceActionConfigPage, public CDeviceUINotify, public CFlexWnd
  23. {
  24. public:
  25. //IUnknown fns
  26. STDMETHOD (QueryInterface) (REFIID iid, LPVOID *ppv);
  27. STDMETHOD_(ULONG, AddRef) ();
  28. STDMETHOD_(ULONG, Release) ();
  29. //IDirectInputActionConfigPage
  30. STDMETHOD (Create) (DICFGPAGECREATESTRUCT *pcs);
  31. STDMETHOD (Show) (LPDIACTIONFORMATW lpDiActFor);
  32. STDMETHOD (Hide) ();
  33. // layout edit mode
  34. STDMETHOD (SetEditLayout) (BOOL bEditLayout);
  35. //@@BEGIN_MSINTERNAL
  36. #ifdef DDKBUILD
  37. // Write layout to IHV setting file
  38. STDMETHOD (WriteIHVSetting) ();
  39. #endif
  40. //@@END_MSINTERNAL
  41. // Set the info box text
  42. STDMETHOD (SetInfoText) (int iCode);
  43. // Unacquire and Reacquire the device for page's purposes
  44. // (the configwnd needs to do this around SetActionMap() calls)
  45. STDMETHOD (Unacquire) ();
  46. STDMETHOD (Reacquire) ();
  47. //construction/destruction
  48. CDIDeviceActionConfigPage();
  49. ~CDIDeviceActionConfigPage();
  50. // dialog window message handlers
  51. /* BOOL OnInitDialog(HWND hWnd, HWND hwndFocus);
  52. BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  53. LRESULT OnNotify(WPARAM wParam, LPARAM lParam);
  54. void OnPaint(HDC hDC);
  55. void OnClick(POINT point, WPARAM, BOOL bLeft);*/
  56. protected:
  57. virtual void OnInit();
  58. virtual void OnPaint(HDC hDC);
  59. virtual void OnClick(POINT point, WPARAM fwKeys, BOOL bLeft);
  60. virtual void OnMouseOver(POINT point, WPARAM fwKeys);
  61. virtual LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  62. private:
  63. enum CONFIGSTATE {CFGSTATE_NORMAL, CFGSTATE_ASSIGN};
  64. // HWND m_hWnd; // handle to the page dialog window
  65. LONG m_cRef; //reference count
  66. LPDIACTIONFORMATW m_lpDiac;
  67. DIDEVICEINSTANCEW m_didi;
  68. LPDIRECTINPUTDEVICE8W m_lpDID;
  69. CUIGlobals *m_puig;
  70. IDIConfigUIFrameWindow *m_pUIFrame;
  71. CONFIGSTATE m_State;
  72. // device ui
  73. CDeviceUI *m_pDeviceUI;
  74. CDeviceControl *m_pCurControl;
  75. virtual void DeviceUINotify(const DEVICEUINOTIFY &);
  76. virtual BOOL IsControlMapped(CDeviceControl *);
  77. // ui logic
  78. void SetCurrentControl(CDeviceControl *pControl);
  79. void NullAction(LPDIACTIONW lpac);
  80. void UnassignControl(CDeviceControl *pControl);
  81. friend void CallUnassignControl(CDeviceControl *pControl, LPVOID pVoid, BOOL bFixed);
  82. void UnassignAction(LPDIACTIONW lpac);
  83. void UnassignSpecificAction(LPDIACTIONW lpac);
  84. void UnassignActionsAssignedTo(const GUID &guidInstance, DWORD dwOffset);
  85. void AssignCurrentControlToAction(LPDIACTIONW lpac);
  86. void ActionClick(LPDIACTIONW lpac);
  87. void EnterAssignState();
  88. void ExitAssignState();
  89. void UnassignCallout();
  90. void SetAppropriateDefaultText();
  91. void GlobalUnassignControlAt(const GUID &, DWORD);
  92. void SetControlAssignments();
  93. void ShowCurrentControlAssignment();
  94. CBitmap *m_pbmRelAxesGlyph;
  95. CBitmap *m_pbmAbsAxesGlyph;
  96. CBitmap *m_pbmButtonGlyph;
  97. CBitmap *m_pbmHatGlyph;
  98. CBitmap *m_pbmCheckGlyph;
  99. CBitmap *m_pbmCheckGlyphDark;
  100. CBitmap *m_pbmIB;
  101. CBitmap *m_pbmIB2;
  102. void InitResources();
  103. void FreeResources();
  104. RECT m_rectIB;
  105. RECT m_rectIBLeft;
  106. RECT m_rectIBRight;
  107. LPTSTR m_tszIBText;
  108. POINT m_ptIBOffset;
  109. POINT m_ptIBOffset2;
  110. RECT m_rectIBText;
  111. void InitIB();
  112. CViewSelWnd m_ViewSelWnd;
  113. void DoViewSel();
  114. CFlexTree m_Tree;
  115. CFTItem *m_pRelAxesParent, *m_pAbsAxesParent, *m_pButtonParent, *m_pHatParent, *m_pUnknownParent;
  116. void ClearTree();
  117. void InitTree(BOOL bForceInit = FALSE);
  118. DWORD m_dwLastControlType;
  119. CFTItem *GetItemForActionAssignedToControl(CDeviceControl *pControl);
  120. int GetNumItemLpacs(CFTItem *pItem);
  121. LPDIACTIONW GetItemLpac(CFTItem *pItem, int i = 0);
  122. typedef CArray<LPDIACTIONW, LPDIACTIONW &> RGLPDIACW;
  123. // GetItemWithActionNameAndSemType returns an item with the specified action name and semantic type. NULL if none.
  124. CFTItem *GetItemWithActionNameAndSemType(LPCWSTR acname, DWORD dwSemantic);
  125. BOOL IsActionAssignedHere(int index);
  126. // quick fix for offset->objid change:
  127. void SetInvalid(LPDIACTIONW);
  128. DWORD GetOffset(LPDIACTIONW);
  129. void SetOffset(LPDIACTIONW, DWORD);
  130. bidirlookup<DWORD, DWORD> offset_objid;
  131. HRESULT InitLookup();
  132. // dropdowns
  133. CFlexComboBox m_UserNames, m_Genres;
  134. // Information window
  135. CFlexInfoBox m_InfoBox;
  136. // Sort Assigned check box for keyboard devices
  137. CFlexCheckBox m_CheckBox;
  138. // device control
  139. DWORD m_cbDeviceDataSize;
  140. DWORD *m_pDeviceData[2];
  141. int m_nOnDeviceData;
  142. BOOL m_bFirstDeviceData;
  143. void InitDevice();
  144. void DeviceTimer();
  145. static void CALLBACK DeviceTimerProc(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
  146. void DeviceDelta(DWORD *pData, DWORD *pOldData);
  147. void AxisDelta(const DIDEVICEOBJECTINSTANCEW &doi, BOOL data, BOOL old);
  148. void ButtonDelta(const DIDEVICEOBJECTINSTANCEW &doi, DWORD data, DWORD old);
  149. void PovDelta(const DIDEVICEOBJECTINSTANCEW &doi, DWORD data, DWORD old);
  150. void ActivateObject(const DIDEVICEOBJECTINSTANCEW &doi);
  151. void DeactivateObject(const DIDEVICEOBJECTINSTANCEW &doi);
  152. bidirlookup<DWORD, int> objid_avai;
  153. typedef CArray<int, int &> AxisValueArray;
  154. CArray<AxisValueArray, AxisValueArray &> m_AxisValueArray;
  155. void StoreAxisDeltaAndCalcSignificance(const DIDEVICEOBJECTINSTANCEW &doi, DWORD data, DWORD olddata, BOOL &bSig, BOOL &bOldSig);
  156. // page index
  157. int m_nPageIndex;
  158. };
  159. #endif //__CDIACPAGE_H__
  160. #endif // FORWARD_DECLS