mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementa Mouse::WindowHandle
This commit is contained in:
parent
e6e0312f9d
commit
fd2624f24e
@ -81,8 +81,8 @@ namespace xna {
|
||||
}
|
||||
|
||||
void Game::Initialize() {
|
||||
Keyboard::Initialize();
|
||||
Mouse::Initialize();
|
||||
Keyboard::Initialize();
|
||||
Mouse::Initialize(_gameWindow->Handle());
|
||||
GamePad::Initialize();
|
||||
AudioEngine::Initialize();
|
||||
|
||||
|
@ -2,9 +2,6 @@
|
||||
|
||||
namespace xna {
|
||||
MouseState Mouse::GetState() {
|
||||
if (!impl || !impl->_dxMouse)
|
||||
return MouseState();
|
||||
|
||||
const auto state = impl->_dxMouse->GetState();
|
||||
MouseState mstate;
|
||||
mstate.LeftButton = static_cast<ButtonState>(state.leftButton);
|
||||
@ -19,35 +16,32 @@ namespace xna {
|
||||
return mstate;
|
||||
}
|
||||
|
||||
bool Mouse::IsConnected() {
|
||||
if (!impl || !impl->_dxMouse)
|
||||
return false;
|
||||
|
||||
bool Mouse::IsConnected() {
|
||||
return impl->_dxMouse->IsConnected();
|
||||
}
|
||||
|
||||
bool Mouse::IsVisible() {
|
||||
if (!impl || !impl->_dxMouse)
|
||||
return false;
|
||||
|
||||
return impl->_dxMouse->IsVisible();
|
||||
}
|
||||
|
||||
void Mouse::IsVisible(bool value) {
|
||||
if (!impl || !impl->_dxMouse)
|
||||
return;
|
||||
|
||||
impl->_dxMouse->SetVisible(value);
|
||||
}
|
||||
|
||||
void Mouse::ResetScrollWheel() {
|
||||
if (!impl || !impl->_dxMouse)
|
||||
return;
|
||||
|
||||
impl->_dxMouse->ResetScrollWheelValue();
|
||||
}
|
||||
|
||||
void Mouse::Initialize() {
|
||||
void Mouse::Initialize(intptr_t handle) {
|
||||
impl = unew<PlatformImplementation>();
|
||||
windowHandle = handle;
|
||||
}
|
||||
|
||||
void Mouse::WindowHandle(intptr_t value) {
|
||||
auto hwnd = reinterpret_cast<HWND>(value);
|
||||
|
||||
if (!hwnd) return;
|
||||
|
||||
impl->_dxMouse->SetWindow(hwnd);
|
||||
}
|
||||
}
|
@ -4,15 +4,24 @@
|
||||
#include "../default.hpp"
|
||||
|
||||
namespace xna {
|
||||
//Represents the state of a mouse input device, including mouse cursor position and buttons pressed.
|
||||
struct MouseState {
|
||||
//Returns the state of the left mouse button.
|
||||
ButtonState LeftButton{ ButtonState::Released };
|
||||
ButtonState RightButton{ ButtonState::Released };
|
||||
//Returns the state of the middle mouse button.
|
||||
ButtonState MiddleButton{ ButtonState::Released };
|
||||
ButtonState XButton1{ ButtonState::Released };
|
||||
ButtonState XButton2{ ButtonState::Released };
|
||||
int X{ 0 };
|
||||
int Y{ 0 };
|
||||
//Returns the state of the right mouse button.
|
||||
ButtonState RightButton{ ButtonState::Released };
|
||||
//Gets the cumulative mouse scroll wheel value since the game was started.
|
||||
int ScroolWheelValue{ 0 };
|
||||
//Specifies the horizontal position of the mouse cursor.
|
||||
int X{ 0 };
|
||||
//Returns the state of XBUTTON1.
|
||||
ButtonState XButton1{ ButtonState::Released };
|
||||
//Returns the state of XBUTTON2.
|
||||
ButtonState XButton2{ ButtonState::Released };
|
||||
//Specifies the vertical position of the mouse cursor.
|
||||
int Y{ 0 };
|
||||
};
|
||||
|
||||
//Allows retrieval of position and button clicks from a mouse input device.
|
||||
@ -21,6 +30,16 @@ namespace xna {
|
||||
//Gets the current state of the mouse, including mouse position and buttons pressed.
|
||||
static MouseState GetState();
|
||||
|
||||
//Gets or sets the window used for mouse processing.
|
||||
//Mouse coordinates returned by GetState are relative to the upper-left corner of this window.
|
||||
constexpr static intptr_t WindowHandle() {
|
||||
return windowHandle;
|
||||
}
|
||||
|
||||
//Gets or sets the window used for mouse processing.
|
||||
//Mouse coordinates returned by GetState are relative to the upper-left corner of this window.
|
||||
static void WindowHandle(intptr_t value);
|
||||
|
||||
static bool IsConnected();
|
||||
static bool IsVisible();
|
||||
static void IsVisible(bool value);
|
||||
@ -28,12 +47,14 @@ namespace xna {
|
||||
|
||||
private:
|
||||
friend class Game;
|
||||
static void Initialize();
|
||||
static void Initialize(intptr_t windowHandle);
|
||||
|
||||
Mouse() = default;
|
||||
Mouse(Mouse&) = default;
|
||||
Mouse(Mouse&&) = default;
|
||||
|
||||
inline static intptr_t windowHandle = 0;
|
||||
|
||||
public:
|
||||
struct PlatformImplementation;
|
||||
inline static uptr<PlatformImplementation> impl = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user