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.

96 lines
2.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: didevinstobj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #define DIRECTINPUT_VERSION 0x0500
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "diDevInstObj.h"
  15. extern BSTR GUIDtoBSTR(LPGUID g);
  16. extern BSTR DINPUTGUIDtoBSTR(LPGUID g);
  17. STDMETHODIMP C_dxj_DIDeviceInstanceObject::getGuidInstance( BSTR __RPC_FAR *ret){
  18. *ret=DINPUTGUIDtoBSTR(&m_inst.guidInstance);
  19. return S_OK;
  20. }
  21. STDMETHODIMP C_dxj_DIDeviceInstanceObject::getGuidProduct( BSTR __RPC_FAR *ret){
  22. *ret=GUIDtoBSTR( &(m_inst.guidProduct));
  23. return S_OK;
  24. }
  25. STDMETHODIMP C_dxj_DIDeviceInstanceObject::getGuidFFDriver( BSTR __RPC_FAR *ret){
  26. *ret=DINPUTGUIDtoBSTR(&(m_inst.guidFFDriver));
  27. return S_OK;
  28. }
  29. //USES_CONVERSION;
  30. STDMETHODIMP C_dxj_DIDeviceInstanceObject::getProductName( BSTR __RPC_FAR *ret){
  31. *ret=T2BSTR(m_inst.tszProductName);
  32. return S_OK;
  33. }
  34. STDMETHODIMP C_dxj_DIDeviceInstanceObject::getInstanceName( BSTR __RPC_FAR *ret){
  35. *ret=T2BSTR(m_inst.tszInstanceName);
  36. return S_OK;
  37. }
  38. STDMETHODIMP C_dxj_DIDeviceInstanceObject::getUsagePage( short __RPC_FAR *ret)
  39. {
  40. *ret=(short)m_inst.wUsagePage;
  41. return S_OK;
  42. }
  43. STDMETHODIMP C_dxj_DIDeviceInstanceObject::getUsage( short __RPC_FAR *ret)
  44. {
  45. *ret=(short)m_inst.wUsage;
  46. return S_OK;
  47. }
  48. STDMETHODIMP C_dxj_DIDeviceInstanceObject::getDevType( long __RPC_FAR *ret)
  49. {
  50. *ret=(long)m_inst.dwDevType;
  51. return S_OK;
  52. }
  53. C_dxj_DIDeviceInstanceObject::C_dxj_DIDeviceInstanceObject()
  54. {
  55. ZeroMemory(&m_inst,sizeof(DIDEVICEINSTANCE));
  56. }
  57. void C_dxj_DIDeviceInstanceObject::init(DIDEVICEINSTANCE *inst)
  58. {
  59. memcpy(&m_inst,inst,sizeof(DIDEVICEINSTANCE));
  60. }
  61. HRESULT C_dxj_DIDeviceInstanceObject::create(DIDEVICEINSTANCE *inst,I_dxj_DirectInputDeviceInstance **ret)
  62. {
  63. HRESULT hr;
  64. if (!ret) return E_INVALIDARG;
  65. C_dxj_DIDeviceInstanceObject *c=NULL;
  66. c=new CComObject<C_dxj_DIDeviceInstanceObject>;
  67. c->init(inst);
  68. if( c == NULL ) return E_FAIL;
  69. hr=c->QueryInterface(IID_I_dxj_DirectInputDeviceInstance, (void**)ret);
  70. return hr;
  71. }