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.

294 lines
8.7 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 = IDirectInputDevice8_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 = IDirectInputDevice8_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. //BUGBUG: Diquick should use latest version
  107. #if DIRECTINPUT_VERSION > 0x700
  108. hres = IDirectInputDevice8_GetProperty(pddi->pdid, DIPROP_SCANCODE,
  109. &u.dipdw.diph);
  110. #endif
  111. if (SUCCEEDED(hres)) {
  112. Vlist_AddIntValue(hwndList, IDS_PROP_SCANCODE, u.dipdw.dwData);
  113. }
  114. hres = IDirectInputDevice8_GetProperty(pddi->pdid, DIPROP_DEADZONE,
  115. &u.dipdw.diph);
  116. if (SUCCEEDED(hres)) {
  117. Vlist_AddNumValueRW(hwndList, IDS_PROP_DEADZONE, &u.dipdw,
  118. 0, 10001, 10,
  119. Prop_SetPropCallback, pddi, (PV)DIPROP_DEADZONE);
  120. }
  121. hres = IDirectInputDevice8_GetProperty(pddi->pdid, DIPROP_SATURATION,
  122. &u.dipdw.diph);
  123. if (SUCCEEDED(hres)) {
  124. Vlist_AddNumValueRW(hwndList, IDS_PROP_SATURATION, &u.dipdw,
  125. 0, 10001, 10,
  126. Prop_SetPropCallback, pddi, (PV)DIPROP_SATURATION);
  127. }
  128. hres = IDirectInputDevice8_GetProperty(pddi->pdid, DIPROP_CALIBRATIONMODE,
  129. &u.dipdw.diph);
  130. if (SUCCEEDED(hres)) {
  131. Vlist_AddBoolValueRW(hwndList, IDS_PROP_CALIBRATIONMODE, &u.dipdw,
  132. Prop_SetPropCallback, pddi,
  133. (PV)DIPROP_CALIBRATIONMODE);
  134. }
  135. u.dipwsz.diph.dwSize = cbX(u.dipwsz);
  136. //BUGBUG: Diquick should use latest version
  137. #if DIRECTINPUT_VERSION > 0x700
  138. hres = IDirectInputDevice8_GetProperty(pddi->pdid, DIPROP_KEYNAME,
  139. &u.dipwsz.diph);
  140. #endif
  141. if (SUCCEEDED(hres)) {
  142. #ifdef UNICODE
  143. Vlist_AddValue(hwndList, IDS_PROP_KEYNAME, u.dipwsz.wsz);
  144. #else
  145. {
  146. CHAR szTemp[cA(u.dipwsz.wsz)];
  147. ConvertString(TRUE, u.dipwsz.wsz, szTemp, cA(szTemp));
  148. Vlist_AddValue(hwndList, IDS_PROP_KEYNAME, szTemp);
  149. }
  150. #endif
  151. }
  152. u.diprg.diph.dwSize = cbX(u.diprg);
  153. hres = IDirectInputDevice8_GetProperty(pddi->pdid, DIPROP_RANGE,
  154. &u.dipcal.diph);
  155. if (SUCCEEDED(hres)) {
  156. Vlist_AddRangeValueRW(hwndList, IDS_PROP_RANGE,
  157. &u.diprg, 10,
  158. Prop_SetPropCallback, pddi, (PV)DIPROP_RANGE);
  159. }
  160. u.dipcal.diph.dwSize = cbX(u.dipcal);
  161. hres = IDirectInputDevice8_GetProperty(pddi->pdid, DIPROP_CALIBRATION,
  162. &u.dipcal.diph);
  163. if (SUCCEEDED(hres)) {
  164. Vlist_AddCalValueRW(hwndList, IDS_PROP_CAL,
  165. &u.dipcal, 10,
  166. Prop_SetPropCallback, pddi, (PV)DIPROP_CALIBRATION);
  167. }
  168. ListBox_SetCurSel(hwndList, 0);
  169. Vlist_OnSelChange(hwndList);
  170. SetDialogPtr(hdlg, pddi);
  171. return 1;
  172. }
  173. /*****************************************************************************
  174. *
  175. * Prop_SyncVlist
  176. *
  177. * Synchronize the value half of the list/value.
  178. *
  179. *****************************************************************************/
  180. BOOL INLINE
  181. Prop_SyncVlist(HWND hdlg)
  182. {
  183. Vlist_OnSelChange(GetDlgItem(hdlg, IDC_PROP_LIST));
  184. return TRUE;
  185. }
  186. /*****************************************************************************
  187. *
  188. * Prop_OnCommand
  189. *
  190. *****************************************************************************/
  191. BOOL INTERNAL
  192. Prop_OnCommand(HWND hdlg, int id, UINT cmd)
  193. {
  194. switch (id) {
  195. case IDC_PROP_LIST:
  196. if (cmd == LBN_SELCHANGE) {
  197. return Prop_SyncVlist(hdlg);
  198. }
  199. break;
  200. }
  201. return 0;
  202. }
  203. /*****************************************************************************
  204. *
  205. * Prop_OnDestroy
  206. *
  207. * Clean up
  208. *
  209. *****************************************************************************/
  210. void INLINE
  211. Prop_OnDestroy(HWND hdlg)
  212. {
  213. Vlist_OnDestroy(GetDlgItem(hdlg, IDC_PROP_LIST));
  214. }
  215. /*****************************************************************************
  216. *
  217. * Prop_DlgProc
  218. *
  219. *****************************************************************************/
  220. INT_PTR CALLBACK
  221. Prop_DlgProc(HWND hdlg, UINT wm, WPARAM wp, LPARAM lp)
  222. {
  223. switch (wm) {
  224. case WM_INITDIALOG: return Prop_OnInitDialog(hdlg, lp);
  225. case WM_COMMAND:
  226. return Prop_OnCommand(hdlg,
  227. (int)GET_WM_COMMAND_ID(wp, lp),
  228. (UINT)GET_WM_COMMAND_CMD(wp, lp));
  229. case WM_CLOSE: EndDialog(hdlg, 0); break;
  230. case WM_DESTROY:
  231. Prop_OnDestroy(hdlg);
  232. break;
  233. }
  234. return 0;
  235. }