#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_DEVICES_WINRTMOUSE_H
#define NUCLEX_INPUT_DEVICES_WINRTMOUSE_H
#include "../Buffered/BufferedMouse.h"
namespace Nuclex { namespace Input { namespace Devices {
// ------------------------------------------------------------------------------------------- //
/// Mouse that captures input from a WinRT CoreWindow
class WinRTMouse : public BufferedMouse {
/// Initializes a new WinRT-based keyboard
public: WinRTMouse() {}
/// Destroys the mouse
public: virtual ~WinRTMouse() {}
/// Whether the input device is currently attached
/// True if the input device is attached, otherwise false
public: bool IsAttached() const { return true; }
/// Retrieves the human-readable name of the input device
/// The human-readable name of the input device
public: const std::string &GetName() const {
static std::string name("WinRT/Metro mouse translator");
return name;
}
/// Locks the mouse cursor to the window for FPS control
/// Whether to lock the mouse cursor to the window
public: void SetLocked(bool locked = true);
/// Whether the mouse cursor is currently locked to the window
/// True if the mouse cursor is locked to the window, otherwise false
public: bool IsLocked() const;
/// Called when a mouse button is pressed down
/// Window that registered the mouse button press
/// Contains the pressed mouse button
public: void InjectButtonPress(
Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs ^arguments
);
/// Called when a mouse button has been released
/// Window that registered the mouse button release
/// Contains the released mouse button
public: void InjectButtonRelease(
Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs ^arguments
);
/// Called when the mouse cursor has been moved to a new location
/// Window that registered the mouse cursor movement
/// Contains the new mouse cursor location
public: void InjectCursorMovement(
Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs ^arguments
);
/// Called when the mouse wheel has been rotated
/// Window that registered the mouse wheel rotation
/// Contains the amount of mouse wheel rotation
public: void InjectWheelRotation(
Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs ^arguments
);
///
/// Adds a cursor movement to the buffer mouse if the cursor's position differs from
/// the last position recorded
///
/// Contains the current pointer position
private: void bufferCursorMovementIfPositionChanged(
Windows::UI::Core::PointerEventArgs ^arguments
);
/// X coordinate of the mouse cursor
private: int cursorX;
/// Y coordinate of the mouse cursor
private: int cursorY;
/// Whether the left mouse button is currently pressed
private: bool leftButtonPressed;
/// Whether the middle mouse button is currently pressed
private: bool middleButtonPressed;
/// Whether the right mouse button is currently pressed
private: bool rightButtonPressed;
};
// ------------------------------------------------------------------------------------------- //
}}} // namespace Nuclex::Input::Devices
#endif // NUCLEX_INPUT_DEVICES_WINRTMOUSE_H