#pragma region CPL License /* Nuclex Engine Copyright (C) 2002-2008 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion #ifndef NUCLEX_PLUGINS_DIRECTINPUT8_DIRECTINPUT8PLUGIN_H #define NUCLEX_PLUGINS_DIRECTINPUT8_DIRECTINPUT8PLUGIN_H #include "Nuclex/Nuclex.h" #ifndef NUCLEX_WIN32 #error This plugin only works on the win32 platform #endif #include "Nuclex/Video/Surface.h" #include "Nuclex/Support/Exception.h" #include "Nuclex/Support/String.h" #include "Nuclex/Input/InputDevice.h" // #include "MemoryTracker/DisableMemoryTracker.h" #include #define DIRECTINPUT_VERSION 0x0800 #include #include // #include "MemoryTracker/MemoryTracker.h" // The following block will decide whether symbols are imported from a // dll (client app) or exported to a dll (nuclex library). // The DIRECTINPUT8PLUGIN_EXPORTS symbol should only be used for compiling // the Nuclex.Plugins.DirectInput8 library and nowhere else. // #ifdef DIRECTINPUT8PLUGIN_EXPORTS #define DIRECTINPUT8PLUGIN_API __declspec(dllexport) #else #define DIRECTINPUT8PLUGIN_API __declspec(dllimport) #endif _COM_SMARTPTR_TYPEDEF(IDirectInputDevice8, IID_IDirectInputDevice8); namespace Nuclex { namespace Input { // ------------------------------------------------------------------------------------------- // /// Returns the global DirectInput8 instance /// The global DirectInput8 instance DIRECTINPUT8PLUGIN_API IDirectInput8 *getDirectInput8(); // ------------------------------------------------------------------------------------------- // /// Checks the return values of Direct3D API methods /// Source of the call /// Method being called /// Method result code static inline void DInputCheck( const char *pszSource, const char *pszMethod, const HRESULT hResult ) { if(FAILED(hResult)) { throw UnexpectedException( pszSource, string("Unexpected failure in ") + pszMethod + ": " + DXGetErrorString9A(hResult) ); } } // ------------------------------------------------------------------------------------------- // /// Converts a direct input device type into a nuclex device type /// Device type to convert /// The nuclex device type static inline InputDevice::Type InputDeviceTypeFromDInputDevType(DWORD dwDevType) { switch(dwDevType) { case DI8DEVTYPE_DRIVING: return InputDevice::T_WHEEL; case DI8DEVTYPE_GAMEPAD: return InputDevice::T_GAMEPAD; case DI8DEVTYPE_JOYSTICK: return InputDevice::T_JOYSTICK; case DI8DEVTYPE_KEYBOARD: return InputDevice::T_KEYBOARD; case DI8DEVTYPE_MOUSE: return InputDevice::T_MOUSE; default: return InputDevice::T_UNKNOWN; } } // ------------------------------------------------------------------------------------------- // }} // namespace Nuclex::Input #endif // NUCLEX_PLUGINS_DIRECTINPUT8_DIRECTINPUT8PLUGIN_H