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.

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