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.

237 lines
6.5 KiB

  1. //===========================================================================
  2. // CPLSVR1.H
  3. //===========================================================================
  4. //===========================================================================
  5. // (C) Copyright 1997 Microsoft Corp. All rights reserved.
  6. //
  7. // You have a royalty-free right to use, modify, reproduce and
  8. // distribute the Sample Files (and/or any modified version) in
  9. // any way you find useful, provided that you agree that
  10. // Microsoft has no warranty obligations or liability for any
  11. // Sample Application Files which are modified.
  12. //===========================================================================
  13. //---------------------------------------------------------------------------
  14. // Comment out to remove FORCE_FEEDBACK PAGE!
  15. //#define FORCE_FEEDBACK
  16. #ifndef _CPLSVR1_H
  17. #define _CPLSVR1_H
  18. //---------------------------------------------------------------------------
  19. #define INC_OLE2
  20. #define DIRECTINPUT_VERSION 0x05B2
  21. #ifndef PPVOID
  22. #define PPVOID LPVOID*
  23. #endif
  24. // included headers
  25. #define STRICT
  26. #include <afxcmn.h>
  27. #include <windows.h>
  28. #include <objbase.h>
  29. #ifndef _UNICODE
  30. #include <afxconv.h>
  31. #endif
  32. #include <dinput.h>
  33. #include <dinputd.h>
  34. #include "dicpl.h"
  35. #include "resource.h"
  36. #include "resrc1.h"
  37. #include <assert.h>
  38. #include "joyarray.h"
  39. #include <mmsystem.h>
  40. // symbolic constants
  41. #define ID_POLLTIMER 50
  42. #ifdef FORCE_FEEDBACK
  43. #define NUMPAGES 3
  44. #else
  45. #define NUMPAGES 2
  46. #endif // FORCE_FEEDBACK
  47. // defines for calibration proc
  48. #define MAX_STR_LEN 256
  49. #define STR_LEN_128 128
  50. #define STR_LEN_64 64
  51. #define STR_LEN_32 32
  52. // defines for the progress controls
  53. #define NUM_WNDS MAX_AXIS - 2
  54. #define Z_INDEX 0
  55. #define RX_INDEX 1
  56. #define RY_INDEX 2
  57. #define RZ_INDEX 3
  58. #define S0_INDEX 4
  59. #define S1_INDEX 5
  60. // Defines for DrawCross()
  61. #define JOYMOVE_DRAWXY 0x00000001
  62. #define JOYMOVE_DRAWR 0x00000002
  63. #define JOYMOVE_DRAWZ 0x00000004
  64. #define JOYMOVE_DRAWU 0x00000008
  65. #define JOYMOVE_DRAWV 0x00000010
  66. #define JOYMOVE_DRAWALL JOYMOVE_DRAWXY | JOYMOVE_DRAWR | JOYMOVE_DRAWZ | JOYMOVE_DRAWU | JOYMOVE_DRAWV
  67. #define CAL_HIT 0x0001
  68. #define RUDDER_HIT 0x0002
  69. #define CALIBRATING 0x0004
  70. #define POV_MIN 0
  71. #define POV_MAX 1
  72. #define HAS_CALIBRATED 0x40
  73. #define FORCE_POV_REFRESH 254
  74. void DoTestPOV ( BYTE nPov, PDWORD pdwPOV, HWND hDlg ); //in test.cpp
  75. void CalibratePolledPOV( LPJOYREGHWCONFIG pHWCfg ); //in test.cpp
  76. extern BOOL bPolledPOV; //in cplsvr1.h
  77. extern DWORD myPOV[2][JOY_POV_NUMDIRS+1]; //in cplsvr1.h
  78. typedef struct _CPLPAGEINFO
  79. {
  80. //LPTSTR lpwszDlgTemplate;
  81. USHORT lpwszDlgTemplate;
  82. DLGPROC fpPageProc;
  83. } CPLPAGEINFO;
  84. // Pop the structure packing
  85. //#include <poppack.h>
  86. typedef struct _STATEFLAGS
  87. {
  88. int nButtons;
  89. BYTE nAxis;
  90. BYTE nPOVs;
  91. } STATEFLAGS;
  92. // prototypes
  93. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, PPVOID ppv);
  94. STDAPI DllCanUnloadNow(void);
  95. // dialog callback functions
  96. INT_PTR CALLBACK Settings_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  97. INT_PTR CALLBACK Test_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  98. #ifdef FORCE_FEEDBACK
  99. INT_PTR CALLBACK ForceFeedback_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  100. #endif // FORCE_FEEDBACK
  101. extern ATOM RegisterCustomButtonClass();
  102. void myitoa(long n, LPTSTR lpStr); // held in cal.cpp
  103. void CreatePens( void );
  104. #ifdef _UNICODE
  105. void RegisterForDevChange(HWND hDlg, PVOID *hNotifyDevNode);
  106. #endif
  107. // As the names imply, I had to create my own stucts because
  108. // the DI ones doesn't support sliders!
  109. typedef struct myjoypos_tag {
  110. long dwX;
  111. long dwY;
  112. long dwZ;
  113. long dwRx;
  114. long dwRy;
  115. long dwRz;
  116. long dwS0;
  117. long dwS1;
  118. } MYJOYPOS, FAR *LPMYJOYPOS;
  119. typedef struct myjoyrange_tag {
  120. MYJOYPOS jpMin;
  121. MYJOYPOS jpMax;
  122. MYJOYPOS jpCenter;
  123. #ifdef WE_SUPPORT_CALIBRATING_POVS
  124. DWORD dwPOV[4]; // Currently only supports 1 POV w/4 possitions!
  125. #endif
  126. } MYJOYRANGE,FAR *LPMYJOYRANGE;
  127. // utility services
  128. void DrawCross ( const HWND hwnd, LPPOINTS pPoint, short nFlag);
  129. void DoJoyMove ( const HWND hDlg, BYTE nDrawFlags );
  130. void SetOEMWindowText( const HWND hDlg, const short *nControlIDs, LPCTSTR *pszLabels, LPCWSTR wszType, LPDIRECTINPUTJOYCONFIG pdiJoyConfig, BYTE nCount );
  131. // Wizard Services!
  132. short CreateWizard(const HWND hwndOwner, LPARAM lParam);
  133. //* NULL_GUID {00000000-0000-0000-0000-000000000000}
  134. const GUID NULL_GUID =
  135. { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } };
  136. // derive a new class from CDIGameCntrlPropSheet
  137. //
  138. // we want to store some additional data here
  139. class CDIGameCntrlPropSheet_X : public IDIGameCntrlPropSheet
  140. {
  141. private:
  142. BYTE m_cProperty_refcount;
  143. BYTE m_nID;
  144. BOOL m_bUser;
  145. public:
  146. CDIGameCntrlPropSheet_X(void);
  147. ~CDIGameCntrlPropSheet_X(void);
  148. // IUnknown methods
  149. virtual STDMETHODIMP QueryInterface(REFIID, PPVOID);
  150. virtual STDMETHODIMP_(ULONG) AddRef(void);
  151. virtual STDMETHODIMP_(ULONG) Release(void);
  152. // IDIGameCntrlPropSheet methods
  153. virtual STDMETHODIMP GetSheetInfo(LPDIGCSHEETINFO *ppSheetInfo);
  154. virtual STDMETHODIMP GetPageInfo (LPDIGCPAGEINFO *ppPageInfo );
  155. virtual STDMETHODIMP SetID(USHORT nID);
  156. virtual STDMETHODIMP_(USHORT) GetID(void) {return m_nID;}
  157. virtual STDMETHODIMP Initialize(void);
  158. virtual STDMETHODIMP SetDevice(LPDIRECTINPUTDEVICE2 pdiDevice2);
  159. virtual STDMETHODIMP GetDevice(LPDIRECTINPUTDEVICE2 *ppdiDevice2);
  160. virtual STDMETHODIMP SetJoyConfig(LPDIRECTINPUTJOYCONFIG pdiJoyCfg);
  161. virtual STDMETHODIMP GetJoyConfig(LPDIRECTINPUTJOYCONFIG *ppdiJoyCfg);
  162. virtual STDMETHODIMP_(STATEFLAGS *) GetStateFlags(void) {return m_pStateFlags;}
  163. virtual STDMETHODIMP_(BOOL) GetUser() {return m_bUser;}
  164. virtual STDMETHODIMP SetUser(BOOL bUser) { m_bUser = bUser; return S_OK;}
  165. protected:
  166. DIGCSHEETINFO *m_pdigcSheetInfo;
  167. DIGCPAGEINFO *m_pdigcPageInfo;
  168. LPDIRECTINPUTDEVICE2 m_pdiDevice2;
  169. LPDIRECTINPUTJOYCONFIG m_pdiJoyCfg;
  170. STATEFLAGS *m_pStateFlags;
  171. ATOM m_aPovClass, m_aButtonClass;
  172. };
  173. //---------------------------------------------------------------------------
  174. #endif // _CPLSVR1_H