+++ /dev/null
-#include "stdafx.h"\r
-/*\r
-* Copyright (c) 2007-2010 SlimDX Group\r
-* \r
-* Permission is hereby granted, free of charge, to any person obtaining a copy\r
-* of this software and associated documentation files (the "Software"), to deal\r
-* in the Software without restriction, including without limitation the rights\r
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
-* copies of the Software, and to permit persons to whom the Software is\r
-* furnished to do so, subject to the following conditions:\r
-* \r
-* The above copyright notice and this permission notice shall be included in\r
-* all copies or substantial portions of the Software.\r
-* \r
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
-* THE SOFTWARE.\r
-*/ \r
-#include <windows.h>\r
-#include <dinput.h>\r
-#include <vcclr.h>\r
-\r
-#include "../ComObject.h"\r
-#include "../SlimDXException.h"\r
-#include "../InternalHelpers.h"\r
-#include "../CollectionShim.h"\r
-\r
-#include "DirectInput.h"\r
-#include "DirectInputException.h"\r
-#include "DirectInputNotFoundException.h"\r
-\r
-#include "CallbacksDI.h"\r
-#include "DeviceDI.h"\r
-\r
-using namespace System;\r
-using namespace System::Collections::Generic;\r
-using namespace System::Runtime::InteropServices;\r
-\r
-namespace SlimDX\r
-{\r
-namespace DirectInput\r
-{\r
- DirectInput::DirectInput()\r
- {\r
- IDirectInput8W* dinput;\r
- IntPtr hInstance = Marshal::GetHINSTANCE( DirectInput::typeid->Module );\r
-\r
- try\r
- {\r
- HRESULT hr = DirectInput8Create( static_cast<HINSTANCE>( hInstance.ToPointer() ), DIRECTINPUT_VERSION, \r
- IID_IDirectInput8, reinterpret_cast<void**>( &dinput ), NULL );\r
-\r
- RECORD_DINPUT( hr );\r
- }\r
- catch( SEHException^ ex )\r
- {\r
- throw gcnew DirectInputNotFoundException( "DirectInput was not found. Reinstalling DirectX may fix the problem.", ex );\r
- }\r
-\r
- if( dinput == NULL )\r
- throw gcnew DirectInputException( "Could not create DirectInput instance." );\r
-\r
- Construct( dinput );\r
- }\r
-\r
- Result DirectInput::RunControlPanel()\r
- {\r
- HRESULT hr = InternalPointer->RunControlPanel( NULL, 0 );\r
- return RECORD_DINPUT( hr );\r
- }\r
-\r
- Result DirectInput::RunControlPanel( IntPtr parent )\r
- {\r
- HRESULT hr = InternalPointer->RunControlPanel( static_cast<HWND>( parent.ToPointer() ), 0 );\r
- return RECORD_DINPUT( hr );\r
- }\r
-\r
- bool DirectInput::IsDeviceAttached( Guid device )\r
- {\r
- HRESULT hr = InternalPointer->GetDeviceStatus( Utilities::ConvertManagedGuid( device ) );\r
- RECORD_DINPUT( hr );\r
-\r
- return hr == DI_OK;\r
- }\r
-\r
- Guid DirectInput::FindDevice( Guid deviceClass, String^ name )\r
- {\r
- GUID result;\r
- pin_ptr<const wchar_t> pinnedName = PtrToStringChars( name );\r
-\r
- HRESULT hr = InternalPointer->FindDevice( Utilities::ConvertManagedGuid( deviceClass ),\r
- reinterpret_cast<LPCTSTR>( pinnedName ), &result );\r
- RECORD_DINPUT( hr );\r
-\r
- if( FAILED( hr ) )\r
- return Guid::Empty;\r
-\r
- return Utilities::ConvertNativeGuid( result );\r
- }\r
-\r
- IList<DeviceInstance^>^ DirectInput::GetDevices()\r
- {\r
- return GetDevices( DeviceClass::All, DeviceEnumerationFlags::AllDevices );\r
- }\r
-\r
- IList<DeviceInstance^>^ DirectInput::GetDevices( DeviceClass deviceClass, DeviceEnumerationFlags enumerationFlags )\r
- {\r
- List<DeviceInstance^>^ results = gcnew List<DeviceInstance^>();\r
- CollectionShim<DeviceInstance^> shim( results );\r
-\r
- HRESULT hr = InternalPointer->EnumDevices( static_cast<DWORD>( deviceClass ), static_cast<LPDIENUMDEVICESCALLBACK>( EnumerateDevices ), &shim, static_cast<DWORD>( enumerationFlags ) );\r
- if( RECORD_DINPUT( hr ).IsFailure )\r
- return nullptr;\r
-\r
- return results;\r
- }\r
-\r
- IList<DeviceInstance^>^ DirectInput::GetDevices( DeviceType deviceType, DeviceEnumerationFlags enumerationFlags )\r
- {\r
- List<DeviceInstance^>^ results = gcnew List<DeviceInstance^>();\r
- CollectionShim<DeviceInstance^> shim( results );\r
-\r
- HRESULT hr = InternalPointer->EnumDevices( static_cast<DWORD>( deviceType ), static_cast<LPDIENUMDEVICESCALLBACK>( EnumerateDevices ), &shim, static_cast<DWORD>( enumerationFlags ) );\r
- if( RECORD_DINPUT( hr ).IsFailure )\r
- return nullptr;\r
-\r
- return results;\r
- }\r
-}\r
-}
\ No newline at end of file