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
@ -82,7 +82,7 @@ namespace xna {
|
|||||||
|
|
||||||
void Game::Initialize() {
|
void Game::Initialize() {
|
||||||
Keyboard::Initialize();
|
Keyboard::Initialize();
|
||||||
Mouse::Initialize();
|
Mouse::Initialize(_gameWindow->Handle());
|
||||||
GamePad::Initialize();
|
GamePad::Initialize();
|
||||||
AudioEngine::Initialize();
|
AudioEngine::Initialize();
|
||||||
|
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
MouseState Mouse::GetState() {
|
MouseState Mouse::GetState() {
|
||||||
if (!impl || !impl->_dxMouse)
|
|
||||||
return MouseState();
|
|
||||||
|
|
||||||
const auto state = impl->_dxMouse->GetState();
|
const auto state = impl->_dxMouse->GetState();
|
||||||
MouseState mstate;
|
MouseState mstate;
|
||||||
mstate.LeftButton = static_cast<ButtonState>(state.leftButton);
|
mstate.LeftButton = static_cast<ButtonState>(state.leftButton);
|
||||||
@ -20,34 +17,31 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Mouse::IsConnected() {
|
bool Mouse::IsConnected() {
|
||||||
if (!impl || !impl->_dxMouse)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return impl->_dxMouse->IsConnected();
|
return impl->_dxMouse->IsConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mouse::IsVisible() {
|
bool Mouse::IsVisible() {
|
||||||
if (!impl || !impl->_dxMouse)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return impl->_dxMouse->IsVisible();
|
return impl->_dxMouse->IsVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mouse::IsVisible(bool value) {
|
void Mouse::IsVisible(bool value) {
|
||||||
if (!impl || !impl->_dxMouse)
|
|
||||||
return;
|
|
||||||
|
|
||||||
impl->_dxMouse->SetVisible(value);
|
impl->_dxMouse->SetVisible(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mouse::ResetScrollWheel() {
|
void Mouse::ResetScrollWheel() {
|
||||||
if (!impl || !impl->_dxMouse)
|
|
||||||
return;
|
|
||||||
|
|
||||||
impl->_dxMouse->ResetScrollWheelValue();
|
impl->_dxMouse->ResetScrollWheelValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mouse::Initialize() {
|
void Mouse::Initialize(intptr_t handle) {
|
||||||
impl = unew<PlatformImplementation>();
|
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"
|
#include "../default.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
//Represents the state of a mouse input device, including mouse cursor position and buttons pressed.
|
||||||
struct MouseState {
|
struct MouseState {
|
||||||
|
//Returns the state of the left mouse button.
|
||||||
ButtonState LeftButton{ ButtonState::Released };
|
ButtonState LeftButton{ ButtonState::Released };
|
||||||
ButtonState RightButton{ ButtonState::Released };
|
//Returns the state of the middle mouse button.
|
||||||
ButtonState MiddleButton{ ButtonState::Released };
|
ButtonState MiddleButton{ ButtonState::Released };
|
||||||
ButtonState XButton1{ ButtonState::Released };
|
//Returns the state of the right mouse button.
|
||||||
ButtonState XButton2{ ButtonState::Released };
|
ButtonState RightButton{ ButtonState::Released };
|
||||||
int X{ 0 };
|
//Gets the cumulative mouse scroll wheel value since the game was started.
|
||||||
int Y{ 0 };
|
|
||||||
int ScroolWheelValue{ 0 };
|
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.
|
//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.
|
//Gets the current state of the mouse, including mouse position and buttons pressed.
|
||||||
static MouseState GetState();
|
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 IsConnected();
|
||||||
static bool IsVisible();
|
static bool IsVisible();
|
||||||
static void IsVisible(bool value);
|
static void IsVisible(bool value);
|
||||||
@ -28,12 +47,14 @@ namespace xna {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Game;
|
friend class Game;
|
||||||
static void Initialize();
|
static void Initialize(intptr_t windowHandle);
|
||||||
|
|
||||||
Mouse() = default;
|
Mouse() = default;
|
||||||
Mouse(Mouse&) = default;
|
Mouse(Mouse&) = default;
|
||||||
Mouse(Mouse&&) = default;
|
Mouse(Mouse&&) = default;
|
||||||
|
|
||||||
|
inline static intptr_t windowHandle = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct PlatformImplementation;
|
struct PlatformImplementation;
|
||||||
inline static uptr<PlatformImplementation> impl = nullptr;
|
inline static uptr<PlatformImplementation> impl = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user