#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2013 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 // CPL License #ifndef NUCLEX_INPUT_WINDOWS_WINDOWSINPUTMANAGER_IMPL_H #define NUCLEX_INPUT_WINDOWS_WINDOWSINPUTMANAGER_IMPL_H #include "Nuclex/Input/WindowsInputManager.h" #include "../Devices/Windows/WindowMessageKeyboard.h" #include "../Devices/Windows/WindowMessageMouse.h" #include "../Devices/Virtuals/VirtualGamePad.h" #include #define DIRECTINPUT_VERSION 0x800 #include #include // --------------------------------------------------------------------------------------------- // /// Smart pointer for the main DirectInput8 interface _COM_SMARTPTR_TYPEDEF(IDirectInput8, IID_IDirectInput8); // --------------------------------------------------------------------------------------------- // namespace Nuclex { namespace Input { // ------------------------------------------------------------------------------------------- // /// A vector of game pads typedef std::vector GamePadVector; /// A vector of virtual game pads typedef std::vector VirtualGamePadVector; /// A vector of touch panels typedef std::vector TouchPanelVector; // ------------------------------------------------------------------------------------------- // /// Structure containing private implementation details /// /// This hides stuff like the DirectInput COM object and various internal fields. /// By hiding these things, you don't even need to have the DirectX SDK on your /// system since the library doesn't include dinput.h in its public headers /// (and the private headers are tucked away in the compiled library). /// struct WindowsInputManager::Impl { /// /// Initializes the window input manager's private implementation details /// /// Handle of the window that will be subclassed /// Handle of the executing process public: Impl(HWND windowHandle, HINSTANCE instanceHandle); /// Destroys the private implementation details public: ~Impl(); /// Determines whether DirectInput is available on the system /// True if DirectInput is available, false otherwise public: bool IsDirectInputAvailable() const { return this->directInput != nullptr; } /// Enumerates all connected DirectInput game controllers /// DirectInput device informations for all connected game controllers public: std::vector EnumerateDirectInputGamePads() const; /// Attempts to initialize DirectInput, if available on the system private: void tryInitializeDirectInput(); /// Subclasses the game's window to listen in on Window messages private: void subclassWindow(); /// Unsubclasses the game's window again private: void unsubclassWindow(); /// Message procedure used to intercept messages to the game's window /// Handle of the window received the message /// Type of message being sent to the window /// First message-dependent parameter /// Second message-dependent parameter private: static LRESULT CALLBACK windowProcedure( HWND windowHandle, UINT message, WPARAM parameter1, LPARAM parameter2 ); /// All keyboards the user can query for public: Devices::WindowMessageKeyboard Keyboard; /// All mice the user can query for public: Devices::WindowMessageMouse Mouse; /// XINPUT game pads the user can query for public: GamePadVector GamePads; /// DirectInput game pads the user can query for public: VirtualGamePadVector VirtualGamePads; /// All touch panels the user can query for public: TouchPanelVector TouchPanels; /// Handle of the window through which input is being captured private: HWND windowHandle; /// Handle of the process the library is executing in private: HINSTANCE instanceHandle; /// The subclassed window's old window message procedure private: WNDPROC oldWindowProc; /// Stores informations used to track a mouse event private: TRACKMOUSEEVENT mouseEventTrackData; /// Main direct input instance private: IDirectInput8Ptr directInput; }; // ------------------------------------------------------------------------------------------- // }} // namespace Nuclex::Input #endif // NUCLEX_INPUT_WINDOWS_WINDOWSINPUTMANAGER_IMPL_H