#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 // If the library is compiled as a DLL, this ensures symbols are exported #define NUCLEX_INPUT_SOURCE 1 #include "Nuclex/Input/Config.h" #if defined(NUCLEX_INPUT_WIN32) #include "Nuclex/Input/WindowsInputManager.h" #include "Windows/WindowsInputManager.Impl.h" namespace Nuclex { namespace Input { // ------------------------------------------------------------------------------------------- // WindowsInputManager::WindowsInputManager( HWND windowHandle, HINSTANCE instanceHandle /* = nullptr */ ) : impl(nullptr) { this->impl = new Impl(windowHandle, instanceHandle); //std::vector deviceInstances = impl->EnumerateDirectInputGamePads(); } // ------------------------------------------------------------------------------------------- // WindowsInputManager::~WindowsInputManager() { delete this->impl; } // ------------------------------------------------------------------------------------------- // std::size_t WindowsInputManager::CountKeyboards() const { return 1; } // ------------------------------------------------------------------------------------------- // const Devices::Keyboard &WindowsInputManager::GetKeyboard(std::size_t index) const { if(index == 0) { return this->impl->Keyboard; } else { throw std::out_of_range("Keyboard index out of range"); } } // ------------------------------------------------------------------------------------------- // Devices::Keyboard &WindowsInputManager::GetKeyboard(std::size_t index) { if(index == 0) { return this->impl->Keyboard; } else { throw std::out_of_range("Keyboard index out of range"); } } // ------------------------------------------------------------------------------------------- // std::size_t WindowsInputManager::CountMice() const { return 1; } // ------------------------------------------------------------------------------------------- // const Devices::Mouse &WindowsInputManager::GetMouse(std::size_t index) const { if(index == 0) { return this->impl->Mouse; } else { throw std::out_of_range("Mouse index out of range"); } } // ------------------------------------------------------------------------------------------- // Devices::Mouse &WindowsInputManager::GetMouse(std::size_t index) { if(index == 0) { return this->impl->Mouse; } else { throw std::out_of_range("Mouse index out of range"); } } // ------------------------------------------------------------------------------------------- // std::size_t WindowsInputManager::CountGamePads() const { return this->impl->GamePads.size() + this->impl->VirtualGamePads.size(); } // ------------------------------------------------------------------------------------------- // const Devices::GamePad &WindowsInputManager::GetGamePad(std::size_t index) const { std::size_t xInputGamePadCount = this->impl->GamePads.size(); if(index >= xInputGamePadCount) { return *this->impl->VirtualGamePads.at(index - xInputGamePadCount); } else { return *this->impl->GamePads[index]; } } // ------------------------------------------------------------------------------------------- // Devices::GamePad &WindowsInputManager::GetGamePad(std::size_t index) { std::size_t xInputGamePadCount = this->impl->GamePads.size(); if(index >= xInputGamePadCount) { return *this->impl->VirtualGamePads.at(index - xInputGamePadCount); } else { return *this->impl->GamePads[index]; } } // ------------------------------------------------------------------------------------------- // std::size_t WindowsInputManager::CountTouchPanels() const { return this->impl->TouchPanels.size(); } // ------------------------------------------------------------------------------------------- // const Devices::TouchPanel &WindowsInputManager::GetTouchPanel(std::size_t index) const { return *this->impl->TouchPanels.at(index); } // ------------------------------------------------------------------------------------------- // Devices::TouchPanel &WindowsInputManager::GetTouchPanel(std::size_t index) { return *this->impl->TouchPanels.at(index); } // ------------------------------------------------------------------------------------------- // }} // namespace Nuclex::Input #endif // defined(NUCLEX_INPUT_WIN32)