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.

550 lines
13 KiB

  1. /*****************************************************************************
  2. *
  3. * DIGenDef.c
  4. *
  5. * Copyright (c) 1996 Microsoft Corporation. All Rights Reserved.
  6. *
  7. * Abstract:
  8. *
  9. * Default IDirectInputDevice callback.
  10. *
  11. * Contents:
  12. *
  13. * CDefDcb_Acquire
  14. * CDefDcb_Unacquire
  15. * CDefDcb_GetProperty
  16. * CDefDcb_SetProperty
  17. * CDefDcb_SetCooperativeLevel
  18. * CDefDcb_CookDeviceData
  19. * CDefDcb_CreateEffect
  20. * CDefDcb_GetFFConfigKey
  21. * CDefDcb_SendDeviceData
  22. * CDefDcb_Poll
  23. * CDefDcb_MapUsage
  24. * CDefDcb_GetUsage
  25. * CDefDcb_SetDIData
  26. *
  27. *****************************************************************************/
  28. #include "dinputpr.h"
  29. /*****************************************************************************
  30. *
  31. * The sqiffle for this file.
  32. *
  33. *****************************************************************************/
  34. #define sqfl sqflNil
  35. /*****************************************************************************
  36. *
  37. * Note! These are generic default functions that all return
  38. * E_NOTIMPL.
  39. *
  40. *****************************************************************************/
  41. /*****************************************************************************
  42. *
  43. * @doc INTERNAL
  44. *
  45. * @method HRESULT | CDefDcb | Acquire |
  46. *
  47. * Tell the device driver to begin data acquisition.
  48. *
  49. * It is the caller's responsibility to have set the
  50. * data format before obtaining acquisition.
  51. *
  52. * @returns
  53. *
  54. * Returns a COM error code. The following error codes are
  55. * intended to be illustrative and not necessarily comprehensive.
  56. *
  57. * <c DI_OK> = <c S_OK>: The operation completed successfully.
  58. *
  59. * <c DIERR_NOTACQUIRED>: The device could not be acquired.
  60. *
  61. *****************************************************************************/
  62. STDMETHODIMP
  63. CDefDcb_Acquire(PDICB pdcb)
  64. {
  65. HRESULT hres;
  66. EnterProcI(IDirectInputDeviceCallback::Def::Acquire, (_ "p", pdcb));
  67. hres = S_FALSE;
  68. ExitOleProcR();
  69. return hres;
  70. }
  71. /*****************************************************************************
  72. *
  73. * @doc INTERNAL
  74. *
  75. * @method HRESULT | CDefDcb | Unacquire |
  76. *
  77. * Tell the device driver to stop data acquisition.
  78. *
  79. * It is the caller's responsibility to call this only
  80. * when the device has been acquired.
  81. *
  82. * @returns
  83. *
  84. * Returns a COM error code. The following error codes are
  85. * intended to be illustrative and not necessarily comprehensive.
  86. *
  87. * <c DI_OK> = <c S_OK>: The operation completed successfully.
  88. *
  89. * <c DIERR_NOTACQUIRED>: The device was not acquired.
  90. *
  91. *****************************************************************************/
  92. STDMETHODIMP
  93. CDefDcb_Unacquire(PDICB pdcb)
  94. {
  95. HRESULT hres;
  96. EnterProcI(IDirectInputDeviceCallback::Def::Unacquire, (_ "p", pdcb));
  97. hres = S_FALSE;
  98. ExitOleProcR();
  99. return hres;
  100. }
  101. /*****************************************************************************
  102. *
  103. * @doc INTERNAL
  104. *
  105. * @method void | CDefDcb | GetProperty |
  106. *
  107. * Retrieve a device property.
  108. *
  109. * @parm IN LPCDIPROPINFO | ppropi |
  110. *
  111. * Information describing the property being retrieved.
  112. *
  113. * @parm LPDIPROPHEADER | pdiph |
  114. *
  115. * Where to put the property value.
  116. *
  117. * @returns
  118. *
  119. * <c E_NOTIMPL> nothing happened.
  120. *
  121. *****************************************************************************/
  122. STDMETHODIMP
  123. CDefDcb_GetProperty(PDICB pdcb, LPCDIPROPINFO ppropi, LPDIPROPHEADER pdiph)
  124. {
  125. HRESULT hres;
  126. EnterProcI(IDirectInputDeviceCallback::Def::GetProperty,
  127. (_ "pxxp", pdcb, ppropi->pguid, ppropi->iobj, pdiph));
  128. hres = E_NOTIMPL;
  129. ExitOleProcR();
  130. return hres;
  131. }
  132. /*****************************************************************************
  133. *
  134. * @doc INTERNAL
  135. *
  136. * @method void | CDefDcb | SetProperty |
  137. *
  138. * Set a device property.
  139. *
  140. * @parm IN LPCDIPROPINFO | ppropi |
  141. *
  142. * Information describing the property being set.
  143. *
  144. * @parm LPCDIPROPHEADER | pdiph |
  145. *
  146. * Structure containing property value.
  147. *
  148. * @returns
  149. *
  150. * <c E_NOTIMPL> nothing happened.
  151. *
  152. *****************************************************************************/
  153. STDMETHODIMP
  154. CDefDcb_SetProperty(PDICB pdcb, LPCDIPROPINFO ppropi, LPCDIPROPHEADER pdiph)
  155. {
  156. HRESULT hres;
  157. EnterProcI(IDirectInputDeviceCallback::Def::SetProperty,
  158. (_ "pxxp", pdcb, ppropi->pguid, ppropi->iobj, pdiph));
  159. hres = E_NOTIMPL;
  160. ExitOleProcR();
  161. return hres;
  162. }
  163. /*****************************************************************************
  164. *
  165. * @doc INTERNAL
  166. *
  167. * @method HRESULT | CDefDcb | SetEventNotification |
  168. *
  169. * Called by DirectInput to inquire whether the device
  170. * supports event notifications.
  171. *
  172. * @parm IN PDM | this |
  173. *
  174. * The object in question.
  175. *
  176. * @field HANDLE | h |
  177. *
  178. * The notification handle, if any.
  179. *
  180. * @returns
  181. *
  182. * Returns a COM error code.
  183. *
  184. * <c S_FALSE>: The operation was begun and should be completed
  185. * by the caller by communicating with the <t VXDINSTANCE>.
  186. *
  187. *****************************************************************************/
  188. STDMETHODIMP
  189. CDefDcb_SetEventNotification(PDICB pdcb, HANDLE h)
  190. {
  191. HRESULT hres;
  192. EnterProcI(IDirectInputDeviceCallback::DefDcb::SetEventNotification,
  193. (_ "px", pdcb, h));
  194. /*
  195. * Yes, we support it. Please do it for me.
  196. */
  197. hres = S_FALSE;
  198. ExitOleProcR();
  199. return hres;
  200. }
  201. /*****************************************************************************
  202. *
  203. * @doc INTERNAL
  204. *
  205. * @method HRESULT | CDefdcb | SetCooperativeLevel |
  206. *
  207. * Notify the device of the cooperative level.
  208. *
  209. * @parm IN HWND | hwnd |
  210. *
  211. * The window handle.
  212. *
  213. * @parm IN DWORD | dwFlags |
  214. *
  215. * The cooperativity level.
  216. *
  217. * @returns
  218. *
  219. * Returns a COM error code.
  220. *
  221. *****************************************************************************/
  222. STDMETHODIMP
  223. CDefDcb_SetCooperativeLevel(PDICB pdcb, HWND hwnd, DWORD dwFlags)
  224. {
  225. HRESULT hres;
  226. EnterProcI(IDirectInputDeviceCallback::Def::SetCooperativityLevel,
  227. (_ "pxx", pdcb, hwnd, dwFlags));
  228. hres = S_OK;
  229. ExitOleProcR();
  230. return hres;
  231. }
  232. /*****************************************************************************
  233. *
  234. * @doc INTERNAL
  235. *
  236. * @method HRESULT | CDefDcb | CookDeviceData |
  237. *
  238. * Manipulate buffered device data.
  239. *
  240. * @parm UINT | cdod |
  241. *
  242. * Number of objects to cook; zero is a valid value.
  243. *
  244. * @parm LPDIDEVICEOBJECTDATA | rgdod |
  245. *
  246. * Array of object data to cook.
  247. *
  248. * @returns
  249. *
  250. * <c E_NOTIMPL>: Nothing happened.
  251. *
  252. ***************************************************************************/
  253. STDMETHODIMP
  254. CDefDcb_CookDeviceData(PDICB pdcb, UINT cdod, LPDIDEVICEOBJECTDATA rgdod)
  255. {
  256. HRESULT hres;
  257. EnterProcI(IDirectInputDeviceCallback::Def::CookDeviceData,
  258. (_ "pxp", pdcb, cdod, rgdod));
  259. hres = E_NOTIMPL;
  260. ExitOleProcR();
  261. return hres;
  262. }
  263. /*****************************************************************************
  264. *
  265. * @doc INTERNAL
  266. *
  267. * @method HRESULT | CDefDcb | CreateEffect |
  268. *
  269. * Create an <i IDirectInputEffectDriver> interface.
  270. *
  271. * @parm LPDIRECTINPUTEFFECTSHEPHERD * | ppes |
  272. *
  273. * Receives the shepherd for the effect driver.
  274. *
  275. *****************************************************************************/
  276. STDMETHODIMP
  277. CDefDcb_CreateEffect(PDICB pdcb, LPDIRECTINPUTEFFECTSHEPHERD *ppes)
  278. {
  279. HRESULT hres;
  280. EnterProcI(IDirectInputDeviceCallback::Kbd::CreateEffect, (_ "p", pdcb));
  281. hres = E_NOTIMPL;
  282. ExitOleProcR();
  283. return hres;
  284. }
  285. /*****************************************************************************
  286. *
  287. * @doc INTERNAL
  288. *
  289. * @method HRESULT | CDefDcb | GetFFConfigKey |
  290. *
  291. * Open and return the registry key that contains
  292. * force feedback configuration information.
  293. *
  294. * @parm DWORD | sam |
  295. *
  296. * Security access mask.
  297. *
  298. * @parm PHKEY | phk |
  299. *
  300. * Receives the registry key.
  301. *
  302. *****************************************************************************/
  303. STDMETHODIMP
  304. CDefDcb_GetFFConfigKey(PDICB pdcb, DWORD sam, PHKEY phk)
  305. {
  306. HRESULT hres;
  307. EnterProcI(IDirectInputDeviceCallback::Def::GetFFConfigKey,
  308. (_ "px", pdcb, sam));
  309. hres = E_NOTIMPL;
  310. ExitOleProcR();
  311. return hres;
  312. }
  313. /*****************************************************************************
  314. *
  315. * @doc INTERNAL
  316. *
  317. * @method HRESULT | CDefDcb | SendDeviceData |
  318. *
  319. * Spew some data to the device.
  320. *
  321. * @parm IN LPCDIDEVICEOBJECTDATA | rgdod |
  322. *
  323. * Array of <t DIDEVICEOBJECTDATA> structures.
  324. *
  325. * @parm INOUT LPDWORD | pdwInOut |
  326. *
  327. * Number of items actually sent.
  328. *
  329. * @parm DWORD | fl |
  330. *
  331. * Flags.
  332. *
  333. * @returns
  334. *
  335. * <c E_NOTIMPL> because we don't support output.
  336. *
  337. *****************************************************************************/
  338. STDMETHODIMP
  339. CDefDcb_SendDeviceData(PDICB pdcb, LPCDIDEVICEOBJECTDATA rgdod,
  340. LPDWORD pdwInOut, DWORD fl)
  341. {
  342. HRESULT hres;
  343. EnterProcI(IDirectInputDeviceCallback::Def::SendDeviceData, (_ "p", pdcb));
  344. *pdwInOut = 0;
  345. hres = E_NOTIMPL;
  346. ExitOleProcR();
  347. return hres;
  348. }
  349. /*****************************************************************************
  350. *
  351. * @doc INTERNAL
  352. *
  353. * @method HRESULT | CDefDcb | Poll |
  354. *
  355. * Ping down into the driver to get the latest data.
  356. *
  357. * @returns
  358. *
  359. * <c S_FALSE> because nothing is pollable.
  360. *
  361. *****************************************************************************/
  362. STDMETHODIMP
  363. CDefDcb_Poll(PDICB pdcb)
  364. {
  365. HRESULT hres;
  366. EnterProcI(IDirectInputDeviceCallback::Def::Poll, (_ "p", pdcb));
  367. hres = S_FALSE;
  368. ExitOleProcR();
  369. return hres;
  370. }
  371. /****************************************************************************
  372. *
  373. * @doc INTERNAL
  374. *
  375. * @method HRESULT | CDefDcb | GetVersions |
  376. *
  377. * Obtain version information about the force feedback
  378. * hardware and driver.
  379. *
  380. * @returns
  381. *
  382. * Returns a COM error code. The following error codes are
  383. * intended to be illustrative and not necessarily comprehensive.
  384. *
  385. * <c DI_OK> = <c S_OK>: The operation completed successfully.
  386. *
  387. * <c DIERR_UNSUPPORTED> = <c E_NOTIMPL>: No version
  388. * information is available.
  389. *
  390. ***************************************************************************/
  391. STDMETHODIMP
  392. CDefDcb_GetVersions(PDICB pdcb, LPDIDRIVERVERSIONS pvers)
  393. {
  394. HRESULT hres;
  395. EnterProcI(IDirectInputDeviceCallback::Def::GetVersions, (_ "p", pdcb));
  396. hres = E_NOTIMPL;
  397. ExitOleProcR();
  398. return hres;
  399. }
  400. /*****************************************************************************
  401. *
  402. * @doc INTERNAL
  403. *
  404. * @method HRESULT | CDefDcb | MapUsage |
  405. *
  406. * Given a usage and usage page (munged into a single
  407. * <t DWORD>), find a device object that matches it.
  408. *
  409. * @parm DWORD | dwUsage |
  410. *
  411. * The usage page and usage combined into a single <t DWORD>
  412. * with the <f DIMAKEUSAGEDWORD> macro.
  413. *
  414. * @parm PINT | piOut |
  415. *
  416. * Receives the object index of the found object, if successful.
  417. *
  418. * @returns
  419. *
  420. * <c E_NOTIMPL> because we don't support usages.
  421. *
  422. *****************************************************************************/
  423. STDMETHODIMP
  424. CDefDcb_MapUsage(PDICB pdcb, DWORD dwUsage, PINT piOut)
  425. {
  426. HRESULT hres;
  427. EnterProcI(IDirectInputDeviceCallback::Def::MapUsage, (_ "p", pdcb));
  428. hres = E_NOTIMPL;
  429. ExitOleProcR();
  430. return hres;
  431. }
  432. /*****************************************************************************
  433. *
  434. * @doc INTERNAL
  435. *
  436. * @method DWORD | CDefDcb | GetUsage |
  437. *
  438. * Given an object index, return the usage and usage page,
  439. * packed into a single <t DWORD>.
  440. *
  441. * @parm int | iobj |
  442. *
  443. * The object index to convert.
  444. *
  445. * @returns
  446. *
  447. * Zero because we don't support usages.
  448. *
  449. *****************************************************************************/
  450. STDMETHODIMP_(DWORD)
  451. CDefDcb_GetUsage(PDICB pdcb, int iobj)
  452. {
  453. EnterProcI(IDirectInputDeviceCallback::Def::GetUsage, (_ "p", pdcb));
  454. return 0;
  455. }
  456. /*****************************************************************************
  457. *
  458. * @doc INTERNAL
  459. *
  460. * @method HRESULT | CDefDcb | SetDIData |
  461. *
  462. * Set DirectInput version and AppHack data from CDIDev *.
  463. *
  464. * @parm DWORD | dwVer |
  465. *
  466. * DirectInput version
  467. *
  468. * @parm LPVOID | lpdihacks |
  469. *
  470. * AppHack data
  471. *
  472. * @returns
  473. *
  474. * <c E_NOTIMPL> because we don't support usages.
  475. *
  476. *****************************************************************************/
  477. STDMETHODIMP
  478. CDefDcb_SetDIData(PDICB pdcb, DWORD dwVer, LPVOID lpdihacks)
  479. {
  480. HRESULT hres;
  481. EnterProcI(IDirectInputDeviceCallback::Def::SetDIData, (_ "pup", pdcb, dwVer, lpdihacks));
  482. hres = E_NOTIMPL;
  483. ExitOleProcR();
  484. return hres;
  485. }