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.

106 lines
2.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: dinput1obj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // dDrawColorControlObj.cpp : Implementation of CDirectApp and DLL registration.
  11. // DHF_DS entire file
  12. #include "stdafx.h"
  13. #include "Direct.h"
  14. #include "dms.h"
  15. #include "dInput1Obj.h"
  16. #include "dInputDeviceObj.h"
  17. #include "dinput.h"
  18. #include "DIEnumDevicesObj.h"
  19. extern HRESULT BSTRtoGUID(LPGUID,BSTR);
  20. extern HRESULT DINPUTBSTRtoGUID(LPGUID,BSTR);
  21. CONSTRUCTOR(_dxj_DirectInput, {});
  22. DESTRUCTOR(_dxj_DirectInput, {});
  23. GETSET_OBJECT(_dxj_DirectInput);
  24. STDMETHODIMP C_dxj_DirectInputObject::createDevice(BSTR strGuid, I_dxj_DirectInputDevice **dev)
  25. {
  26. HRESULT hr = DD_OK;
  27. GUID rguid;
  28. LPDIRECTINPUTDEVICE realdevice1=NULL;
  29. LPDIRECTINPUTDEVICE2 realdevice=NULL;
  30. hr = DINPUTBSTRtoGUID(&rguid,strGuid);
  31. if FAILED(hr) return hr;
  32. hr=m__dxj_DirectInput->CreateDevice(rguid,&realdevice1,NULL);
  33. if FAILED(hr) return hr;
  34. hr=realdevice1->QueryInterface(IID_IDirectInputDevice2,(void**)&realdevice);
  35. realdevice1->Release();
  36. if FAILED(hr) return hr;
  37. INTERNAL_CREATE(_dxj_DirectInputDevice,realdevice,dev);
  38. if (*dev==NULL) {
  39. realdevice->Release();
  40. return E_OUTOFMEMORY;
  41. }
  42. if (0==_wcsicmp(strGuid,L"guid_syskeyboard")){
  43. hr=realdevice->SetDataFormat(&c_dfDIKeyboard);
  44. }
  45. else if (0==_wcsicmp(strGuid,L"guid_sysmouse")){
  46. hr=realdevice->SetDataFormat(&c_dfDIMouse);
  47. }
  48. else {
  49. hr=realdevice->SetDataFormat(&c_dfDIJoystick2);
  50. }
  51. return hr;
  52. }
  53. STDMETHODIMP C_dxj_DirectInputObject::runControlPanel( long hwndOwner )
  54. {
  55. HRESULT hr;
  56. hr = m__dxj_DirectInput->RunControlPanel((HWND)hwndOwner, (DWORD)0);
  57. return hr;
  58. }
  59. STDMETHODIMP C_dxj_DirectInputObject::getDeviceStatus( BSTR strGuid, VARIANT_BOOL *status){
  60. HRESULT hr;
  61. GUID g;
  62. hr = DINPUTBSTRtoGUID(&g,strGuid);
  63. if FAILED(hr) return hr;
  64. if (!status) return E_INVALIDARG;
  65. hr = m__dxj_DirectInput->GetDeviceStatus((REFGUID)g);
  66. if (hr==DI_OK)
  67. *status=VARIANT_TRUE;
  68. else
  69. *status=VARIANT_FALSE;
  70. return S_OK;
  71. }
  72. STDMETHODIMP C_dxj_DirectInputObject::getDIEnumDevices(
  73. long deviceType, long flags, I_dxj_DIEnumDevices **ppRet)
  74. {
  75. HRESULT hr;
  76. hr = C_dxj_DIEnumDevicesObject::create(m__dxj_DirectInput,deviceType,flags,ppRet);
  77. return hr;
  78. }