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.

1056 lines
30 KiB

  1. //===========================================================================
  2. // dimaptst.cpp
  3. //
  4. // DirectInput Mapper test tool
  5. //
  6. // Build options:
  7. // Internal Test Tool
  8. // -DINTERNAL -DTESTAPP
  9. //
  10. // External DDK Configuration Tool
  11. // -DDDKAPP
  12. //
  13. // Functions:
  14. // WinMain
  15. // dimaptstMainDlgProc
  16. // dimaptstOnInitDialog
  17. // dimaptstOnClose
  18. // dimaptstOnCommand
  19. // dimaptstOnUpdateControlData
  20. // dmtGetCheckedRadioButton
  21. //
  22. // History:
  23. // 08/19/1999 - davidkl - created
  24. //===========================================================================
  25. #define INITGUID
  26. #include "dimaptst.h"
  27. #include "dmtabout.h"
  28. #include "dmtinput.h"
  29. #include "dmtcfg.h"
  30. #include "dmttest.h"
  31. //#include "dmtwrite.h"
  32. #include "dmtstress.h"
  33. //---------------------------------------------------------------------------
  34. #ifndef NTAPI
  35. #define NTAPI __stdcall
  36. #endif
  37. #ifndef NTSYSAPI
  38. #define NTSYSAPI __declspec(dllimport)
  39. #endif
  40. #ifndef NTSTATUS
  41. typedef LONG NTSTATUS;
  42. #endif
  43. #ifndef PCSZ
  44. typedef CONST char *PCSZ;
  45. #endif
  46. extern "C"
  47. {
  48. NTSYSAPI NTSTATUS NTAPI RtlCharToInteger(PCSZ szString,
  49. ULONG ulBase,
  50. ULONG *puValue);
  51. NTSYSAPI ULONG NTAPI RtlNtStatusToDosError(NTSTATUS nts);
  52. }
  53. //---------------------------------------------------------------------------
  54. // app global variables
  55. HINSTANCE ghinst = NULL;
  56. HANDLE ghEvent = NULL;
  57. CRITICAL_SECTION gcritsect;
  58. //---------------------------------------------------------------------------
  59. // file global variables
  60. //---------------------------------------------------------------------------
  61. //===========================================================================
  62. // WinMain
  63. //
  64. // App entry point
  65. //
  66. // Parameters: (see SDK help for parameter details)
  67. // HINSTANCE hinst
  68. // HINSTANCE hinstPrev
  69. // LPSTR szCmdParams
  70. // int nShow
  71. //
  72. // Returns: (see SDK help for return value details)
  73. // int
  74. //
  75. // History:
  76. // 08/19/1999 - davidkl - created
  77. //===========================================================================
  78. int WINAPI WinMain(HINSTANCE hinst,
  79. HINSTANCE hinstPrev,
  80. PSTR szCmdParams,
  81. int nShow)
  82. {
  83. //int n = 0;
  84. //JJ 64Bit Compat
  85. INT_PTR n = 0;
  86. // initialize DPF
  87. DbgInitialize(TRUE);
  88. DbgEnable(TRUE);
  89. // see if our ini file exists
  90. n = GetPrivateProfileIntA("0",
  91. "AI0",
  92. 0,
  93. GENRES_INI);
  94. if(0 == n)
  95. {
  96. // file does not exist
  97. //
  98. // inform user and bail
  99. MessageBoxA(NULL,
  100. "Please copy genre.ini to the current folder.",
  101. "Unable to locate genre.ini",
  102. MB_OK);
  103. return FALSE;
  104. }
  105. // initialize Win9x common controls (progress bars, etc)
  106. InitCommonControls();
  107. // intialize COM
  108. if(FAILED(CoInitialize(NULL)))
  109. {
  110. DPF(0, "COM initialization failed... exiting");
  111. return -1;
  112. }
  113. // save our instance handle
  114. ghinst = hinst;
  115. // create our critical section
  116. InitializeCriticalSection(&gcritsect);
  117. // create our signal event
  118. ghEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
  119. // create our main dialog window
  120. n = DialogBoxParamA(hinst,
  121. MAKEINTRESOURCEA(IDD_MAIN),
  122. (HWND)NULL,
  123. dimaptstMainDlgProc,
  124. (LPARAM)NULL);
  125. if(-1 == n)
  126. {
  127. DPF(0, "WinMain - DialogBoxParamA returned an error (%d)",
  128. GetLastError());
  129. }
  130. // done
  131. CloseHandle(ghEvent);
  132. DeleteCriticalSection(&gcritsect);
  133. CoUninitialize();
  134. return (int)n;
  135. } //*** end WinMain()
  136. //===========================================================================
  137. // dimaptstMainDlgProc
  138. //
  139. // Main application dialog processing function
  140. //
  141. // Parameters: (see SDK help for parameter details)
  142. // HWND hwnd
  143. // UINT uMsg
  144. // WPARAM wparam
  145. // LPARAM lparam
  146. //
  147. // Returns: (see SDK help for return value details)
  148. // BOOL
  149. //
  150. // History:
  151. // 08/19/1999 - davidkl - created
  152. //===========================================================================
  153. /*BOOL*/INT_PTR CALLBACK dimaptstMainDlgProc(HWND hwnd,
  154. UINT uMsg,
  155. WPARAM wparam,
  156. LPARAM lparam)
  157. {
  158. switch(uMsg)
  159. {
  160. case WM_INITDIALOG:
  161. return dimaptstOnInitDialog(hwnd,
  162. (HWND)wparam,
  163. lparam);
  164. case WM_CLOSE:
  165. return dimaptstOnClose(hwnd);
  166. case WM_COMMAND:
  167. return dimaptstOnCommand(hwnd,
  168. LOWORD(wparam),
  169. (HWND)lparam,
  170. HIWORD(wparam));
  171. //JJ Comment: I am keeping the timer stuff around for now while getting rid of
  172. //input polling because we are going to use it later in a different way; I will
  173. //leave the timer stuff in for now and then add in the input stuff when more specific
  174. //decisions are made concerning *what* exact performance/implementation is desired.
  175. case WM_TIMER:
  176. return dimaptstOnTimer(hwnd,
  177. wparam);
  178. case WM_DMT_UPDATE_LISTS:
  179. return dimaptstOnUpdateLists(hwnd);
  180. }
  181. return FALSE;
  182. }
  183. //===========================================================================
  184. // dimaptstOnInitDialog
  185. //
  186. // Handle WM_INITDIALOG processing for the main dialogfs
  187. //
  188. // Parameters:
  189. //
  190. // Returns: BOOL
  191. //
  192. // History:
  193. // 08/20/1999 - davidkl - created
  194. //===========================================================================
  195. BOOL dimaptstOnInitDialog(HWND hwnd,
  196. HWND hwndFocus,
  197. LPARAM lparam)
  198. {
  199. HRESULT hRes = S_OK;
  200. /*int*/
  201. //JJ 64Bit Compat
  202. UINT_PTR nIdx = 0;
  203. //LONG lPrev = 0L;
  204. //JJ 64Bit Compat
  205. LONG_PTR lPrev = 0;
  206. DMT_APPINFO *pdmtai = NULL;
  207. DMTGENRE_NODE *pNode = NULL;
  208. DPF(5, "dimaptstOnInitDialog");
  209. // give the system menu our icon
  210. SendMessageA(hwnd,
  211. WM_SETICON,
  212. ICON_BIG,
  213. (LPARAM)LoadIcon(ghinst,
  214. MAKEINTRESOURCEA(IDI_DIMAPTST)));
  215. SendMessageA(hwnd,
  216. WM_SETICON,
  217. ICON_SMALL,
  218. (LPARAM)LoadIcon(ghinst,
  219. MAKEINTRESOURCEA(IDI_DIMAPTST)));
  220. // allocate the appinfo structure
  221. pdmtai = (DMT_APPINFO*)LocalAlloc(LMEM_FIXED,
  222. sizeof(DMT_APPINFO));
  223. if(!pdmtai)
  224. {
  225. // serious app problem.
  226. // we need to stop things right here and now
  227. DPF(0, "dimaptstOnInitDialog - This is bad... "
  228. "We failed to allocate appinfo");
  229. DPF(0, "dimaptstOnInitDialog - Please find someone "
  230. "to look at this right away");
  231. DebugBreak();
  232. return FALSE;
  233. }
  234. pdmtai->pGenreList = NULL;
  235. pdmtai->pSubGenre = NULL;
  236. pdmtai->pDeviceList = NULL;
  237. pdmtai->fStartWithDefaults = FALSE;
  238. // allocate the genre list
  239. hRes = dmtcfgCreateGenreList(&(pdmtai->pGenreList));
  240. if(FAILED(hRes))
  241. {
  242. // this is potentially very bad
  243. // ISSUE-2001/03/29-Marcand we fault if we hit this
  244. // really need to kill the app at this point
  245. DPF(0, "dimaptstOnInitDialog - This is bad... "
  246. "We failed to create genre list "
  247. "(%s == %08Xh)",
  248. dmtxlatHRESULT(hRes), hRes);
  249. DPF(0, "dimaptstOnInitDialog - Check to be sure that %s "
  250. " exists in the current directory",
  251. GENRES_INI);
  252. return FALSE;
  253. }
  254. // set the hwnd userdata
  255. SetLastError(0);
  256. //JJ- 64Bit compat change
  257. lPrev = SetWindowLongPtr(hwnd,
  258. GWLP_USERDATA,
  259. (LONG_PTR)pdmtai);
  260. if(!lPrev && GetLastError())
  261. {
  262. // serious app problem.
  263. // we need to stop things right here and now
  264. DPF(0, "dimaptstOnInitDialog - This is bad... "
  265. "We failed to store pList");
  266. DPF(0, "dimaptstOnInitDialog - Please find someone "
  267. "to look at this right away");
  268. DebugBreak();
  269. return FALSE;
  270. }
  271. // populate the controls
  272. // genre list
  273. pNode = pdmtai->pGenreList;
  274. while(pNode)
  275. {
  276. // add the name to the list
  277. nIdx = SendMessageA((HWND)GetDlgItem(hwnd, IDC_DEVICE_GENRES),
  278. CB_ADDSTRING,
  279. 0,
  280. (LPARAM)(pNode->szName));
  281. // add the node to the item data
  282. SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_GENRES),
  283. CB_SETITEMDATA,
  284. nIdx,
  285. (LPARAM)pNode);
  286. // next node
  287. pNode = pNode->pNext;
  288. }
  289. // set the selection to the first in the list
  290. SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_GENRES),
  291. CB_SETCURSEL,
  292. 0,
  293. 0L);
  294. // populate the subgenre list
  295. SendMessageA(hwnd,
  296. WM_DMT_UPDATE_LISTS,
  297. 0,
  298. 0L);
  299. // set the testing option
  300. // CheckRadioButton(hwnd,
  301. // IDC_USE_INTEGRATED,
  302. // IDC_USE_CPL,
  303. // IDC_USE_CPL);
  304. #ifdef TESTAPP
  305. //***************************************
  306. // Internal app specific control settings
  307. //***************************************
  308. // set the verification option to automatic
  309. CheckRadioButton(hwnd,
  310. IDC_VERIFY_AUTOMATIC,
  311. IDC_VERIFY_MANUAL,
  312. IDC_VERIFY_AUTOMATIC);
  313. #endif // TESTAPP
  314. #ifdef DDKAPP
  315. //***************************************
  316. // DDK Tool specific control settings
  317. //***************************************
  318. // set default state for "start with defaults"
  319. CheckDlgButton(hwnd,
  320. IDC_START_WITH_DEFAULTS,
  321. BST_CHECKED);
  322. #endif // DDKAPP
  323. SendMessageA(hwnd,
  324. WM_COMMAND,
  325. IDC_ENUM_DEVICES,
  326. 0L);
  327. // done
  328. return TRUE;
  329. } //*** end dimaptstOnInitDialog()
  330. //===========================================================================
  331. // dimaptstOnClose
  332. //
  333. // Handle WM_CLOSE processing for the main dialog
  334. //
  335. // Parameters:
  336. //
  337. // Returns: BOOL
  338. //
  339. // History:
  340. // 08/20/1999 - davidkl - created
  341. //===========================================================================
  342. BOOL dimaptstOnClose(HWND hwnd)
  343. {
  344. HRESULT hRes = S_OK;
  345. HRESULT hr = S_OK;
  346. DMT_APPINFO *pdmtai = NULL;
  347. DPF(5, "dimaptstOnClose");
  348. __try
  349. {
  350. // get appinfo
  351. //JJ- 64Bit Compat
  352. pdmtai = (DMT_APPINFO*)GetWindowLongPtr(hwnd,
  353. GWLP_USERDATA);
  354. if(!pdmtai)
  355. {
  356. DPF(0, "dimaptstOnClose - unable to retrieve app info");
  357. hRes = E_UNEXPECTED;
  358. __leave;
  359. }
  360. // free appinfo
  361. // device list first
  362. hr = dmtinputFreeDeviceList(&(pdmtai->pDeviceList));
  363. if(S_OK == hRes)
  364. {
  365. DPF(2, "dimaptstOnClose - dmtinputFreeDeviceList (%s == %08Xh)",
  366. dmtxlatHRESULT(hr), hr);
  367. hRes = hr;
  368. }
  369. pdmtai->pDeviceList = NULL;
  370. // then genre list
  371. hRes = dmtcfgFreeGenreList(&(pdmtai->pGenreList));
  372. if(S_OK == hRes)
  373. {
  374. DPF(2, "dimaptstOnClose - dmtinputFreeGenreList (%s == %08Xh)",
  375. dmtxlatHRESULT(hr), hr);
  376. hRes = hr;
  377. }
  378. pdmtai->pGenreList = NULL;
  379. // parent structure
  380. if(LocalFree((HLOCAL)pdmtai))
  381. {
  382. DPF(0, "dimaptstOnClose - LocalFree(app info) failed!");
  383. if(S_OK == hRes)
  384. {
  385. hRes = DMT_S_MEMORYLEAK;
  386. }
  387. }
  388. pdmtai = NULL;
  389. }
  390. _finally
  391. {
  392. // time to leave
  393. EndDialog(hwnd, (int)hRes);
  394. PostQuitMessage((int)hRes);
  395. }
  396. // done
  397. return FALSE;
  398. } //*** end dimaptstOnClose()
  399. //===========================================================================
  400. // dimaptstOnCommand
  401. //
  402. // Handle WM_COMMAND processing for the main dialog
  403. //
  404. // Parameters:
  405. //
  406. // Returns: BOOL
  407. //
  408. // History:
  409. // 08/20/1999 - davidkl - created
  410. //===========================================================================
  411. BOOL dimaptstOnCommand(HWND hwnd,
  412. WORD wId,
  413. HWND hwndCtrl,
  414. WORD wNotifyCode)
  415. {
  416. HRESULT hRes = S_OK;
  417. BOOL fEnable = FALSE;
  418. BOOL fEnumSuitable = FALSE;
  419. //JJ Added 64Bit Compat
  420. LONG_PTR nIdx = -1;
  421. UINT_PTR u = 0;
  422. static UINT_PTR uGenSel = 0;
  423. static UINT uSubSel = 0;
  424. DMT_APPINFO *pdmtai = NULL;
  425. DMTDEVICE_NODE *pDevice = NULL;
  426. DMTGENRE_NODE *pGenre = NULL;
  427. DMTSUBGENRE_NODE *pSubGenre = NULL;
  428. #ifdef TESTAPP
  429. int nWidth = 597;
  430. int nHeight = 0;
  431. #endif // TESTAPP
  432. DPF(5, "dimaptstOnCommand");
  433. // get app info (stored in hwnd userdata)
  434. //JJ- 64Bit Compat
  435. pdmtai = (DMT_APPINFO*)GetWindowLongPtr(hwnd,
  436. GWLP_USERDATA);
  437. if(!pdmtai)
  438. {
  439. // ISSUE-2001/03/29-timgill Needs error case handling
  440. }
  441. switch(wId)
  442. {
  443. case IDOK:
  444. //JJ FIX UI
  445. hRes = dmttestRunMapperCPL(hwnd,
  446. FALSE);
  447. break;
  448. case IDCANCEL:
  449. // ISSUE-2001/03/29-timgill need to check return value
  450. dmttestStopIntegrated(hwnd);
  451. break;
  452. case IDC_DEVICE_GENRES:
  453. // check for selection change
  454. if(CBN_DROPDOWN == wNotifyCode)
  455. {
  456. // memorize current selection
  457. uGenSel = SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_GENRES),
  458. CB_GETCURSEL,
  459. 0,
  460. //JJ- 64Bit Compat
  461. //0L);
  462. 0);
  463. }
  464. if(CBN_SELCHANGE == wNotifyCode)
  465. {
  466. // selection changed
  467. //
  468. // get the new selection
  469. u = SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_GENRES),
  470. CB_GETCURSEL,
  471. 0,
  472. 0L);
  473. if(uGenSel != u)
  474. {
  475. SendMessageA(hwnd,
  476. WM_DMT_UPDATE_LISTS,
  477. 0,
  478. 0L);
  479. }
  480. }
  481. break;
  482. case IDC_SUBGENRES:
  483. #ifndef DDKAPP
  484. // check for selection change
  485. if(CBN_DROPDOWN == wNotifyCode)
  486. {
  487. // memorize current selection
  488. uSubSel = SendMessageA(GetDlgItem(hwnd, IDC_SUBGENRES),
  489. CB_GETCURSEL,
  490. 0,
  491. 0L);
  492. }
  493. if(CBN_SELCHANGE == wNotifyCode)
  494. {
  495. // selection changed
  496. //
  497. // get the new selection
  498. u = SendMessageA(GetDlgItem(hwnd, IDC_SUBGENRES),
  499. CB_GETCURSEL,
  500. 0,
  501. 0L);
  502. if(uSubSel != u)
  503. {
  504. // clear the device combo box
  505. SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_LIST),
  506. CB_RESETCONTENT,
  507. 0,
  508. 0L);
  509. // release device list
  510. dmtinputFreeDeviceList(&(pdmtai->pDeviceList));
  511. // release the mapping lists for each subgenre
  512. dmtcfgFreeAllMappingLists(pdmtai->pGenreList);
  513. // disable appropriate controls
  514. dimaptstPostEnumEnable(hwnd, FALSE);
  515. }
  516. }
  517. #endif
  518. break;
  519. case IDC_ENUM_DEVICES:
  520. // ISSUE-2001/03/29-timgill Long conditional branch
  521. // should really make a sep. fn
  522. /*
  523. #ifdef DDKAPP
  524. // we only want to enumerate all gaming
  525. // devices if we are the DDK tool
  526. fEnumSuitable = FALSE;
  527. #else
  528. */
  529. fEnumSuitable = TRUE;
  530. u = SendMessageA(GetDlgItem(hwnd, IDC_SUBGENRES),
  531. CB_GETCURSEL,
  532. 0,
  533. 0L);
  534. pSubGenre = (DMTSUBGENRE_NODE*)SendMessageA(GetDlgItem(hwnd, IDC_SUBGENRES),
  535. CB_GETITEMDATA,
  536. u,
  537. 0L);
  538. if(!pSubGenre)
  539. {
  540. // ISSUE-2001/03/29-timgill Needs error case handling
  541. }
  542. //#endif
  543. // first, free the existing device list
  544. hRes = dmtinputFreeDeviceList(&(pdmtai->pDeviceList));
  545. if(FAILED(hRes))
  546. {
  547. // ISSUE-2001/03/29-timgill Needs error case handling
  548. }
  549. // then, flush the combo box
  550. SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_LIST),
  551. CB_RESETCONTENT,
  552. 0,
  553. 0L);
  554. // now, re-create the device list
  555. hRes = dmtinputCreateDeviceList(hwnd,
  556. fEnumSuitable,
  557. pSubGenre,
  558. &(pdmtai->pDeviceList));
  559. if(FAILED(hRes))
  560. {
  561. // ISSUE-2001/03/29-timgill Needs error case handling
  562. }
  563. // free the existing mapping lists
  564. dmtcfgFreeAllMappingLists(pdmtai->pGenreList);
  565. // create the mapping lists within the subgenres
  566. hRes = dmtcfgCreateAllMappingLists(pdmtai);
  567. if(FAILED(hRes))
  568. {
  569. // ISSUE-2001/03/29-timgill Needs error case handling
  570. }
  571. // populate the devices control
  572. pDevice = pdmtai->pDeviceList;
  573. while(pDevice)
  574. {
  575. // add device name
  576. nIdx = SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_LIST),
  577. CB_ADDSTRING,
  578. 0,
  579. (LPARAM)&(pDevice->szName));
  580. // add device node to item data
  581. SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_LIST),
  582. CB_SETITEMDATA,
  583. nIdx,
  584. (LPARAM)pDevice);
  585. // next device
  586. pDevice = pDevice->pNext;
  587. }
  588. // select the 1st entry
  589. SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_LIST),
  590. CB_SETCURSEL,
  591. 0,
  592. 0L);
  593. // enable appropriate ui elements
  594. dimaptstPostEnumEnable(hwnd, TRUE);
  595. break;
  596. #ifdef TESTAPP
  597. //***************************************
  598. // Internal app specific message handling
  599. //***************************************
  600. case IDC_VERIFY_MANUAL:
  601. case IDC_VERIFY_AUTOMATIC:
  602. // enable/disable manual override option
  603. fEnable = (BOOL)(IDC_VERIFY_MANUAL - dmtGetCheckedRadioButton(hwnd,
  604. IDC_VERIFY_AUTOMATIC,
  605. IDC_VERIFY_MANUAL));
  606. EnableWindow(GetDlgItem(hwnd, IDC_VERIFY_MANUAL_OVERRIDE), fEnable);
  607. break;
  608. case IDC_STRESS_MODE:
  609. // expand/shrink dialog
  610. nHeight = IsDlgButtonChecked(hwnd, IDC_STRESS_MODE) ? 490 : 361;
  611. SetWindowPos(hwnd,
  612. HWND_TOP,
  613. 0, 0,
  614. nWidth, nHeight,
  615. SWP_NOMOVE | SWP_NOOWNERZORDER);
  616. // enable / disable stress configuration & launch
  617. fEnable = (BOOL)IsDlgButtonChecked(hwnd, IDC_STRESS_MODE);
  618. // EnableWindow(GetDlgItem(hwnd, IDC_CONFIGURE), fEnable);
  619. EnableWindow(GetDlgItem(hwnd, IDC_STRESS_START), fEnable);
  620. break;
  621. #endif // TESTAPP
  622. #ifdef DDKAPP
  623. case IDC_LAUNCH_CPL_EDIT_MODE:
  624. // get the currently selected device?
  625. nIdx = SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_LIST),
  626. CB_GETCURSEL,
  627. 0,
  628. 0L);
  629. if (nIdx == CB_ERR)
  630. {
  631. // Error has occurred. Most likely no device is available.
  632. MessageBox(hwnd, "No device selected.", "Error", MB_OK);
  633. return TRUE;
  634. }
  635. pDevice = (DMTDEVICE_NODE*)SendMessageA(GetDlgItem(hwnd,
  636. IDC_DEVICE_LIST),
  637. CB_GETITEMDATA,
  638. nIdx,
  639. 0L);
  640. if(!pDevice)
  641. {
  642. // ISSUE-2001/03/29-timgill Needs error case handling
  643. }
  644. // launch the mapper cpl in edit mode
  645. hRes = dmttestRunMapperCPL(hwnd,
  646. TRUE);
  647. if(FAILED(hRes))
  648. {
  649. // ISSUE-2001/03/29-timgill Needs error case handling
  650. }
  651. break;
  652. #endif // DDKAPP
  653. }
  654. // done
  655. return FALSE;
  656. } //*** end dimaptstOnCommand()
  657. //===========================================================================
  658. // dimaptstOnTimer
  659. //
  660. // Handles WM_TIMER messages for the main app dialog
  661. //
  662. // Parameters:
  663. //
  664. // Returns: BOOL
  665. //
  666. // History:
  667. // 11/02/1999 - davidkl - created
  668. //===========================================================================
  669. BOOL dimaptstOnTimer(HWND hwnd,
  670. WPARAM wparamTimerId)
  671. {
  672. //int nSel = -1;
  673. //JJ 64Bit Compat
  674. LONG_PTR nSel = -1;
  675. DMTDEVICE_NODE *pDevice = NULL;
  676. DPF(5, "dimaptstOnTimer - ID == %d",
  677. wparamTimerId);
  678. if(ID_POLL_TIMER == wparamTimerId)
  679. {
  680. // get the current device
  681. nSel = SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_LIST),
  682. CB_GETCURSEL,
  683. 0,
  684. 0L);
  685. if(-1 == nSel)
  686. {
  687. DPF(0, "dimaptstOnTimer - invalid device selection");
  688. return FALSE;
  689. }
  690. pDevice = (DMTDEVICE_NODE*)SendMessageA(GetDlgItem(hwnd,
  691. IDC_DEVICE_LIST),
  692. CB_GETITEMDATA,
  693. nSel,
  694. 0L);
  695. if(!pDevice)
  696. {
  697. DPF(0, "dimaptstOnTimer - failed to retrieve device node");
  698. return FALSE;
  699. }
  700. // get data from the device
  701. //JJ Removed
  702. //dmttestGetInput(hwnd,
  703. // pDevice);
  704. }
  705. // done
  706. return FALSE;
  707. } //*** end dimaptstOnTimer()
  708. //===========================================================================
  709. // dimaptstOnUpdateLists
  710. //
  711. // Updates the subgenre list in response to a genre bucket change
  712. //
  713. // NOTE: INTERNAL only - This also clears the devices list, frees
  714. // all associated linked lists and performs some window enabling/disabling
  715. // tasks.
  716. //
  717. // Parameters:
  718. // HWND hwnd - handle to app window
  719. //
  720. // Returns: BOOL
  721. //
  722. // History:
  723. // 10/01/1999 - davidkl - created
  724. //===========================================================================
  725. BOOL dimaptstOnUpdateLists(HWND hwnd)
  726. {
  727. //JJ 64Bit Compat
  728. UINT_PTR uSel = 0;
  729. DMTGENRE_NODE *pGenre = NULL;
  730. DMTSUBGENRE_NODE *pSubNode = NULL;
  731. DMT_APPINFO *pdmtai = NULL;
  732. // get the genre bucket node
  733. uSel = SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_GENRES),
  734. CB_GETCURSEL,
  735. 0,
  736. 0L);
  737. pGenre = (DMTGENRE_NODE*)SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_GENRES),
  738. CB_GETITEMDATA,
  739. uSel,
  740. 0L);
  741. if(!pGenre)
  742. {
  743. // this is bad
  744. DebugBreak();
  745. return TRUE;
  746. }
  747. // clear the existing list contents
  748. SendMessageA(GetDlgItem(hwnd, IDC_SUBGENRES),
  749. CB_RESETCONTENT,
  750. 0,
  751. 0L);
  752. // update (sub)genres list
  753. pSubNode = pGenre->pSubGenreList;
  754. while(pSubNode)
  755. {
  756. uSel = SendMessageA(GetDlgItem(hwnd, IDC_SUBGENRES),
  757. CB_ADDSTRING,
  758. 0,
  759. (LPARAM)(pSubNode->szName));
  760. SendMessageA(GetDlgItem(hwnd, IDC_SUBGENRES),
  761. CB_SETITEMDATA,
  762. uSel,
  763. (LPARAM)pSubNode);
  764. // next subgenre
  765. pSubNode = pSubNode->pNext;
  766. }
  767. // select the first list entry
  768. SendMessageA(GetDlgItem(hwnd, IDC_SUBGENRES),
  769. CB_SETCURSEL,
  770. 0,
  771. 0L);
  772. #ifndef DDKAPP
  773. //============================================
  774. // only do this part for SDK and INTERNAL apps
  775. //============================================
  776. // get the device list
  777. pdmtai = (DMT_APPINFO*)GetWindowLong(hwnd,
  778. GWL_USERDATA);
  779. if(!pdmtai)
  780. {
  781. // ISSUE-2001/03/29-timgill Needs error case handling
  782. }
  783. // clear the device combo box
  784. SendMessageA(GetDlgItem(hwnd, IDC_DEVICE_LIST),
  785. CB_RESETCONTENT,
  786. 0,
  787. 0L);
  788. // release device list
  789. dmtinputFreeDeviceList(&(pdmtai->pDeviceList));
  790. // release the mapping lists for each subgenre
  791. dmtcfgFreeAllMappingLists(pdmtai->pGenreList);
  792. // disable appropriate controls
  793. dimaptstPostEnumEnable(hwnd, FALSE);
  794. #endif
  795. // done
  796. return FALSE;
  797. } //*** end dimaptstOnUpdateLists()
  798. //===========================================================================
  799. // dmtGetCheckedRadioButton
  800. //
  801. // Returns the checked radio button in a group.
  802. //
  803. // Parameters:
  804. //
  805. // Returns:
  806. //
  807. // History:
  808. // 08/25/1998 - davidkl - created (copied from dmcs sources)
  809. //===========================================================================
  810. UINT dmtGetCheckedRadioButton(HWND hWnd,
  811. UINT uCtrlStart,
  812. UINT uCtrlStop)
  813. {
  814. UINT uCurrent = 0;
  815. for(uCurrent = uCtrlStart; uCurrent <= uCtrlStop; uCurrent++)
  816. {
  817. if(IsDlgButtonChecked(hWnd, uCurrent))
  818. {
  819. return uCurrent;
  820. }
  821. }
  822. // if we get here, none were checked
  823. return 0;
  824. } //*** end dmtGetCheckedRadioButton()
  825. //===========================================================================
  826. // dimaptstPostEnumEnable
  827. //
  828. // Enables/disables main app UI elements in response to enumerating devices
  829. //
  830. // Parameters:
  831. // HWND hwnd - main app window handle
  832. // BOOL fEnable - enable or disable controls
  833. //
  834. // Returns: nothing
  835. //
  836. // History:
  837. // 10/01/1999 - davidkl - created
  838. //===========================================================================
  839. void dimaptstPostEnumEnable(HWND hwnd,
  840. BOOL fEnable)
  841. {
  842. UINT u = 0;
  843. // devices list
  844. EnableWindow(GetDlgItem(hwnd, IDC_DEVICES_LABEL), fEnable);
  845. EnableWindow(GetDlgItem(hwnd, IDC_DEVICE_LIST), fEnable);
  846. //JJ UI FIX
  847. // test controls
  848. //for(u = IDC_TEST_CTRL_GROUP; u <= IDC_USE_CPL; u++)
  849. //{
  850. // EnableWindow(GetDlgItem(hwnd, u), fEnable);
  851. // }
  852. // ISSUE-2000/02/21-timgill disable integration control and start button for the preview
  853. // should be re-enabled once test mode code is fixed
  854. // EnableWindow(GetDlgItem(hwnd, IDC_USE_INTEGRATED), FALSE);
  855. // start button
  856. // EnableWindow(GetDlgItem(hwnd, IDOK), fEnable);
  857. #ifdef DDKAPP
  858. // mapping file group
  859. for(u = IDC_MAPPING_FILE_GROUP; u <= IDC_LAUNCH_CPL_EDIT_MODE; u++)
  860. {
  861. EnableWindow(GetDlgItem(hwnd, u), TRUE);
  862. }
  863. #else
  864. #ifdef TESTAPP
  865. // verification mode
  866. for(u = IDC_VERIFY_GROUP; u <= IDC_VERIFY_MANUAL; u++)
  867. {
  868. EnableWindow(GetDlgItem(hwnd, u), TRUE);
  869. }
  870. // this will enable the manual overrride option as appropriate
  871. SendMessageA(hwnd,
  872. WM_COMMAND,
  873. IDC_VERIFY_AUTOMATIC,
  874. 0L);
  875. // this will enable the configuration button and
  876. // expand the application window as appropriate
  877. SendMessageA(hwnd,
  878. WM_COMMAND,
  879. IDC_STRESS_MODE,
  880. 0L);
  881. #endif
  882. #endif
  883. } //*** end dimaptstPostEnumEnable()
  884. //===========================================================================
  885. //===========================================================================
  886. //===========================================================================
  887. //===========================================================================
  888. //===========================================================================
  889. //===========================================================================