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.

79 lines
2.2 KiB

  1. /*****************************************************************************
  2. *
  3. * diqdevm.c
  4. *
  5. * Acquire an IDirectInputDevice8 as if it were a mouse.
  6. *
  7. *****************************************************************************/
  8. #include "diquick.h"
  9. /*****************************************************************************
  10. *
  11. * Devm_UpdateStatus
  12. *
  13. *****************************************************************************/
  14. STDMETHODIMP
  15. Devm_UpdateStatus(PDEVDLGINFO pddi, LPTSTR ptszBuf)
  16. {
  17. HRESULT hres;
  18. #if DIRECTINPUT_VERSION >= 0x700
  19. DIMOUSESTATE2 md;
  20. #else
  21. DIMOUSESTATE md;
  22. #endif
  23. IDirectInputDevice8 *pdid = pddi->pdid;
  24. hres = IDirectInputDevice8_GetDeviceState(pdid, sizeof(md), &md);
  25. if (SUCCEEDED(hres)) {
  26. #if DIRECTINPUT_VERSION >= 0x700
  27. wsprintf(ptszBuf, TEXT("(%d, %d, %d) %c %c %c %c %c %c %c %c"),
  28. md.lX, md.lY, md.lZ,
  29. md.rgbButtons[0] & 0x80 ? '0' : ' ',
  30. md.rgbButtons[1] & 0x80 ? '1' : ' ',
  31. md.rgbButtons[2] & 0x80 ? '2' : ' ',
  32. md.rgbButtons[3] & 0x80 ? '3' : ' ',
  33. md.rgbButtons[4] & 0x80 ? '4' : ' ',
  34. md.rgbButtons[5] & 0x80 ? '5' : ' ',
  35. md.rgbButtons[6] & 0x80 ? '6' : ' ',
  36. md.rgbButtons[7] & 0x80 ? '7' : ' '
  37. );
  38. #else
  39. wsprintf(ptszBuf, TEXT("(%d, %d, %d) %c %c %c %c"),
  40. md.lX, md.lY, md.lZ,
  41. md.rgbButtons[0] & 0x80 ? '0' : ' ',
  42. md.rgbButtons[1] & 0x80 ? '1' : ' ',
  43. md.rgbButtons[2] & 0x80 ? '2' : ' ',
  44. md.rgbButtons[3] & 0x80 ? '3' : ' '
  45. );
  46. #endif
  47. }
  48. return hres;
  49. }
  50. /*****************************************************************************
  51. *
  52. * c_acqvtblDevMouse
  53. *
  54. *****************************************************************************/
  55. #pragma BEGIN_CONST_DATA
  56. ACQVTBL c_acqvtblDevMouse = {
  57. Devm_UpdateStatus,
  58. Common_AcqSetDataFormat,
  59. Common_AcqDestroy,
  60. &c_dfDIMouse,
  61. };
  62. ACQVTBL c_acqvtblDevMouse2 = {
  63. Devm_UpdateStatus,
  64. Common_AcqSetDataFormat,
  65. Common_AcqDestroy,
  66. &c_dfDIMouse2,
  67. };
  68. #pragma END_CONST_DATA