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.

264 lines
7.8 KiB

  1. /*****************************************************************************
  2. *
  3. * diqprop.c
  4. *
  5. * Property sheet page for device object properties.
  6. *
  7. *****************************************************************************/
  8. #include "diquick.h"
  9. #pragma BEGIN_CONST_DATA
  10. CHECKLISTFLAG c_rgcfDidoi[] = {
  11. { DIDOI_FFACTUATOR, IDS_PROP_FFACTUATOR, },
  12. { DIDOI_FFEFFECTTRIGGER, IDS_PROP_FFEFFECTTRIGGER, },
  13. { DIDOI_POLLED, IDS_PROP_POLLED, },
  14. };
  15. #pragma END_CONST_DATA
  16. /*****************************************************************************
  17. *
  18. * Prop_SetPropCallback
  19. *
  20. *****************************************************************************/
  21. HRESULT CALLBACK
  22. Prop_SetPropCallback(LPDIPROPHEADER pdiph, PV pvRef1, PV pvRef2)
  23. {
  24. PDEVDLGINFO pddi = pvRef1;
  25. const GUID *prop = (const GUID *)pvRef2;
  26. HRESULT hres;
  27. hres = IDirectInputDevice_SetProperty(pddi->pdid, prop, pdiph);
  28. return hres;
  29. }
  30. /*****************************************************************************
  31. *
  32. * Prop_OnInitDialog
  33. *
  34. * Fill with the properties of the item.
  35. *
  36. *****************************************************************************/
  37. BOOL INTERNAL
  38. Prop_OnInitDialog(HWND hdlg, LPARAM lp)
  39. {
  40. HWND hdlgParent = (HWND)lp;
  41. HWND hwndList = GetDlgItem(hdlgParent, IDC_ENUMOBJ_LIST);
  42. PDEVDLGINFO pddi = GetDialogPtr(hdlgParent);
  43. DWORD dwObj;
  44. DIDEVICEOBJECTINSTANCE doi;
  45. HRESULT hres;
  46. int iItem;
  47. union {
  48. DIPROPDWORD dipdw;
  49. DIPROPRANGE diprg;
  50. DIPROPCAL dipcal;
  51. DIPROPSTRING dipwsz;
  52. } u;
  53. iItem = ListBox_GetCurSel(hwndList);
  54. dwObj = (DWORD)ListBox_GetItemData(hwndList, iItem);
  55. SetWindowLongPtr(hdlg, GWLP_USERDATA, dwObj);
  56. /*
  57. * Don't SetDialogPtr until we're finished. This prevents
  58. * WM_COMMAND from causing us to do wacky things before
  59. * we're ready.
  60. */
  61. hwndList = GetDlgItem(hdlg, IDC_PROP_LIST);
  62. Vlist_OnInitDialog(hwndList);
  63. hres = GetObjectInfo(pddi, &doi, dwObj, DIPH_BYID);
  64. if (SUCCEEDED(hres)) {
  65. REFCLSID rclsid = &doi.guidType;
  66. SetWindowText(hdlg, doi.tszName);
  67. Vlist_AddValue(hwndList, IDS_PROP_TYPE,
  68. MapGUID(rclsid, doi.tszName));
  69. Vlist_AddIntValue(hwndList, IDS_PROP_OFS, doi.dwOfs);
  70. Vlist_AddHexValue(hwndList, IDS_PROP_OBJTYPE, doi.dwType);
  71. Vlist_AddFlags(hwndList, doi.dwFlags, c_rgcfDidoi, cA(c_rgcfDidoi));
  72. LoadString(g_hinst,
  73. IDS_PROP_ASPECTS + ((doi.dwFlags & DIDOI_ASPECTMASK) >> 8),
  74. doi.tszName, cA(doi.tszName));
  75. if (doi.tszName[0]) {
  76. Vlist_AddValue(hwndList, IDS_PROP_ASPECT, doi.tszName);
  77. } else {
  78. Vlist_AddHexValue(hwndList, IDS_PROP_ASPECT,
  79. doi.dwFlags & DIDOI_ASPECTMASK);
  80. }
  81. if (doi.dwSize > sizeof(DIDEVICEOBJECTINSTANCE_DX3)) {
  82. Vlist_AddIntValue(hwndList, IDS_PROP_FFMAXFORCE, doi.dwFFMaxForce);
  83. Vlist_AddIntValue(hwndList, IDS_PROP_FFFORCERESOLUTION,
  84. doi.dwFFForceResolution);
  85. Vlist_AddIntValue(hwndList, IDS_PROP_COLLECTIONNUMBER,
  86. doi.wCollectionNumber);
  87. Vlist_AddIntValue(hwndList, IDS_PROP_DESIGNATORINDEX,
  88. doi.wDesignatorIndex);
  89. Vlist_AddIntValue(hwndList, IDS_PROP_USAGEPAGE,
  90. doi.wUsagePage);
  91. Vlist_AddIntValue(hwndList, IDS_PROP_USAGE,
  92. doi.wUsage);
  93. Vlist_AddIntValue(hwndList, IDS_PROP_REPORTID,
  94. doi.wReportId);
  95. }
  96. }
  97. u.dipdw.diph.dwSize = cbX(u.dipdw);
  98. u.dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
  99. u.dipdw.diph.dwObj = dwObj;
  100. u.dipdw.diph.dwHow = DIPH_BYID;
  101. hres = IDirectInputDevice_GetProperty(pddi->pdid, DIPROP_GRANULARITY,
  102. &u.dipdw.diph);
  103. if (SUCCEEDED(hres)) {
  104. Vlist_AddIntValue(hwndList, IDS_PROP_GRANULARITY, u.dipdw.dwData);
  105. }
  106. hres = IDirectInputDevice_GetProperty(pddi->pdid, DIPROP_DEADZONE,
  107. &u.dipdw.diph);
  108. if (SUCCEEDED(hres)) {
  109. Vlist_AddNumValueRW(hwndList, IDS_PROP_DEADZONE, &u.dipdw,
  110. 0, 10001, 10,
  111. Prop_SetPropCallback, pddi, (PV)DIPROP_DEADZONE);
  112. }
  113. hres = IDirectInputDevice_GetProperty(pddi->pdid, DIPROP_SATURATION,
  114. &u.dipdw.diph);
  115. if (SUCCEEDED(hres)) {
  116. Vlist_AddNumValueRW(hwndList, IDS_PROP_SATURATION, &u.dipdw,
  117. 0, 10001, 10,
  118. Prop_SetPropCallback, pddi, (PV)DIPROP_SATURATION);
  119. }
  120. hres = IDirectInputDevice_GetProperty(pddi->pdid, DIPROP_CALIBRATIONMODE,
  121. &u.dipdw.diph);
  122. if (SUCCEEDED(hres)) {
  123. Vlist_AddBoolValueRW(hwndList, IDS_PROP_CALIBRATIONMODE, &u.dipdw,
  124. Prop_SetPropCallback, pddi,
  125. (PV)DIPROP_CALIBRATIONMODE);
  126. }
  127. u.diprg.diph.dwSize = cbX(u.diprg);
  128. hres = IDirectInputDevice_GetProperty(pddi->pdid, DIPROP_RANGE,
  129. &u.dipcal.diph);
  130. if (SUCCEEDED(hres)) {
  131. Vlist_AddRangeValueRW(hwndList, IDS_PROP_RANGE,
  132. &u.diprg, 10,
  133. Prop_SetPropCallback, pddi, (PV)DIPROP_RANGE);
  134. }
  135. u.dipcal.diph.dwSize = cbX(u.dipcal);
  136. hres = IDirectInputDevice_GetProperty(pddi->pdid, DIPROP_CALIBRATION,
  137. &u.dipcal.diph);
  138. if (SUCCEEDED(hres)) {
  139. Vlist_AddCalValueRW(hwndList, IDS_PROP_CAL,
  140. &u.dipcal, 10,
  141. Prop_SetPropCallback, pddi, (PV)DIPROP_CALIBRATION);
  142. }
  143. ListBox_SetCurSel(hwndList, 0);
  144. Vlist_OnSelChange(hwndList);
  145. SetDialogPtr(hdlg, pddi);
  146. return 1;
  147. }
  148. /*****************************************************************************
  149. *
  150. * Prop_SyncVlist
  151. *
  152. * Synchronize the value half of the list/value.
  153. *
  154. *****************************************************************************/
  155. BOOL INLINE
  156. Prop_SyncVlist(HWND hdlg)
  157. {
  158. Vlist_OnSelChange(GetDlgItem(hdlg, IDC_PROP_LIST));
  159. return TRUE;
  160. }
  161. /*****************************************************************************
  162. *
  163. * Prop_OnCommand
  164. *
  165. *****************************************************************************/
  166. BOOL INTERNAL
  167. Prop_OnCommand(HWND hdlg, int id, UINT cmd)
  168. {
  169. switch (id) {
  170. case IDC_PROP_LIST:
  171. if (cmd == LBN_SELCHANGE) {
  172. return Prop_SyncVlist(hdlg);
  173. }
  174. break;
  175. }
  176. return 0;
  177. }
  178. /*****************************************************************************
  179. *
  180. * Prop_OnDestroy
  181. *
  182. * Clean up
  183. *
  184. *****************************************************************************/
  185. void INLINE
  186. Prop_OnDestroy(HWND hdlg)
  187. {
  188. Vlist_OnDestroy(GetDlgItem(hdlg, IDC_PROP_LIST));
  189. }
  190. /*****************************************************************************
  191. *
  192. * Prop_DlgProc
  193. *
  194. *****************************************************************************/
  195. INT_PTR CALLBACK
  196. Prop_DlgProc(HWND hdlg, UINT wm, WPARAM wp, LPARAM lp)
  197. {
  198. switch (wm) {
  199. case WM_INITDIALOG: return Prop_OnInitDialog(hdlg, lp);
  200. case WM_COMMAND:
  201. return Prop_OnCommand(hdlg,
  202. (int)GET_WM_COMMAND_ID(wp, lp),
  203. (UINT)GET_WM_COMMAND_CMD(wp, lp));
  204. case WM_CLOSE: EndDialog(hdlg, 0); break;
  205. case WM_DESTROY:
  206. Prop_OnDestroy(hdlg);
  207. break;
  208. }
  209. return 0;
  210. }