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.

173 lines
4.4 KiB

  1. /*****************************************************************************
  2. *
  3. * diqeobj.c
  4. *
  5. * Property sheet page for device "enum objects".
  6. *
  7. *****************************************************************************/
  8. #include "diquick.h"
  9. /*****************************************************************************
  10. *
  11. * EObj_EnumCallback
  12. *
  13. * Called one for each object.
  14. *
  15. *****************************************************************************/
  16. typedef struct EOBJENUMINFO {
  17. HWND hwndList;
  18. PDEVDLGINFO pddi;
  19. } EOBJENUMINFO, *PEOBJENUMINFO;
  20. BOOL CALLBACK
  21. EObj_EnumCallback(const void *pvDoi, LPVOID pv)
  22. {
  23. PEOBJENUMINFO peoei = pv;
  24. int iItem;
  25. DIDEVICEOBJECTINSTANCE doi;
  26. ConvertDoi(peoei->pddi, &doi, pvDoi);
  27. iItem = ListBox_AddString(peoei->hwndList, doi.tszName);
  28. ListBox_SetItemData(peoei->hwndList, iItem, doi.dwType);
  29. return DIENUM_CONTINUE;
  30. }
  31. /*****************************************************************************
  32. *
  33. * EObj_Enum
  34. *
  35. * Enumerate the objects in the device and populate the list box.
  36. *
  37. *****************************************************************************/
  38. BOOL INTERNAL
  39. EObj_Enum(HWND hdlg, DWORD dwType)
  40. {
  41. EOBJENUMINFO eoei;
  42. #ifdef DEBUG
  43. int iItem;
  44. #endif
  45. eoei.pddi = GetDialogPtr(hdlg);
  46. eoei.hwndList = GetDlgItem(hdlg, IDC_ENUMOBJ_LIST);
  47. SetWindowRedraw(eoei.hwndList, 0);
  48. ListBox_ResetContent(eoei.hwndList);
  49. if (eoei.pddi->didcItf & 1) {
  50. IDirectInputDevice8_EnumObjects(eoei.pddi->pdid,
  51. EObj_EnumCallback, &eoei, dwType);
  52. } else {
  53. IDirectInputDevice8_EnumObjects(eoei.pddi->pdid,
  54. EObj_EnumCallback, &eoei, dwType);
  55. }
  56. #ifdef DEBUG
  57. iItem = ListBox_AddString(eoei.hwndList, TEXT("<invalid>"));
  58. ListBox_SetItemData(eoei.hwndList, iItem, 0);
  59. #endif
  60. SetWindowRedraw(eoei.hwndList, 1);
  61. return 1;
  62. }
  63. /*****************************************************************************
  64. *
  65. * EObj_OnInitDialog
  66. *
  67. * Start out by enumerating everything.
  68. *
  69. *****************************************************************************/
  70. BOOL INTERNAL
  71. EObj_OnInitDialog(HWND hdlg, LPARAM lp)
  72. {
  73. PDEVDLGINFO pddi = (PV)(((LPPROPSHEETPAGE)lp)->lParam);
  74. SetDialogPtr(hdlg, pddi);
  75. CheckRadioButton(hdlg, IDC_ENUMOBJ_AXES, IDC_ENUMOBJ_ALL, IDC_ENUMOBJ_ALL);
  76. EObj_Enum(hdlg, DIDFT_ALL);
  77. return 1;
  78. }
  79. /*****************************************************************************
  80. *
  81. * EObj_OnDblClk
  82. *
  83. * An item in the list box was double-clicked. Display details.
  84. *
  85. *****************************************************************************/
  86. BOOL INTERNAL
  87. EObj_OnDblClk(HWND hdlg)
  88. {
  89. PDEVDLGINFO pddi = GetDialogPtr(hdlg);
  90. HWND hwndList = GetDlgItem(hdlg, IDC_ENUMOBJ_LIST);
  91. int iItem;
  92. iItem = ListBox_GetCurSel(hwndList);
  93. if (iItem >= 0) {
  94. DialogBoxParam(g_hinst, MAKEINTRESOURCE(IDD_OBJPROP),
  95. GetParent(hdlg), Prop_DlgProc, (LPARAM)hdlg);
  96. /*
  97. * That dialog screws up the vwi state.
  98. */
  99. SetActiveWindow(hdlg);
  100. }
  101. return 1;
  102. }
  103. /*****************************************************************************
  104. *
  105. * EObj_OnCommand
  106. *
  107. *****************************************************************************/
  108. BOOL INLINE
  109. EObj_OnCommand(HWND hdlg, int id, UINT cmd)
  110. {
  111. switch (id) {
  112. case IDC_ENUMOBJ_AXES: return EObj_Enum(hdlg, DIDFT_AXIS);
  113. case IDC_ENUMOBJ_BUTTONS: return EObj_Enum(hdlg, DIDFT_BUTTON);
  114. case IDC_ENUMOBJ_POVS: return EObj_Enum(hdlg, DIDFT_POV);
  115. case IDC_ENUMOBJ_ALL: return EObj_Enum(hdlg, DIDFT_ALL | DIDFT_ALIAS | DIDFT_VENDORDEFINED);
  116. case IDC_ENUMOBJ_LIST:
  117. if (cmd == LBN_DBLCLK)return EObj_OnDblClk(hdlg);
  118. break;
  119. case IDC_ENUMOBJ_PROP: return EObj_OnDblClk(hdlg);
  120. }
  121. return 0;
  122. }
  123. /*****************************************************************************
  124. *
  125. * EObj_DlgProc
  126. *
  127. *****************************************************************************/
  128. INT_PTR CALLBACK
  129. EObj_DlgProc(HWND hdlg, UINT wm, WPARAM wp, LPARAM lp)
  130. {
  131. switch (wm) {
  132. case WM_INITDIALOG: return EObj_OnInitDialog(hdlg, lp);
  133. case WM_COMMAND:
  134. return EObj_OnCommand(hdlg,
  135. (int)GET_WM_COMMAND_ID(wp, lp),
  136. (UINT)GET_WM_COMMAND_CMD(wp, lp));
  137. }
  138. return 0;
  139. }