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.

133 lines
4.4 KiB

  1. //===========================================================================
  2. // dmtxlat.cpp
  3. //
  4. // Value lookup tables
  5. //
  6. // Functions:
  7. // dmtxlatHRESULT
  8. //
  9. // History:
  10. // 11/09/1999 - davidkl - created
  11. //===========================================================================
  12. #include "dimaptst.h"
  13. //---------------------------------------------------------------------------
  14. // HRESULT error list (used by dmtxlatHRESULT)
  15. typedef struct _errlist
  16. {
  17. HRESULT rval;
  18. PSTR sz;
  19. } ERRLIST;
  20. static ERRLIST elErrors[] =
  21. {
  22. // these are listed as found in dinput.h
  23. // success codes
  24. { DI_OK, "S_OK" },
  25. { S_FALSE, "DI_NOTATTACHED | DI_BUFFEROVERFLOW | DI_PROPNOEFFECT | DI_NOEFFECT" },
  26. { DI_POLLEDDEVICE, "DI_POLLEDDEVICE" },
  27. { DI_DOWNLOADSKIPPED, "DI_DOWNLOADSKIPPED" },
  28. { DI_EFFECTRESTARTED, "DI_EFFECTRESTARTED" },
  29. { DI_TRUNCATED, "DI_TRUNCATED" },
  30. { DI_TRUNCATEDANDRESTARTED, "DI_TRUNCATEDANDRESTARTED" },
  31. // failure codes
  32. { DIERR_OLDDIRECTINPUTVERSION, "DIERR_OLDDIRECTINPUTVERSION" },
  33. { DIERR_BETADIRECTINPUTVERSION, "DIERR_BETADIRECTINPUTVERSION" },
  34. { DIERR_BADDRIVERVER, "DIERR_BADDRIVERVER" },
  35. { REGDB_E_CLASSNOTREG, "DIERR_DEVICENOTREG" },
  36. { DIERR_NOTFOUND, "DIERR_NOTFOUND | DIERR_OBJECTNOTFOUND" },
  37. { E_INVALIDARG, "DIERR_INVALIDPARAM" },
  38. { E_NOINTERFACE, "DIERR_NOINTERFACE" },
  39. { E_FAIL, "DIERR_GENERIC" },
  40. { E_OUTOFMEMORY, "DIERR_OUTOFMEMORY" },
  41. { E_NOTIMPL, "DIERR_UNSUPPORTED" },
  42. { DIERR_NOTINITIALIZED, "DIERR_NOTINITIALIZED" },
  43. { DIERR_ALREADYINITIALIZED, "DIERR_ALREADYINITIALIZED" },
  44. { CLASS_E_NOAGGREGATION, "DIERR_NOAGGREGATION" },
  45. { E_ACCESSDENIED, "DIERR_OTHERAPPHASPRIO | DIERR_READONLY | DIERR_HANDLEEXISTS" },
  46. { DIERR_INPUTLOST, "DIERR_INPUTLOST" },
  47. { DIERR_ACQUIRED, "DIERR_ACQUIRED" },
  48. { DIERR_NOTACQUIRED, "DIERR_NOTACQUIRED" },
  49. { E_PENDING, "E_PENDING" },
  50. { DIERR_INSUFFICIENTPRIVS, "DIERR_INSUFFICIENTPRIVS" },
  51. { DIERR_DEVICEFULL, "DIERR_DEVICEFULL" },
  52. { DIERR_MOREDATA, "DIERR_MOREDATA" },
  53. { DIERR_NOTDOWNLOADED, "DIERR_NOTDOWNLOADED" },
  54. { DIERR_HASEFFECTS, "DIERR_HASEFFECTS" },
  55. { DIERR_NOTEXCLUSIVEACQUIRED, "DIERR_NOTEXCLUSIVEACQUIRED" },
  56. { DIERR_INCOMPLETEEFFECT, "DIERR_INCOMPLETEEFFECT" },
  57. { DIERR_NOTBUFFERED, "DIERR_NOTBUFFERED" },
  58. { DIERR_EFFECTPLAYING, "DIERR_EFFECTPLAYING" },
  59. { DIERR_UNPLUGGED, "DIERR_UNPLUGGED" },
  60. { DIERR_REPORTFULL, "DIERR_REPORTFULL" }
  61. };
  62. //---------------------------------------------------------------------------
  63. //===========================================================================
  64. // dmtxlatHRESULT
  65. //
  66. // Translates HRESULT codes into human readable form.
  67. //
  68. // Parameters:
  69. // HRESULT hRes - result code to translate
  70. //
  71. // Returns: PSTR
  72. //
  73. // History:
  74. // 11/09/1999 - davidkl - created (adapted from tdmusic sources)
  75. //===========================================================================
  76. PSTR dmtxlatHRESULT(HRESULT hRes)
  77. {
  78. int i = 0;
  79. for(i = 0; i < COUNT_ARRAY_ELEMENTS(elErrors); i++ )
  80. {
  81. if(hRes == elErrors[i].rval)
  82. {
  83. return elErrors[i].sz;
  84. }
  85. }
  86. return (PSTR)"Unknown HRESULT";
  87. } //*** end dmtxlatHRESULT()
  88. //===========================================================================
  89. // dmtxlatAppData
  90. //
  91. // Translates DIDEVICEOBJECTDATA.uAppData into text string representing
  92. // semantic action.
  93. //
  94. // Parameters:
  95. //
  96. // Returns: PSTR
  97. //
  98. // History:
  99. // 11/11/1999 - davidkl - created
  100. //===========================================================================
  101. PSTR dmtxlatAppData(UINT_PTR uAppData,
  102. ACTIONNAME *pan,
  103. DWORD dwActions)
  104. {
  105. DWORD dw = 0;
  106. for(dw = 0; dw < dwActions; dw++)
  107. {
  108. if(((DWORD)uAppData) == (pan+dw)->dw)
  109. {
  110. return (pan+dw)->sz;
  111. }
  112. }
  113. return (PSTR)"Unknown action";
  114. } //*** end dmtxlatAppData()