Leaked source code of windows server 2003
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.

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