#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_WINRT) #include "WinRTInputManager.Impl.h" using namespace Windows::UI::Core; using namespace Windows::Foundation; namespace { // ------------------------------------------------------------------------------------------- // /// Determines if the specified device is a mouse /// Device that will be checked for being a mouse /// True if the specified device is a mouse bool isMouse(Windows::Devices::Input::PointerDevice ^device) { return (device->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Mouse); } // ------------------------------------------------------------------------------------------- // } // anonymous namespace namespace Nuclex { namespace Input { // ------------------------------------------------------------------------------------------- // WinRTInputManager::Impl::Impl(Windows::UI::Core::CoreWindow ^window) : window(window) { subscribeWindowEvents(); } // ------------------------------------------------------------------------------------------- // WinRTInputManager::Impl::~Impl() { this->window->PointerWheelChanged -= this->pointerWheelChangedEventToken; window->PointerMoved -= this->pointerMovedEventToken; window->PointerReleased -= this->pointerReleasedEventToken; window->PointerPressed -= this->pointerPressedEventToken; window->CharacterReceived -= this->characterReceivedEventToken; window->KeyUp -= this->keyUpEventToken; window->KeyDown -= this->keyDownEventToken; } // ------------------------------------------------------------------------------------------- // void WinRTInputManager::Impl::pointerPressed( Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs ^arguments ) { if(isMouse(arguments->CurrentPoint->PointerDevice)) { this->Mouse.InjectButtonPress(sender, arguments); } else { // TODO: Route to touch panel } } // ------------------------------------------------------------------------------------------- // void WinRTInputManager::Impl::pointerReleased( Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs ^arguments ) { if(isMouse(arguments->CurrentPoint->PointerDevice)) { this->Mouse.InjectButtonPress(sender, arguments); } else { // TODO: Route to touch panel } } // ------------------------------------------------------------------------------------------- // void WinRTInputManager::Impl::pointerMoved( Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs ^arguments ) { if(isMouse(arguments->CurrentPoint->PointerDevice)) { this->Mouse.InjectCursorMovement(sender, arguments); } else { // TODO: Reoute to touch panel } } // ------------------------------------------------------------------------------------------- // void WinRTInputManager::Impl::pointerWheelChanged( Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs ^arguments ) { if(isMouse(arguments->CurrentPoint->PointerDevice)) { this->Mouse.InjectWheelRotation(sender, arguments); } else { // TODO: Reoute to touch panel } } // ------------------------------------------------------------------------------------------- // void WinRTInputManager::Impl::subscribeWindowEvents() { this->keyDownEventToken = ( this->window->KeyDown += ref new TypedEventHandler( this, &Impl::keyDown ) ); this->keyUpEventToken = ( this->window->KeyUp += ref new TypedEventHandler( this, &Impl::keyUp ) ); this->characterReceivedEventToken = ( this->window->CharacterReceived += ref new TypedEventHandler< CoreWindow ^, CharacterReceivedEventArgs ^ >(this, &Impl::characterReceived) ); this->pointerPressedEventToken = ( this->window->PointerPressed += ref new TypedEventHandler< CoreWindow ^, PointerEventArgs ^ >(this, &Impl::pointerPressed) ); this->pointerReleasedEventToken = ( this->window->PointerReleased += ref new TypedEventHandler< CoreWindow ^, PointerEventArgs ^ >(this, &Impl::pointerReleased) ); this->pointerMovedEventToken = ( this->window->PointerMoved += ref new TypedEventHandler< CoreWindow ^, PointerEventArgs ^ >(this, &Impl::pointerMoved) ); this->pointerWheelChangedEventToken = ( this->window->PointerWheelChanged += ref new TypedEventHandler< CoreWindow ^, PointerEventArgs ^ >(this, &Impl::pointerWheelChanged) ); } // ------------------------------------------------------------------------------------------- // }} // namespace Nuclex::Input #endif // defined(NUCLEX_INPUT_WINRT)