mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Comentários em Input
This commit is contained in:
parent
2b3f686d19
commit
dd43ea7dbc
@ -3,8 +3,7 @@
|
||||
|
||||
namespace xna {
|
||||
void GamePad::Initialize() {
|
||||
impl = unew<PlatformImplementation>();
|
||||
impl->_dxGamePad = unew<DirectX::GamePad>();
|
||||
impl = unew<PlatformImplementation>();
|
||||
}
|
||||
|
||||
GamePadState GamePad::GetState(PlayerIndex index) {
|
||||
|
@ -15,7 +15,6 @@ namespace xna {
|
||||
|
||||
void Keyboard::Initialize() {
|
||||
impl = unew<PlatformImplementation>();
|
||||
impl->_dxKeyboard = unew<DirectX::Keyboard>();
|
||||
}
|
||||
|
||||
bool Keyboard::IsConnected() {
|
||||
|
@ -50,6 +50,5 @@ namespace xna {
|
||||
|
||||
void Mouse::Initialize() {
|
||||
impl = unew<PlatformImplementation>();
|
||||
impl->_dxMouse = unew<DirectX::Mouse>();
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
#include "../common/numerics.hpp"
|
||||
|
||||
namespace xna {
|
||||
//Structure that defines the position of the left and right triggers on an Xbox Controller.
|
||||
struct GamePadTriggers {
|
||||
constexpr GamePadTriggers() = default;
|
||||
|
||||
@ -37,6 +38,7 @@ namespace xna {
|
||||
}
|
||||
};
|
||||
|
||||
//Structure that represents the position of left and right sticks (thumbsticks) on an Xbox Controller.
|
||||
struct GamePadThumbSticks {
|
||||
constexpr GamePadThumbSticks() = default;
|
||||
|
||||
@ -69,6 +71,7 @@ namespace xna {
|
||||
}
|
||||
};
|
||||
|
||||
//Identifies which directions on the directional pad of an Xbox Controller are being pressed.
|
||||
struct GamePadDPad {
|
||||
constexpr GamePadDPad() = default;
|
||||
|
||||
@ -83,6 +86,7 @@ namespace xna {
|
||||
ButtonState Left{};
|
||||
};
|
||||
|
||||
//Identifies whether buttons on an Xbox Controller are pressed or released.
|
||||
struct GamePadButtons {
|
||||
constexpr GamePadButtons() = default;
|
||||
|
||||
@ -146,6 +150,7 @@ namespace xna {
|
||||
using GamePadId = uint64_t;
|
||||
#endif
|
||||
|
||||
//Describes the capabilities of an Xbox Controller, including controller type, and identifies if the controller supports voice.
|
||||
struct GamePadCapabilities {
|
||||
constexpr GamePadCapabilities() = default;
|
||||
|
||||
@ -156,6 +161,7 @@ namespace xna {
|
||||
GamePadId Id{};
|
||||
};
|
||||
|
||||
//Represents specific information about the state of an Xbox Controller, including the current state of buttons and sticks.
|
||||
struct GamePadState {
|
||||
constexpr GamePadState() = default;
|
||||
|
||||
@ -229,22 +235,30 @@ namespace xna {
|
||||
GamePadTriggers Triggers{};
|
||||
};
|
||||
|
||||
//Allows retrieval of user interaction with an Xbox Controller and setting of controller vibration motors.
|
||||
class GamePad {
|
||||
public:
|
||||
//Gets the current state of a game pad controller. As an option, it specifies a dead zone processing method for the analog sticks.
|
||||
static GamePadState GetState(PlayerIndex index);
|
||||
//Gets the current state of a game pad controller. As an option, it specifies a dead zone processing method for the analog sticks.
|
||||
static GamePadState GetState(PlayerIndex index, GamePadDeadZone deadZone);
|
||||
|
||||
//Retrieves the capabilities of an Xbox 360 Controller.
|
||||
static GamePadCapabilities GetCapabilities(PlayerIndex index);
|
||||
//Sets the vibration motor speeds on an Xbox 360 Controller.
|
||||
static bool SetVibration(PlayerIndex index, float leftMotor, float rightMotor, float leftTrigger = 0, float rightTrigger = 0);
|
||||
|
||||
GamePad() = delete;
|
||||
GamePad(GamePad&) = delete;
|
||||
GamePad(GamePad&&) = delete;
|
||||
|
||||
private:
|
||||
friend class Game;
|
||||
static void Initialize();
|
||||
|
||||
public:
|
||||
struct PlatformImplementation;
|
||||
inline static uptr<PlatformImplementation> impl = nullptr;
|
||||
|
||||
private:
|
||||
GamePad();
|
||||
GamePad(GamePad&&);
|
||||
GamePad(GamePad&);
|
||||
inline static uptr<PlatformImplementation> impl = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,13 @@
|
||||
#include "../default.hpp"
|
||||
|
||||
namespace xna {
|
||||
//Represents a state of keystrokes recorded by a keyboard input device.
|
||||
struct KeyboardState {
|
||||
//
|
||||
//same implementation of the DirectX::Keyboard::State structure
|
||||
//
|
||||
public:
|
||||
bool IsKeyDown(Keys key) const {
|
||||
constexpr bool IsKeyDown(Keys key) const {
|
||||
const auto k = static_cast<unsigned char>(key);
|
||||
|
||||
if (k <= 0xfe)
|
||||
@ -18,7 +22,7 @@ namespace xna {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsKeyUp(Keys key) const {
|
||||
constexpr bool IsKeyUp(Keys key) const {
|
||||
return !IsKeyDown(key);
|
||||
}
|
||||
|
||||
@ -210,13 +214,21 @@ namespace xna {
|
||||
bool Reserved26 : 1;
|
||||
};
|
||||
|
||||
//Allows retrieval of keystrokes from a keyboard input device.
|
||||
class Keyboard {
|
||||
public:
|
||||
//Returns the current keyboard or Chatpad state.
|
||||
static KeyboardState GetState();
|
||||
//static bool IsConnected();
|
||||
static void Initialize();
|
||||
static bool IsConnected();
|
||||
|
||||
Keyboard() = delete;
|
||||
Keyboard(Keyboard&) = delete;
|
||||
Keyboard(Keyboard&&) = delete;
|
||||
|
||||
private:
|
||||
friend class Game;
|
||||
static void Initialize();
|
||||
|
||||
public:
|
||||
struct PlatformImplementation;
|
||||
inline static uptr<PlatformImplementation> impl = nullptr;
|
||||
|
@ -15,19 +15,28 @@ namespace xna {
|
||||
int ScroolWheelValue{ 0 };
|
||||
};
|
||||
|
||||
//Allows retrieval of position and button clicks from a mouse input device.
|
||||
class Mouse {
|
||||
public:
|
||||
//Gets the current state of the mouse, including mouse position and buttons pressed.
|
||||
static MouseState GetState();
|
||||
|
||||
static bool IsConnected();
|
||||
static bool IsVisible();
|
||||
static void IsVisible(bool value);
|
||||
static void ResetScrollWheel();
|
||||
static void ResetScrollWheel();
|
||||
|
||||
Mouse() = delete;
|
||||
Mouse(Mouse&) = delete;
|
||||
Mouse(Mouse&&) = delete;
|
||||
|
||||
private:
|
||||
friend class Game;
|
||||
static void Initialize();
|
||||
|
||||
public:
|
||||
struct PlatformImplementation;
|
||||
inline static uptr<PlatformImplementation> impl = nullptr;
|
||||
inline static uptr<PlatformImplementation> impl = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,7 @@ using comptr = Microsoft::WRL::ComPtr<T>;
|
||||
// OTHERS INCLUDES
|
||||
//--------------------------------//
|
||||
|
||||
#include "../default.hpp"
|
||||
#include "../exception.hpp"
|
||||
#include "../graphics/blendstate.hpp"
|
||||
#include "../graphics/adapter.hpp"
|
||||
@ -586,14 +587,14 @@ namespace xna {
|
||||
};
|
||||
|
||||
struct GamePad::PlatformImplementation {
|
||||
inline static uptr<DirectX::GamePad> _dxGamePad = nullptr;
|
||||
uptr<DirectX::GamePad> _dxGamePad = unew<DirectX::GamePad>();
|
||||
|
||||
void Suspend() {
|
||||
void Suspend() const {
|
||||
if (_dxGamePad)
|
||||
_dxGamePad->Suspend();
|
||||
}
|
||||
|
||||
void Resume() {
|
||||
void Resume() const {
|
||||
if (_dxGamePad)
|
||||
_dxGamePad->Resume();
|
||||
}
|
||||
@ -611,18 +612,18 @@ namespace xna {
|
||||
};
|
||||
|
||||
struct Keyboard::PlatformImplementation {
|
||||
inline static uptr<DirectX::Keyboard> _dxKeyboard = nullptr;
|
||||
uptr<DirectX::Keyboard> _dxKeyboard = unew<DirectX::Keyboard>();
|
||||
|
||||
void ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam) {
|
||||
void ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam) const {
|
||||
if (_dxKeyboard)
|
||||
_dxKeyboard->ProcessMessage(message, wParam, lParam);
|
||||
}
|
||||
};
|
||||
|
||||
struct Mouse::PlatformImplementation {
|
||||
inline static uptr<DirectX::Mouse> _dxMouse = nullptr;
|
||||
uptr<DirectX::Mouse> _dxMouse = unew<DirectX::Mouse>();
|
||||
|
||||
void ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam) {
|
||||
void ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam) const {
|
||||
if (_dxMouse)
|
||||
_dxMouse->ProcessMessage(message, wParam, lParam);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user