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.

843 lines
25 KiB

  1. //===========================================================================
  2. // dmttest.cpp
  3. //
  4. // Device test functionality
  5. //
  6. // Functions:
  7. // dmttestRunIntegrated
  8. // dmttestRunMapperCPL
  9. //
  10. // History:
  11. // 08/27/1999 - davidkl - created
  12. //===========================================================================
  13. #include "dimaptst.h"
  14. #include "dmtinput.h"
  15. #include "dmtwrite.h"
  16. #include "dmtfail.h"
  17. #include "dmttest.h"
  18. #include "d3d.h"
  19. #include "assert.h"
  20. #include <tchar.h>
  21. #include <stdio.h>
  22. #include <commdlg.h>
  23. #define DIPROP_MAPFILE MAKEDIPROP(0xFFFD)
  24. //---------------------------------------------------------------------------
  25. // file global variables
  26. HANDLE ghthDeviceTest = NULL;
  27. DIDEVICEOBJECTDATA *gpdidod = NULL;
  28. HICON ghiButtonState[2];
  29. HICON ghiPovState[9];
  30. UINT_PTR g_NumSubGenres = 0;
  31. //---------------------------------------------------------------------------
  32. //===========================================================================
  33. // dmttestRunIntegrated
  34. //
  35. // Runs integrated device test, prompts for test results
  36. //
  37. // Parameters:
  38. //
  39. // Returns: HRESULT
  40. //
  41. // History:
  42. // 08/27/1999 - davidkl - created
  43. // 11/02/1999 - davidkl - now does all preparation and starts input timer
  44. // 11/10/1999 - davidkl - now allocates and populates pdmtai->pan
  45. //===========================================================================
  46. HRESULT dmttestRunIntegrated(HWND hwnd)
  47. {
  48. HRESULT hRes = S_OK;
  49. //JJ 64Bit Compat
  50. INT_PTR nIdx = -1;
  51. UINT u = 0;
  52. DWORD dw = 0;
  53. DMTDEVICE_NODE *pDevice = NULL;
  54. DMTSUBGENRE_NODE *pSubGenre = NULL;
  55. DMTMAPPING_NODE *pMapping = NULL;
  56. DMTACTION_NODE *pAction = NULL;
  57. DMT_APPINFO *pdmtai = NULL;
  58. ACTIONNAME *pan = NULL;
  59. DIACTIONA *pdia = NULL;
  60. // get the app info structure
  61. //JJ 64Bit Compat
  62. pdmtai = (DMT_APPINFO*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  63. if(!pdmtai)
  64. {
  65. return E_UNEXPECTED;
  66. }
  67. __try
  68. {
  69. // get the currently selected device
  70. nIdx = SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_LIST),
  71. CB_GETCURSEL,
  72. 0,
  73. 0L);
  74. if(-1 == nIdx)
  75. {
  76. // this is bad
  77. hRes = E_UNEXPECTED;
  78. __leave;
  79. }
  80. pDevice = (DMTDEVICE_NODE*)SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_LIST),
  81. CB_GETITEMDATA,
  82. nIdx,
  83. 0L);
  84. if(!pDevice)
  85. {
  86. // this is bad
  87. hRes = E_UNEXPECTED;
  88. __leave;
  89. }
  90. // get the currently selected genre
  91. nIdx = SendMessageA(GetDlgItem(hwnd, IDC_SUBGENRES),
  92. CB_GETCURSEL,
  93. 0,
  94. 0L);
  95. if(-1 == nIdx)
  96. {
  97. // this is bad
  98. hRes = E_UNEXPECTED;
  99. __leave;
  100. }
  101. pSubGenre = (DMTSUBGENRE_NODE*)SendMessageA(GetDlgItem(hwnd, IDC_SUBGENRES),
  102. CB_GETITEMDATA,
  103. nIdx,
  104. 0L);
  105. if(!pSubGenre)
  106. {
  107. // this is bad
  108. hRes = E_UNEXPECTED;
  109. __leave;
  110. }
  111. // match the device with the mapping node
  112. pMapping = pSubGenre->pMappingList;
  113. while(pMapping)
  114. {
  115. // is this our device's mapping info?
  116. if(IsEqualGUID(pDevice->guidInstance, pMapping->guidInstance))
  117. {
  118. break;
  119. }
  120. // next mapping node
  121. pMapping = pMapping->pNext;
  122. }
  123. if(!pMapping)
  124. {
  125. // no match found
  126. hRes = E_UNEXPECTED;
  127. __leave;
  128. }
  129. // allocate the app info's actionname list
  130. if(pdmtai->pan)
  131. {
  132. // for some reason,
  133. // we are attempting to clobber existing data!
  134. // ISSUE-2001/03/29-timgill Need to raise an error code here
  135. DebugBreak();
  136. }
  137. pdmtai->pan = (ACTIONNAME*)LocalAlloc(LMEM_FIXED, sizeof(ACTIONNAME) * pMapping->uActions);
  138. if(!(pdmtai->pan))
  139. {
  140. hRes = E_UNEXPECTED;
  141. __leave;
  142. }
  143. ZeroMemory((void*)(pdmtai->pan), sizeof(ACTIONNAME) * pMapping->uActions);
  144. pdmtai->dwActions = (DWORD)(pMapping->uActions);
  145. pan = pdmtai->pan;
  146. // allocate data buffer
  147. gpdidod = (DIDEVICEOBJECTDATA*)LocalAlloc(LMEM_FIXED,
  148. DMTINPUT_BUFFERSIZE *
  149. sizeof(DIDEVICEOBJECTDATA));
  150. if(!gpdidod)
  151. {
  152. // nothing we can do if we are out of memory
  153. DPF(0, "dmttestGetInput - unable to allocate data buffer (%d)",
  154. GetLastError());
  155. hRes = E_OUTOFMEMORY;
  156. __leave;
  157. }
  158. // setup the device
  159. hRes = dmtinputPrepDevice(hwnd,
  160. pSubGenre->dwGenreId,
  161. pDevice,
  162. pMapping->uActions,
  163. pMapping->pdia);
  164. if(FAILED(hRes))
  165. {
  166. __leave;
  167. }
  168. // populate the actionname list
  169. //
  170. // match pdia->dwSemantic with pAction->dwActionId
  171. // if found, copy pAction->szName to pdia->lptszActionName
  172. pdia = pMapping->pdia;
  173. for(u = 0; u < pMapping->uActions; u++)
  174. {
  175. (pan+u)->dw = (DWORD)/*JJ 64Bit*/(pdia+u)->uAppData;
  176. lstrcpyA((pan+u)->sz, (pdia+u)->lptszActionName);
  177. }
  178. // start the input timer
  179. DPF(4, "dmttestRunIntegrated - Starting input timer...");
  180. // ISSUE-2001/03/29-timgill Should check return value here
  181. SetTimer(hwnd,
  182. ID_POLL_TIMER,
  183. DMT_POLL_TIMEOUT,
  184. NULL);
  185. // en/disable appropriate ui elements
  186. EnableWindow(GetDlgItem(hwnd, IDOK), FALSE);
  187. EnableWindow(GetDlgItem(hwnd, IDCANCEL), TRUE);
  188. EnableWindow(GetDlgItem(hwnd, IDC_GENRES_LABEL), FALSE);
  189. EnableWindow(GetDlgItem(hwnd, IDC_DEVICE_GENRES), FALSE);
  190. EnableWindow(GetDlgItem(hwnd, IDC_ENUM_DEVICES), FALSE);
  191. EnableWindow(GetDlgItem(hwnd, IDC_DEVICES_LABEL), FALSE);
  192. EnableWindow(GetDlgItem(hwnd, IDC_DEVICE_LIST), FALSE);
  193. // EnableWindow(GetDlgItem(hwnd, IDC_CONFIGURE), FALSE);
  194. EnableWindow(GetDlgItem(hwnd, IDC_LAUNCH_CPL_EDIT_MODE), FALSE);
  195. // EnableWindow(GetDlgItem(hwnd, IDC_SAVE_STD), FALSE);
  196. EnableWindow(GetDlgItem(hwnd, IDC_SAVE_HID), FALSE);
  197. EnableWindow(GetDlgItem(hwnd, IDC_SAVE_BOTH), FALSE);
  198. EnableWindow(GetDlgItem(hwnd, IDC_START_WITH_DEFAULTS), FALSE);
  199. }
  200. __finally
  201. {
  202. // if something failed
  203. if(FAILED(hRes))
  204. {
  205. if(LocalFree((HLOCAL)(pdmtai->pan)))
  206. {
  207. // memory leak
  208. // ISSUE-2001/03/29-timgill Needs error case handling
  209. }
  210. }
  211. }
  212. // done
  213. return S_OK;
  214. } //*** end dmttestRunIntegrated()
  215. BOOL CALLBACK EnumDeviceCallback(const DIDEVICEINSTANCE *lpdidi, LPDIRECTINPUTDEVICE8 lpDID, DWORD dwFlags, DWORD dwDeviceRemaining, LPVOID hwnd)
  216. {
  217. DIPROPSTRING dips;
  218. HRESULT hr;
  219. ZeroMemory(&dips, sizeof(dips));
  220. dips.diph.dwSize = sizeof(dips);
  221. dips.diph.dwHeaderSize = sizeof(DIPROPHEADER);
  222. dips.diph.dwObj = 0;
  223. dips.diph.dwHow = DIPH_DEVICE;
  224. hr = lpDID->GetProperty(DIPROP_MAPFILE, &dips.diph);
  225. if (hr == DIERR_OBJECTNOTFOUND)
  226. {
  227. // Map file not specified. Let the use specify it.
  228. TCHAR tszMsg[MAX_PATH];
  229. _stprintf(tszMsg, _T("INI path not specified for %s. You need to specify it now."), lpdidi->tszInstanceName);
  230. MessageBox(NULL, tszMsg, _T("Error"), MB_OK);
  231. // Obstain a file name
  232. TCHAR tszFilePath[MAX_PATH] = _T("");
  233. TCHAR tszFileName[MAX_PATH];
  234. OPENFILENAME ofn;
  235. ZeroMemory(&ofn, sizeof(ofn));
  236. ofn.lStructSize = sizeof(ofn);
  237. ofn.hwndOwner = (HWND)hwnd;
  238. ofn.lpstrFilter = _T("INI Files (*.ini)\0*.ini\0All Files (*.*)\0*.*\0");
  239. ofn.lpstrFile = tszFilePath;
  240. ofn.nMaxFile = MAX_PATH;
  241. ofn.lpstrTitle = _T("INI File Path");
  242. ofn.Flags = OFN_FILEMUSTEXIST;
  243. GetOpenFileName(&ofn);
  244. // Obtain the registry key
  245. LPDIRECTINPUT8 lpDI = NULL;
  246. LPDIRECTINPUTJOYCONFIG8 lpDIJC = NULL;
  247. DIJOYCONFIG jc;
  248. DIPROPDWORD diPropDword;
  249. HKEY hkType;
  250. DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID*)&lpDI, NULL);
  251. if (lpDI)
  252. {
  253. lpDI->QueryInterface(IID_IDirectInputJoyConfig8, (LPVOID*)&lpDIJC);
  254. lpDI->Release();
  255. }
  256. if (lpDIJC)
  257. {
  258. diPropDword.diph.dwSize = sizeof( diPropDword );
  259. diPropDword.diph.dwHeaderSize = sizeof( diPropDword.diph );
  260. diPropDword.diph.dwObj = 0;
  261. diPropDword.diph.dwHow = DIPH_DEVICE;
  262. lpDID->GetProperty( DIPROP_JOYSTICKID, &diPropDword.diph );
  263. jc.dwSize = sizeof( jc );
  264. lpDIJC->GetConfig( diPropDword.dwData, &jc, DIJC_REGHWCONFIGTYPE );
  265. lpDIJC->SetCooperativeLevel((HWND)hwnd, DISCL_EXCLUSIVE|DISCL_BACKGROUND);
  266. lpDIJC->Acquire();
  267. dmtOpenTypeKey(jc.wszType, KEY_ALL_ACCESS, &hkType);
  268. // Write the INI file name
  269. RegSetValueEx(hkType, _T("OEMMapFile"), 0, REG_SZ, (LPBYTE)ofn.lpstrFile, (lstrlen(ofn.lpstrFile)+1) * sizeof(TCHAR));
  270. RegCloseKey(hkType);
  271. lpDIJC->Unacquire();
  272. lpDIJC->Release();
  273. }
  274. }
  275. return DIENUM_CONTINUE;
  276. }
  277. //===========================================================================
  278. // ModifyDiactfrmDllPath
  279. //
  280. // Modifies the path of the diactfrm.dll COM server in the registry
  281. // to same as the exe path.
  282. //
  283. // Parameters:
  284. //
  285. // Returns: TRUE if path is modified. FALSE if an error occurred.
  286. //
  287. // History:
  288. // 08/02/2001 - jacklin - created
  289. //===========================================================================
  290. static BOOL ModifyDiactfrmDllPath()
  291. {
  292. const TCHAR tszFrmwrkPath[] = _T("SOFTWARE\\Classes\\CLSID\\{18AB439E-FCF4-40D4-90DA-F79BAA3B0655}\\InProcServer32");
  293. const TCHAR tszPagePath[] = _T("SOFTWARE\\Classes\\CLSID\\{9F34AF20-6095-11D3-8FB2-00C04F8EC627}\\InProcServer32");
  294. HKEY hKey;
  295. LONG lResult;
  296. // Construct the full path of the DLL using current exe path.
  297. TCHAR tszNewPath[MAX_PATH];
  298. if (!GetModuleFileName(NULL, tszNewPath, MAX_PATH))
  299. {
  300. return FALSE;
  301. }
  302. TCHAR *pcLastSlash;
  303. pcLastSlash = _tcsrchr(tszNewPath, _T('\\'));
  304. // Replace the exe name with diactfrm.dll
  305. lstrcpy(pcLastSlash + 1, _T("diactfrm.dll"));
  306. // Check that the DLL exists
  307. HANDLE hDllFile = CreateFile(tszNewPath, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
  308. FILE_ATTRIBUTE_NORMAL, NULL);
  309. if (hDllFile == INVALID_HANDLE_VALUE)
  310. return FALSE;
  311. CloseHandle(hDllFile);
  312. //// Modify the path for framework object
  313. // Open the key for write access
  314. lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, tszFrmwrkPath, 0, KEY_WRITE, &hKey);
  315. if (lResult != ERROR_SUCCESS)
  316. {
  317. // Cannot open the key. Most likely some bad error happened.
  318. // We will do nothing in this case.
  319. return FALSE;
  320. }
  321. // Write the new path to the default value
  322. lResult = RegSetValue(hKey, NULL, REG_SZ, tszNewPath, lstrlen(tszNewPath));
  323. RegCloseKey(hKey);
  324. if (lResult != ERROR_SUCCESS)
  325. {
  326. // Error occurred while writing the value.
  327. return FALSE;
  328. }
  329. //// Modify the path for framework page object
  330. // Open the key for write access
  331. lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, tszPagePath, 0, KEY_WRITE, &hKey);
  332. if (lResult != ERROR_SUCCESS)
  333. {
  334. // Cannot open the key. Most likely some bad error happened.
  335. // We will do nothing in this case.
  336. return FALSE;
  337. }
  338. // Write the new path to the default value
  339. lResult = RegSetValue(hKey, NULL, REG_SZ, tszNewPath, lstrlen(tszNewPath));
  340. RegCloseKey(hKey);
  341. if (lResult != ERROR_SUCCESS)
  342. {
  343. // Error occurred while writing the value.
  344. return FALSE;
  345. }
  346. return TRUE;
  347. }
  348. //===========================================================================
  349. // RestoreDiactfrmDllPath
  350. //
  351. // Restores the path of the diactfrm.dll COM server in the registry
  352. // to the system directory, which should be the default.
  353. //
  354. // Parameters:
  355. //
  356. // Returns: TRUE if path is modified. FALSE if an error occurred.
  357. //
  358. // History:
  359. // 08/02/2001 - jacklin - created
  360. //===========================================================================
  361. static BOOL RestoreDiactfrmDllPath()
  362. {
  363. const TCHAR tszFrmwrkPath[] = _T("SOFTWARE\\Classes\\CLSID\\{18AB439E-FCF4-40D4-90DA-F79BAA3B0655}\\InProcServer32");
  364. const TCHAR tszPagePath[] = _T("SOFTWARE\\Classes\\CLSID\\{9F34AF20-6095-11D3-8FB2-00C04F8EC627}\\InProcServer32");
  365. HKEY hKey;
  366. LONG lResult;
  367. // Construct the full path of the DLL using current exe path.
  368. TCHAR tszNewPath[MAX_PATH];
  369. if (!GetSystemDirectory(tszNewPath, MAX_PATH))
  370. {
  371. return FALSE;
  372. }
  373. lstrcat(tszNewPath, _T("\\diactfrm.dll"));
  374. //// Modify the path for framework object
  375. // Open the key for write access
  376. lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, tszFrmwrkPath, 0, KEY_WRITE, &hKey);
  377. if (lResult != ERROR_SUCCESS)
  378. {
  379. // Cannot open the key. Most likely some bad error happened.
  380. // We will do nothing in this case.
  381. return FALSE;
  382. }
  383. // Write the new path to the default value
  384. lResult = RegSetValue(hKey, NULL, REG_SZ, tszNewPath, lstrlen(tszNewPath));
  385. RegCloseKey(hKey);
  386. if (lResult != ERROR_SUCCESS)
  387. {
  388. // Error occurred while writing the value.
  389. return FALSE;
  390. }
  391. //// Modify the path for framework page object
  392. // Open the key for write access
  393. lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, tszPagePath, 0, KEY_WRITE, &hKey);
  394. if (lResult != ERROR_SUCCESS)
  395. {
  396. // Cannot open the key. Most likely some bad error happened.
  397. // We will do nothing in this case.
  398. return FALSE;
  399. }
  400. // Write the new path to the default value
  401. lResult = RegSetValue(hKey, NULL, REG_SZ, tszNewPath, lstrlen(tszNewPath));
  402. RegCloseKey(hKey);
  403. if (lResult != ERROR_SUCCESS)
  404. {
  405. // Error occurred while writing the value.
  406. return FALSE;
  407. }
  408. return TRUE;
  409. }
  410. //===========================================================================
  411. // dmttestRunMapperCPL
  412. //
  413. // Launches DirectInput Mapper CPL, prompts for test results
  414. //
  415. // Parameters:
  416. //
  417. // Returns: HRESULT
  418. //
  419. // History:
  420. // 08/27/1999 - davidkl - created
  421. // 11/04/1999 - davidkl - added support for launching in IHV Edit Mode
  422. //===========================================================================
  423. HRESULT dmttestRunMapperCPL(HWND hwnd,
  424. BOOL fEditMode)
  425. {
  426. HRESULT hRes = S_OK;
  427. // int n = -1;
  428. //JJ 64Bit Compat
  429. INT_PTR n = -1;
  430. UINT u = 0;
  431. BOOL fUserMadeChanges = FALSE;
  432. DMTDEVICE_NODE *pDevice = NULL;
  433. DMTSUBGENRE_NODE *pSubGenre = NULL;
  434. DMTMAPPING_NODE *pMapping = NULL;
  435. IDirectInput8A *pdi = NULL;
  436. char szBuf[MAX_PATH];
  437. //DIACTIONFORMATA diaf;
  438. //JJ Fix
  439. DMTGENRE_NODE *pGenre = NULL;
  440. DIACTIONFORMATA* pDiaf = NULL;
  441. DMT_APPINFO *pdmtai = NULL;
  442. ULONG i = 0;
  443. //JJ TEST
  444. DICONFIGUREDEVICESPARAMSA dicdp;
  445. GUID guidActionMap;
  446. DWORD dwMapUIMode = 0;
  447. /////////////////THIS IS WHERE THE FIX FOR USING AN ACTION ARRAY STARTS////////////
  448. //initialize appropriate mapper UI GUID and display mode
  449. //RY fix for bug #35577
  450. if(fEditMode)
  451. {
  452. guidActionMap = GUID_DIConfigAppEditLayout;
  453. dwMapUIMode = DICD_EDIT;
  454. }
  455. else
  456. {
  457. guidActionMap = GUID_DIMapTst;
  458. dwMapUIMode = DICD_DEFAULT;
  459. }
  460. pdmtai = (DMT_APPINFO*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  461. if(!pdmtai)
  462. {
  463. // big problem
  464. // this should NEVER happen
  465. // ISSUE-2001/03/29-timgill Needs error case handling
  466. }
  467. __try
  468. {
  469. // pDevice = pdmtai->pDeviceList;
  470. // get the currently selected device
  471. n = SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_LIST),
  472. CB_GETCURSEL,
  473. 0,
  474. 0L);
  475. pDevice = (DMTDEVICE_NODE*)SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_LIST),
  476. CB_GETITEMDATA,
  477. n,
  478. 0L);
  479. //JJ Fix 34157
  480. if(CB_ERR == (INT_PTR)pDevice)
  481. {
  482. MessageBox(hwnd,
  483. TEXT("Please install a gaming device"),
  484. TEXT("NO DEVICES"),
  485. 0);
  486. hRes = E_UNEXPECTED;
  487. __leave;
  488. }
  489. if(fEditMode)
  490. {
  491. hRes = dmtwriteWriteFileHeader(hwnd, pDevice);
  492. if(FAILED(hRes))
  493. {
  494. __leave;
  495. }
  496. if (S_FALSE == hRes)
  497. {
  498. hRes = S_OK;
  499. __leave;
  500. }
  501. }
  502. //JJ FIX
  503. // create a directinput object
  504. hRes = dmtinputCreateDirectInput(ghinst,
  505. &pdi);
  506. if(FAILED(hRes))
  507. {
  508. hRes = DMT_E_INPUT_CREATE_FAILED;
  509. __leave;
  510. }
  511. pGenre = pdmtai->pGenreList;
  512. //Allocate out the array...
  513. pDiaf = (DIACTIONFORMATA*)malloc(sizeof(DIACTIONFORMATA) * g_NumSubGenres);
  514. ZeroMemory((void*)pDiaf, sizeof(DIACTIONFORMATA) * g_NumSubGenres);
  515. while(pGenre)
  516. {
  517. pSubGenre = pGenre->pSubGenreList;
  518. while(pSubGenre)
  519. {
  520. // find the mapping node for the selected device
  521. pMapping = pSubGenre->pMappingList;
  522. pMapping = pSubGenre->pMappingList;
  523. while(pMapping)
  524. {
  525. if(IsEqualGUID(pDevice->guidInstance,
  526. pMapping->guidInstance))
  527. {
  528. break;
  529. }
  530. // next mapping
  531. pMapping = pMapping->pNext;
  532. }
  533. if(!pMapping)
  534. {
  535. // this should never happen
  536. hRes = DMT_E_NO_MATCHING_MAPPING;
  537. DebugBreak();
  538. __leave;
  539. }
  540. // prepare the DIACTIONFORMAT structure
  541. pDiaf[i].dwSize = sizeof(DIACTIONFORMAT);
  542. pDiaf[i].dwActionSize = sizeof(DIACTIONA);
  543. pDiaf[i].dwNumActions = (DWORD)(pMapping->uActions);
  544. pDiaf[i].rgoAction = pMapping->pdia;
  545. pDiaf[i].dwDataSize = 4 * pDiaf[i].dwNumActions;
  546. pDiaf[i].dwGenre = pSubGenre->dwGenreId;
  547. pDiaf[i].dwBufferSize = DMTINPUT_BUFFERSIZE;
  548. //Set up the proper names
  549. wsprintfA(szBuf, "%s: %s",
  550. pSubGenre->szName, pSubGenre->szDescription);
  551. pDiaf[i].guidActionMap = guidActionMap;
  552. lstrcpyA(pDiaf[i].tszActionMap, szBuf);
  553. //Increment the counter
  554. i++;
  555. //Next Subgenre
  556. pSubGenre = pSubGenre->pNext;
  557. }
  558. //Next Genre
  559. pGenre = pGenre->pNext;
  560. }
  561. assert(i == g_NumSubGenres);
  562. // Enumerate the devices and check if INI path is set
  563. pdi->EnumDevicesBySemantics(NULL, pDiaf, ::EnumDeviceCallback, (LPVOID)hwnd, DIEDBSFL_ATTACHEDONLY);
  564. // prepare the configure devices params
  565. ZeroMemory((void*)&dicdp, sizeof(DICONFIGUREDEVICESPARAMSA));
  566. dicdp.dwSize = sizeof(DICONFIGUREDEVICESPARAMSA);
  567. dicdp.dwcUsers = 0;
  568. dicdp.lptszUserNames = NULL;
  569. //dicdp.dwcFormats = 1;
  570. dicdp.dwcFormats = i;//g_NumSubGenres;
  571. dicdp.lprgFormats = pDiaf;//&diaf;
  572. dicdp.hwnd = hwnd;
  573. dicdp.lpUnkDDSTarget = NULL;
  574. // colors
  575. dicdp.dics.dwSize = sizeof(DICOLORSET);
  576. /* dicdp.dics.cTextFore = D3DRGB(0,0,255);
  577. dicdp.dics.cTextHighlight = D3DRGB(0,255,255);
  578. dicdp.dics.cCalloutLine = D3DRGB(255,255,255);
  579. dicdp.dics.cCalloutHighlight= D3DRGB(255,255,0);
  580. dicdp.dics.cBorder = D3DRGB(0,128,255);
  581. dicdp.dics.cControlFill = D3DRGB(128,128,255);
  582. dicdp.dics.cHighlightFill = D3DRGB(255,0,0);
  583. dicdp.dics.cAreaFill = D3DRGB(192,192,192); */
  584. // display mapper cpl
  585. ///////////////////////////////END FIX///////////////////////////////////////
  586. //JJ Fix34958
  587. EnableWindow(hwnd,
  588. FALSE);
  589. // 8/2/2001 (jacklin): Modify the path of diactfrm.dll COM server to
  590. // use the DDK version of the DLL.
  591. BOOL bModified = ModifyDiactfrmDllPath();
  592. hRes = pdi->ConfigureDevices(NULL,
  593. &dicdp,
  594. dwMapUIMode, // flags
  595. NULL); // user data for callback fn
  596. // 8/2/2001 (jacklin): Restore the path of diactfrm.dll COM server
  597. if (bModified)
  598. RestoreDiactfrmDllPath();
  599. EnableWindow(hwnd,
  600. TRUE);
  601. if(FAILED(hRes))
  602. {
  603. DPF(0, "ConfigureDevices failed (%s == %08Xh)",
  604. dmtxlatHRESULT(hRes), hRes);
  605. __leave;
  606. }
  607. }
  608. __finally
  609. {
  610. // general cleanup
  611. SAFE_RELEASE(pdi);
  612. if(pDiaf)
  613. {
  614. free(pDiaf);
  615. pDiaf = NULL;
  616. }
  617. }
  618. // done
  619. return hRes;
  620. } //*** end dmttestRunMapperCPL()
  621. //===========================================================================
  622. // dmttestStopIntegrated
  623. //
  624. // Stops integrated device test
  625. //
  626. // Parameters:
  627. // HWND hwnd - handle of app window
  628. //
  629. // Returns: BOOL
  630. // TRUE - Passed
  631. // FALSE - Failed
  632. //
  633. // History:
  634. // 09/22/1999 - davidkl - created
  635. // 11/02/1999 - davidkl - stops timer and performs cleanup
  636. // 11/09/1999 - davidkl - added freeing of actionname allocation
  637. //===========================================================================
  638. BOOL dmttestStopIntegrated(HWND hwnd)
  639. {
  640. int n = 0;
  641. DWORD dw = WAIT_ABANDONED;
  642. BOOL fPassed = TRUE;
  643. DMT_APPINFO *pdmtai = NULL;
  644. // get the app info structure
  645. //JJ 64Bit Compat
  646. pdmtai = (DMT_APPINFO*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  647. if(!pdmtai)
  648. {
  649. // ISSUE-2001/03/29-timgill Needs error case handling
  650. }
  651. // stop the input timer
  652. // ISSUE-2001/03/29-timgill Should check timer was set and return value
  653. KillTimer(hwnd,
  654. ID_POLL_TIMER);
  655. // free the buffer
  656. if(gpdidod)
  657. {
  658. if(LocalFree((HLOCAL)gpdidod))
  659. {
  660. // memory leak
  661. // ISSUE-2001/03/29-timgill Needs error case handling
  662. }
  663. }
  664. // free the pdmtai actionname list
  665. if(pdmtai->pan)
  666. {
  667. if(LocalFree((HLOCAL)(pdmtai->pan)))
  668. {
  669. // memory leak
  670. // ISSUE-2001/03/29-timgill Needs error case handling
  671. }
  672. pdmtai->pan = NULL;
  673. }
  674. // prompt for test results
  675. n = MessageBoxA(hwnd, "Were the correct semantics displayed\r\n"
  676. "for each device control?",
  677. "Test Results",
  678. MB_YESNO);
  679. if(IDNO == n)
  680. {
  681. // display dialog prompting for details
  682. // ISSUE-2001/03/29-timgill Should test type (cpl/integrated)
  683. DialogBoxParamA(ghinst,
  684. MAKEINTRESOURCEA(IDD_FAILURE_DETAILS),
  685. hwnd,
  686. dmtfailDlgProc,
  687. (LPARAM)NULL);
  688. }
  689. // en/disable appropriate ui elements
  690. EnableWindow(GetDlgItem(hwnd, IDOK), TRUE);
  691. EnableWindow(GetDlgItem(hwnd, IDCANCEL), FALSE);
  692. EnableWindow(GetDlgItem(hwnd, IDC_GENRES_LABEL), TRUE);
  693. EnableWindow(GetDlgItem(hwnd, IDC_DEVICE_GENRES), TRUE);
  694. EnableWindow(GetDlgItem(hwnd, IDC_ENUM_DEVICES), TRUE);
  695. EnableWindow(GetDlgItem(hwnd, IDC_DEVICES_LABEL), TRUE);
  696. EnableWindow(GetDlgItem(hwnd, IDC_DEVICE_LIST), TRUE);
  697. // EnableWindow(GetDlgItem(hwnd, IDC_CONFIGURE), TRUE);
  698. EnableWindow(GetDlgItem(hwnd, IDC_LAUNCH_CPL_EDIT_MODE), TRUE);
  699. // EnableWindow(GetDlgItem(hwnd, IDC_SAVE_STD), TRUE);
  700. EnableWindow(GetDlgItem(hwnd, IDC_SAVE_HID), TRUE);
  701. EnableWindow(GetDlgItem(hwnd, IDC_SAVE_BOTH), TRUE);
  702. EnableWindow(GetDlgItem(hwnd, IDC_START_WITH_DEFAULTS), TRUE);
  703. // done
  704. return fPassed;
  705. } //*** end dmttestStopIntegrated()
  706. //===========================================================================
  707. //===========================================================================
  708. //===========================================================================
  709. //===========================================================================
  710. //===========================================================================
  711. //===========================================================================
  712. //===========================================================================
  713. //===========================================================================
  714. //===========================================================================
  715. //===========================================================================
  716. //===========================================================================
  717. //===========================================================================