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.

786 lines
23 KiB

  1. //===========================================================================
  2. // CPLSVR1.CPP
  3. //
  4. // Simple sample "Game Controllers" control panel extension server.
  5. //
  6. // Functions:
  7. // DLLMain()
  8. // DllGetClassObject()
  9. // DllCanUnloadNow()
  10. // CServerClassFactory::CServerClassFactory()
  11. // CServerClassFactory::~CServerClassFactory()
  12. // CServerClassFactory::QueryInterface()
  13. // CServerClassFactory::AddRef()
  14. // CServerClassFactory::Release()
  15. // CServerClassFactory::CreateInstance()
  16. // CServerClassFactory::LockServer()
  17. // CDIGameCntrlPropSheet_X::CDIGameCntrlPropSheet_X()
  18. // CDIGameCntrlPropSheet_X::~CDIGameCntrlPropSheet_X()
  19. // CDIGameCntrlPropSheet_X::QueryInterface()
  20. // CDIGameCntrlPropSheet_X::AddRef()
  21. // CDIGameCntrlPropSheet_X::Release()
  22. // CDIGameCntrlPropSheet_X::GetSheetInfo()
  23. // CDIGameCntrlPropSheet_X::GetPageInfo()
  24. // CDIGameCntrlPropSheet_X::SetID()
  25. // CDIGameCntrlPropSheet_X::Initialize()
  26. // CDIGameCntrlPropSheet_X::SetDevice()
  27. // CDIGameCntrlPropSheet_X::GetDevice()
  28. // CDIGameCntrlPropSheet_X::SetJoyConfig()
  29. // CDIGameCntrlPropSheet_X::GetJoyConfig()
  30. //
  31. //===========================================================================
  32. //===========================================================================
  33. // (C) Copyright 1997 Microsoft Corp. All rights reserved.
  34. //
  35. // You have a royalty-free right to use, modify, reproduce and
  36. // distribute the Sample Files (and/or any modified version) in
  37. // any way you find useful, provided that you agree that
  38. // Microsoft has no warranty obligations or liability for any
  39. // Sample Application Files which are modified.
  40. //===========================================================================
  41. #define INITGUID
  42. #define STRICT
  43. #include "cplsvr1.h"
  44. #include "pov.h"
  45. #include "assert.h"
  46. //---------------------------------------------------------------------------
  47. // file global variables
  48. static BYTE glDLLRefCount = 0; // DLL reference count
  49. static LONG glServerLocks = 0; // Count of locks
  50. CDIGameCntrlPropSheet_X *pdiCpl;
  51. HINSTANCE ghInst;
  52. CRITICAL_SECTION gcritsect;
  53. DWORD myPOV[2][JOY_POV_NUMDIRS+1];
  54. BOOL bPolledPOV;
  55. //---------------------------------------------------------------------------
  56. // LegacyServer GUID!!!
  57. // {92187326-72B4-11d0-A1AC-0000F8026977}
  58. DEFINE_GUID(CLSID_LegacyServer,
  59. 0x92187326, 0x72b4, 0x11d0, 0xa1, 0xac, 0x0, 0x0, 0xf8, 0x2, 0x69, 0x77);
  60. //---------------------------------------------------------------------------
  61. //===========================================================================
  62. // DLLMain
  63. //
  64. // DLL entry point.
  65. //
  66. // Parameters:
  67. // HINSTANCE hInst - the DLL's instance handle
  68. // DWORD dwReason - reason why DLLMain was called
  69. // LPVOID lpvReserved -
  70. //
  71. // Returns:
  72. // BOOL - TRUE if succeeded
  73. //
  74. //===========================================================================
  75. int APIENTRY DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpvReserved)
  76. {
  77. switch (dwReason)
  78. {
  79. case DLL_PROCESS_ATTACH:
  80. ghInst = hInst;
  81. InitializeCriticalSection(&gcritsect);
  82. break;
  83. case DLL_PROCESS_DETACH:
  84. DeleteCriticalSection(&gcritsect);
  85. break;
  86. case DLL_THREAD_ATTACH:
  87. DisableThreadLibraryCalls((HMODULE)hInst);
  88. case DLL_THREAD_DETACH:
  89. break;
  90. } //** end switch(dwReason)
  91. return TRUE;
  92. } //*** end DLLMain()
  93. //===========================================================================
  94. // DllGetClassObject
  95. //
  96. // Gets an IClassFactory object.
  97. //
  98. // Parameters:
  99. // REFCLSID rclsid - CLSID value (by reference)
  100. // REFIID riid - IID value (by reference)
  101. // PPVOID ppv - ptr to store interface ptr
  102. //
  103. // Returns:
  104. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  105. //
  106. //===========================================================================
  107. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, PPVOID ppv)
  108. {
  109. // did the caller pass in our CLSID?
  110. if(!IsEqualCLSID(rclsid, CLSID_LegacyServer))
  111. {
  112. // no, return class not available error
  113. return CLASS_E_CLASSNOTAVAILABLE;
  114. }
  115. // did the caller request our class factory?
  116. if(!IsEqualIID(riid, IID_IClassFactory))
  117. {
  118. // no, return no interface error
  119. return E_NOINTERFACE;
  120. }
  121. // instantiate class factory object
  122. CServerClassFactory *pClsFactory = new CServerClassFactory();
  123. if (NULL == pClsFactory)
  124. {
  125. // could not create the object
  126. //
  127. // chances are we were out of memory
  128. return E_OUTOFMEMORY;
  129. }
  130. // query for interface riid, and return it via ppv
  131. HRESULT hRes = pClsFactory->QueryInterface(riid, ppv);
  132. // we're finished with our local object
  133. pClsFactory->Release();
  134. // return the result code from QueryInterface
  135. return hRes;
  136. } //*** end DllGetClassObject()
  137. //===========================================================================
  138. // DllCanUnloadNow
  139. //
  140. // Reports whether or not the DLL can be unloaded.
  141. //
  142. // Parameters: none
  143. //
  144. // Returns
  145. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  146. //
  147. //===========================================================================
  148. STDAPI DllCanUnloadNow(void)
  149. {
  150. // unloading should be safe if the global dll refcount is zero and server lock ref is 0
  151. return (glDLLRefCount == 0 && glServerLocks == 0) ? S_OK : S_FALSE;
  152. } //*** end DllCanUnloadNow()
  153. //===========================================================================
  154. // CServerClassFactory::CServerClassFactory
  155. //
  156. // Class constructor.
  157. //
  158. // Parameters: none
  159. //
  160. // Returns:
  161. // CServerClassFactory* (implicit)
  162. //
  163. //===========================================================================
  164. CServerClassFactory::CServerClassFactory(void)
  165. {
  166. // initialize and increment the object refcount
  167. m_ServerCFactory_refcount = 0;
  168. AddRef();
  169. // increment the dll refcount
  170. InterlockedIncrement((LPLONG)&glDLLRefCount);
  171. } //*** end CServerClassFactory::CServerClassFactory()
  172. //===========================================================================
  173. // CServerClassFactory::CServerClassFactory
  174. //
  175. // Class constructor.
  176. //
  177. // Parameters: none
  178. //
  179. // Returns:
  180. // CServerClassFactory* (implicit)
  181. //
  182. //===========================================================================
  183. CServerClassFactory::~CServerClassFactory(void)
  184. {
  185. // decrement the dll refcount
  186. InterlockedDecrement((LPLONG)&glDLLRefCount);
  187. } //*** end CServerClassFactory::~CServerClassFactory()
  188. //===========================================================================
  189. // CServerClassFactory::QueryInterface
  190. //
  191. // Implementation of the QueryInterface() method.
  192. //
  193. // Parameters:
  194. // REFIID riid - the interface that is being looked for
  195. // PPVOID ppv - pointer to target interface pointer
  196. //
  197. // Returns:
  198. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  199. //
  200. //===========================================================================
  201. STDMETHODIMP CServerClassFactory::QueryInterface(REFIID riid, PPVOID ppv)
  202. {
  203. // make sure that if anything fails, we return something reasonable
  204. *ppv = NULL;
  205. // we support IUnknown...
  206. if (IsEqualIID(riid, IID_IUnknown))
  207. {
  208. // return our object as an IUnknown
  209. *ppv = (LPUNKNOWN)(LPCLASSFACTORY)this;
  210. }
  211. else
  212. {
  213. // ... and our interface
  214. if (IsEqualIID(riid, IID_IClassFactory))
  215. // return our object as a class factory
  216. *ppv = (LPCLASSFACTORY)this;
  217. else
  218. // we do not support any other interfaces
  219. return E_NOINTERFACE;
  220. }
  221. // we got this far, so we've succeeded
  222. // increment our refcount and return
  223. AddRef();
  224. return S_OK;
  225. } //*** end CServerClassFactory::QueryInterface()
  226. //===========================================================================
  227. // CServerClassFactory::AddRef
  228. //
  229. // Implementation of the AddRef() method.
  230. //
  231. // Parameters: none
  232. //
  233. // Returns:
  234. // ULONG - updated reference count.
  235. // NOTE: apps should NOT rely on this value!
  236. //
  237. //===========================================================================
  238. STDMETHODIMP_(ULONG) CServerClassFactory::AddRef(void)
  239. {
  240. // update and return our object's reference count
  241. InterlockedIncrement((LPLONG)&m_ServerCFactory_refcount);
  242. return m_ServerCFactory_refcount;
  243. } //*** end CServerClassFactory::AddRef()
  244. //===========================================================================
  245. // CServerClassFactory::Release
  246. //
  247. // Implementation of the Release() method.
  248. //
  249. // Parameters: none
  250. //
  251. // Returns:
  252. // ULONG - updated reference count.
  253. // NOTE: apps should NOT rely on this value!
  254. //
  255. //===========================================================================
  256. STDMETHODIMP_(ULONG) CServerClassFactory::Release(void)
  257. {
  258. // update and return our object's reference count
  259. InterlockedDecrement((LPLONG)&m_ServerCFactory_refcount);
  260. if (0 == m_ServerCFactory_refcount)
  261. {
  262. // it's now safe to call the destructor
  263. delete this;
  264. return 0;
  265. }
  266. else return m_ServerCFactory_refcount;
  267. } //*** end CServerClassFactory::Release()
  268. //===========================================================================
  269. // CServerClassFactory::CreateInstance
  270. //
  271. // Implementation of the CreateInstance() method.
  272. //
  273. // Parameters: none
  274. //
  275. // Returns:
  276. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  277. //
  278. //===========================================================================
  279. STDMETHODIMP CServerClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, PPVOID ppvObj)
  280. {
  281. CDIGameCntrlPropSheet_X *pdiGCPropSheet = NULL;
  282. HRESULT hRes = E_NOTIMPL;
  283. // make sure that if anything fails, we return something reasonable
  284. *ppvObj = NULL;
  285. // we want pUnkOuter to be NULL
  286. //
  287. // we do not support aggregation
  288. if (pUnkOuter != NULL)
  289. {
  290. // tell the caller that we do not support this feature
  291. return CLASS_E_NOAGGREGATION;
  292. }
  293. // Create a new instance of the game controller property sheet object
  294. pdiGCPropSheet = new CDIGameCntrlPropSheet_X();
  295. if (NULL == pdiGCPropSheet)
  296. {
  297. // we could not create our object
  298. // chances are, we have run out of memory
  299. return E_OUTOFMEMORY;
  300. }
  301. // initialize the object (memory allocations, etc)
  302. if (SUCCEEDED(pdiGCPropSheet->Initialize()))
  303. // query for interface riid, and return it via ppvObj
  304. hRes = pdiGCPropSheet->QueryInterface(riid, ppvObj);
  305. // release the local object
  306. pdiGCPropSheet->Release();
  307. // all done, return result from QueryInterface
  308. return hRes;
  309. } //*** end CServerClassFactory::CreateInstance()
  310. //===========================================================================
  311. // CServerClassFactory::LockServer
  312. //
  313. // Implementation of the LockServer() method.
  314. //
  315. // Parameters: none
  316. //
  317. // Returns:
  318. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  319. //
  320. //===========================================================================
  321. STDMETHODIMP CServerClassFactory::LockServer(BOOL fLock)
  322. {
  323. //HRESULT hRes = E_NOTIMPL;
  324. // increment/decrement based on fLock
  325. if (fLock)
  326. InterlockedIncrement((LPLONG)&glDLLRefCount);
  327. else
  328. InterlockedDecrement((LPLONG)&glDLLRefCount);
  329. // all done
  330. return S_OK;
  331. } //*** end CServerClassFactory::LockServer()
  332. //===========================================================================
  333. // CDIGameCntrlPropSheet_X::CDIGameCntrlPropSheet_X
  334. //
  335. // Class constructor.
  336. //
  337. // Parameters: none
  338. //
  339. // Returns: nothing
  340. //
  341. //===========================================================================
  342. CDIGameCntrlPropSheet_X::CDIGameCntrlPropSheet_X(void)
  343. {
  344. // initialize and increment the object refcount
  345. m_cProperty_refcount = 0;
  346. AddRef();
  347. // initialize our device id to -1 just to be safe
  348. m_nID = (BYTE)-1;
  349. // init
  350. m_bUser = FALSE;
  351. // initialize all of our pointers
  352. m_pdigcPageInfo = NULL;
  353. m_pdiDevice2 = NULL;
  354. m_pdiJoyCfg = NULL;
  355. pdiCpl = NULL;
  356. // increment the dll refcount
  357. InterlockedIncrement((LPLONG)&glDLLRefCount);
  358. // Register the POV hat class
  359. m_aPovClass = RegisterPOVClass();
  360. // Register the custom Button class
  361. m_aButtonClass = RegisterCustomButtonClass();
  362. } //*** end CDIGameCntrlPropSheet_X::CDIGameCntrlPropSheet_X()
  363. //===========================================================================
  364. // CDIGameCntrlPropSheet_X::~CDIGameCntrlPropSheet_X
  365. //
  366. // Class destructor.
  367. //
  368. // Parameters: none
  369. //
  370. // Returns: nothing
  371. //
  372. //===========================================================================
  373. CDIGameCntrlPropSheet_X::~CDIGameCntrlPropSheet_X(void)
  374. {
  375. // free the DIGCPAGEINFO memory
  376. if (m_pdigcPageInfo)
  377. LocalFree(m_pdigcPageInfo);
  378. // free the DIGCSHEETINFO memory
  379. if (m_pdigcSheetInfo)
  380. LocalFree(m_pdigcSheetInfo);
  381. // free up the StateFlags memory!
  382. if (m_pStateFlags)
  383. delete (m_pStateFlags);
  384. // cleanup directinput objects
  385. // m_pdiDevice2
  386. if (m_pdiDevice2)
  387. {
  388. m_pdiDevice2->Unacquire();
  389. m_pdiDevice2->Release();
  390. m_pdiDevice2 = NULL;
  391. }
  392. // m_pdiJoyCfg
  393. if (m_pdiJoyCfg)
  394. {
  395. m_pdiJoyCfg->Unacquire();
  396. m_pdiJoyCfg->Release();
  397. m_pdiJoyCfg = NULL;
  398. }
  399. // Unregister the classes!!!
  400. if (m_aPovClass)
  401. UnregisterClass((LPCTSTR)m_aPovClass, ghInst);
  402. if (m_aButtonClass)
  403. UnregisterClass((LPCTSTR)m_aButtonClass, ghInst);
  404. // decrement the dll refcount
  405. InterlockedDecrement((LPLONG)&glDLLRefCount);
  406. } //*** end CDIGameCntrlPropSheet_X::~CDIGameCntrlPropSheet_X()
  407. //===========================================================================
  408. // CDIGameCntrlPropSheet_X::QueryInterface
  409. //
  410. // Implementation of the QueryInterface() method.
  411. //
  412. // Parameters:
  413. // REFIID riid - the interface that is being looked for
  414. // PPVOID ppv - pointer to target interface pointer
  415. //
  416. // Returns:
  417. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  418. //
  419. //===========================================================================
  420. STDMETHODIMP CDIGameCntrlPropSheet_X::QueryInterface(REFIID riid, PPVOID ppv)
  421. {
  422. // make sure that if anything fails, we return something reasonable
  423. *ppv = NULL;
  424. // we support IUnknown...
  425. if(IsEqualIID(riid, IID_IUnknown))
  426. {
  427. *ppv = (LPUNKNOWN)(LPCDIGAMECNTRLPROPSHEET)this;
  428. }
  429. else
  430. {
  431. // ... and IID_IDIGameCntrlPropSheet
  432. if(IsEqualIID(riid, IID_IDIGameCntrlPropSheet))
  433. *ppv = (LPCDIGAMECNTRLPROPSHEET)this;
  434. else
  435. // we do not support any other interfaces
  436. return E_NOINTERFACE;
  437. }
  438. // we got this far, so we've succeeded
  439. // increment our refcount and return
  440. AddRef();
  441. return S_OK;
  442. } //*** end CDIGameCntrlPropSheet_X::QueryInterface()
  443. //===========================================================================
  444. // CDIGameCntrlPropSheet_X::AddRef
  445. //
  446. // Implementation of the AddRef() method.
  447. //
  448. // Parameters: none
  449. //
  450. // Returns:
  451. // ULONG - updated reference count.
  452. // NOTE: apps should NOT rely on this value!
  453. //===========================================================================
  454. STDMETHODIMP_(ULONG) CDIGameCntrlPropSheet_X::AddRef(void)
  455. {
  456. // update and return our object's reference count
  457. InterlockedIncrement((LPLONG)&m_cProperty_refcount);
  458. return m_cProperty_refcount;
  459. } //*** end CDIGameCntrlPropSheet_X::AddRef()
  460. //===========================================================================
  461. // CDIGameCntrlPropSheet_X::Release
  462. //
  463. // Implementation of the Release() method.
  464. //
  465. // Parameters: none
  466. //
  467. // Returns:
  468. // ULONG - updated reference count.
  469. // NOTE: apps should NOT rely on this value!
  470. //===========================================================================
  471. STDMETHODIMP_(ULONG) CDIGameCntrlPropSheet_X::Release(void)
  472. {
  473. // update and return our object's reference count
  474. InterlockedDecrement((LPLONG)&m_cProperty_refcount);
  475. if (m_cProperty_refcount)
  476. return m_cProperty_refcount;
  477. // it's now safe to call the destructor
  478. delete this;
  479. return S_OK;
  480. } //*** end CDIGameCntrlPropSheet_X::Release()
  481. //===========================================================================
  482. // CDIGameCntrlPropSheet_X::GetSheetInfo
  483. //
  484. // Implementation of the GetSheetInfo() method.
  485. //
  486. // Parameters:
  487. // LPDIGCSHEETINFO *ppSheetInfo - ptr to DIGCSHEETINFO struct ptr
  488. //
  489. // Returns:
  490. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  491. //===========================================================================
  492. STDMETHODIMP CDIGameCntrlPropSheet_X::GetSheetInfo(LPDIGCSHEETINFO *ppSheetInfo)
  493. {
  494. // pass back the our sheet information
  495. *ppSheetInfo = m_pdigcSheetInfo;
  496. // all done here
  497. return S_OK;
  498. } //*** end CDIGameCntrlPropSheet_X::GetSheetInfo()
  499. //===========================================================================
  500. // CDIGameCntrlPropSheet_X::GetPageInfo
  501. //
  502. // Implementation of the GetPageInfo() method.
  503. //
  504. // NOTE: This returns the information for ALL pages. There is no mechanism
  505. // in place to request only page n's DIGCPAGEINFO.
  506. //
  507. // Parameters:
  508. // LPDIGCPAGEINFO *ppPageInfo - ptr to DIGCPAGEINFO struct ptr
  509. //
  510. // Returns:
  511. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  512. //===========================================================================
  513. STDMETHODIMP CDIGameCntrlPropSheet_X::GetPageInfo(LPDIGCPAGEINFO *ppPageInfo)
  514. {
  515. // pass back the our page information
  516. *ppPageInfo = m_pdigcPageInfo;
  517. // all done here
  518. return S_OK;
  519. } //*** end CDIGameCntrlPropSheet_X::GetPageInfo()
  520. //===========================================================================
  521. // CDIGameCntrlPropSheet_X::SetID
  522. //
  523. // Implementation of the SetID() method.
  524. //
  525. // Parameters:
  526. // USHORT nID - identifier to set
  527. //
  528. // Returns:
  529. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  530. //===========================================================================
  531. STDMETHODIMP CDIGameCntrlPropSheet_X::SetID(USHORT nID)
  532. {
  533. // store the device id
  534. m_nID = (BYTE)nID;
  535. return S_OK;
  536. } //*** end CDIGameCntrlPropSheet_X::SetID()
  537. //===========================================================================
  538. // CDIGameCntrlPropSheet::Initialize
  539. //
  540. // Implementation of the Initialize() method.
  541. //
  542. // Parameters: none
  543. //
  544. // Returns:
  545. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  546. //===========================================================================
  547. HRESULT CDIGameCntrlPropSheet_X::Initialize(void)
  548. {
  549. // provide the following information for each device page
  550. // { dialog template, callback function pointer }
  551. CPLPAGEINFO grgcpInfo[NUMPAGES] = {
  552. IDD_SETTINGS,
  553. (DLGPROC)Settings_DlgProc,
  554. IDD_TEST,
  555. (DLGPROC)Test_DlgProc
  556. #ifdef FORCE_FEEDBACK
  557. , // Template DlgProc
  558. IDD_FORCEFEEDBACK,
  559. (DLGPROC)ForceFeedback_DlgProc
  560. #endif // FORCE_FEEDBACK
  561. };
  562. // allocate memory for the DIGCPAGEINFO structures
  563. m_pdigcPageInfo = (DIGCPAGEINFO *)LocalAlloc(LPTR, NUMPAGES * sizeof(DIGCPAGEINFO));
  564. if (!m_pdigcPageInfo){
  565. return E_OUTOFMEMORY;
  566. }
  567. m_pdigcSheetInfo = (DIGCSHEETINFO *)LocalAlloc(LPTR, sizeof(DIGCSHEETINFO));
  568. if (!m_pdigcSheetInfo) {
  569. LocalFree(m_pdigcPageInfo);
  570. return E_OUTOFMEMORY;
  571. }
  572. // populate the DIGCPAGEINFO structure for each sheet
  573. BYTE i = 0;
  574. do
  575. {
  576. m_pdigcPageInfo[i].dwSize = sizeof(DIGCPAGEINFO);
  577. m_pdigcPageInfo[i].fIconFlag = FALSE;
  578. // This is done to test JOY.CPL...
  579. // It's also better for Win9x, as it will not be required to convert it!
  580. // m_pdigcPageInfo[i].lpwszPageIcon = (LPWSTR)IDI_GCICON; //MAKEINTRESOURCE(IDI_GCICON);
  581. m_pdigcPageInfo[i].hInstance = ghInst;
  582. m_pdigcPageInfo[i].lParam = (LPARAM)this;
  583. // the following data is unique to each page
  584. m_pdigcPageInfo[i].fpPageProc = grgcpInfo[i].fpPageProc;
  585. m_pdigcPageInfo[i].lpwszTemplate = (LPWSTR)grgcpInfo[i++].lpwszDlgTemplate;
  586. } while (i < NUMPAGES);
  587. // populate the DIGCSHEETINFO structure
  588. m_pdigcSheetInfo->dwSize = sizeof(DIGCSHEETINFO);
  589. m_pdigcSheetInfo->nNumPages = NUMPAGES;
  590. m_pdigcSheetInfo->fSheetIconFlag = TRUE;
  591. m_pdigcSheetInfo->lpwszSheetIcon = (LPWSTR)IDI_GCICON; //MAKEINTRESOURCEW(IDI_GCICON);
  592. // Do that device object enumeration thing!
  593. m_pStateFlags = new (STATEFLAGS);
  594. if (!m_pStateFlags) {
  595. LocalFree(m_pdigcPageInfo);
  596. LocalFree(m_pdigcSheetInfo);
  597. return E_OUTOFMEMORY;
  598. }
  599. ZeroMemory(m_pStateFlags, sizeof(STATEFLAGS));
  600. // all done
  601. return S_OK;
  602. } //*** end CDIGameCntrlPropSheet::Initialize()
  603. //===========================================================================
  604. // CDIGameCntrlPropSheet_X::SetDevice
  605. //
  606. // Implementation of the SetDevice() method.
  607. //
  608. // Parameters:
  609. // LPDIRECTINPUTDEVICE2 pdiDevice2 - device object ptr
  610. //
  611. // Returns:
  612. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  613. //===========================================================================
  614. STDMETHODIMP CDIGameCntrlPropSheet_X::SetDevice(LPDIRECTINPUTDEVICE2 pdiDevice2)
  615. {
  616. // store the device object ptr
  617. m_pdiDevice2 = pdiDevice2;
  618. return S_OK;
  619. } //*** end CDIGameCntrlPropSheet_X::SetDevice()
  620. //===========================================================================
  621. // CDIGameCntrlPropSheet_X::GetDevice
  622. //
  623. // Implementation of the GetDevice() method.
  624. //
  625. // Parameters:
  626. // LPDIRECTINPUTDEVICE2 *ppdiDevice2 - ptr to device object ptr
  627. //
  628. // Returns:
  629. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  630. //===========================================================================
  631. STDMETHODIMP CDIGameCntrlPropSheet_X::GetDevice(LPDIRECTINPUTDEVICE2 *ppdiDevice2)
  632. {
  633. // retrieve the device object ptr
  634. *ppdiDevice2 = m_pdiDevice2;
  635. return S_OK;
  636. } //*** end CDIGameCntrlPropSheet_X::GetDevice()
  637. //===========================================================================
  638. // CDIGameCntrlPropSheet_X::SetJoyConfig
  639. //
  640. // Implementation of the SetJoyConfig() method.
  641. //
  642. // Parameters:
  643. // LPDIRECTINPUTJOYCONFIG pdiJoyCfg - joyconfig object ptr
  644. //
  645. // Returns:
  646. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  647. //===========================================================================
  648. STDMETHODIMP CDIGameCntrlPropSheet_X::SetJoyConfig(LPDIRECTINPUTJOYCONFIG pdiJoyCfg)
  649. {
  650. // store the joyconfig object ptr
  651. m_pdiJoyCfg = pdiJoyCfg;
  652. return S_OK;
  653. } //*** end CDIGameCntrlPropSheet_X::SetJoyConfig()
  654. //===========================================================================
  655. // CDIGameCntrlPropSheet_X::SetJoyConfig
  656. //
  657. // Implementation of the SetJoyConfig() method.
  658. //
  659. // Parameters:
  660. // LPDIRECTINPUTJOYCONFIG *ppdiJoyCfg - ptr to joyconfig object ptr
  661. //
  662. // Returns:
  663. // HRESULT - OLE type success/failure code (S_OK if succeeded)
  664. //===========================================================================
  665. STDMETHODIMP CDIGameCntrlPropSheet_X::GetJoyConfig(LPDIRECTINPUTJOYCONFIG *ppdiJoyCfg)
  666. {
  667. // retrieve the joyconfig object ptr
  668. *ppdiJoyCfg = m_pdiJoyCfg;
  669. return S_OK;
  670. } //*** end CDIGameCntrlPropSheet_X::GetJoyConfig()