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 {
|
namespace xna {
|
||||||
void GamePad::Initialize() {
|
void GamePad::Initialize() {
|
||||||
impl = unew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
impl->_dxGamePad = unew<DirectX::GamePad>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GamePadState GamePad::GetState(PlayerIndex index) {
|
GamePadState GamePad::GetState(PlayerIndex index) {
|
||||||
|
@ -15,7 +15,6 @@ namespace xna {
|
|||||||
|
|
||||||
void Keyboard::Initialize() {
|
void Keyboard::Initialize() {
|
||||||
impl = unew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
impl->_dxKeyboard = unew<DirectX::Keyboard>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Keyboard::IsConnected() {
|
bool Keyboard::IsConnected() {
|
||||||
|
@ -50,6 +50,5 @@ namespace xna {
|
|||||||
|
|
||||||
void Mouse::Initialize() {
|
void Mouse::Initialize() {
|
||||||
impl = unew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
impl->_dxMouse = unew<DirectX::Mouse>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,6 +5,7 @@
|
|||||||
#include "../common/numerics.hpp"
|
#include "../common/numerics.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
//Structure that defines the position of the left and right triggers on an Xbox Controller.
|
||||||
struct GamePadTriggers {
|
struct GamePadTriggers {
|
||||||
constexpr GamePadTriggers() = default;
|
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 {
|
struct GamePadThumbSticks {
|
||||||
constexpr GamePadThumbSticks() = default;
|
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 {
|
struct GamePadDPad {
|
||||||
constexpr GamePadDPad() = default;
|
constexpr GamePadDPad() = default;
|
||||||
|
|
||||||
@ -83,6 +86,7 @@ namespace xna {
|
|||||||
ButtonState Left{};
|
ButtonState Left{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Identifies whether buttons on an Xbox Controller are pressed or released.
|
||||||
struct GamePadButtons {
|
struct GamePadButtons {
|
||||||
constexpr GamePadButtons() = default;
|
constexpr GamePadButtons() = default;
|
||||||
|
|
||||||
@ -146,6 +150,7 @@ namespace xna {
|
|||||||
using GamePadId = uint64_t;
|
using GamePadId = uint64_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//Describes the capabilities of an Xbox Controller, including controller type, and identifies if the controller supports voice.
|
||||||
struct GamePadCapabilities {
|
struct GamePadCapabilities {
|
||||||
constexpr GamePadCapabilities() = default;
|
constexpr GamePadCapabilities() = default;
|
||||||
|
|
||||||
@ -156,6 +161,7 @@ namespace xna {
|
|||||||
GamePadId Id{};
|
GamePadId Id{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Represents specific information about the state of an Xbox Controller, including the current state of buttons and sticks.
|
||||||
struct GamePadState {
|
struct GamePadState {
|
||||||
constexpr GamePadState() = default;
|
constexpr GamePadState() = default;
|
||||||
|
|
||||||
@ -229,22 +235,30 @@ namespace xna {
|
|||||||
GamePadTriggers Triggers{};
|
GamePadTriggers Triggers{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Allows retrieval of user interaction with an Xbox Controller and setting of controller vibration motors.
|
||||||
class GamePad {
|
class GamePad {
|
||||||
public:
|
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);
|
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);
|
static GamePadState GetState(PlayerIndex index, GamePadDeadZone deadZone);
|
||||||
|
|
||||||
|
//Retrieves the capabilities of an Xbox 360 Controller.
|
||||||
static GamePadCapabilities GetCapabilities(PlayerIndex index);
|
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);
|
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();
|
static void Initialize();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct PlatformImplementation;
|
struct PlatformImplementation;
|
||||||
inline static uptr<PlatformImplementation> impl = nullptr;
|
inline static uptr<PlatformImplementation> impl = nullptr;
|
||||||
|
|
||||||
private:
|
|
||||||
GamePad();
|
|
||||||
GamePad(GamePad&&);
|
|
||||||
GamePad(GamePad&);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,9 +4,13 @@
|
|||||||
#include "../default.hpp"
|
#include "../default.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
//Represents a state of keystrokes recorded by a keyboard input device.
|
||||||
struct KeyboardState {
|
struct KeyboardState {
|
||||||
|
//
|
||||||
|
//same implementation of the DirectX::Keyboard::State structure
|
||||||
|
//
|
||||||
public:
|
public:
|
||||||
bool IsKeyDown(Keys key) const {
|
constexpr bool IsKeyDown(Keys key) const {
|
||||||
const auto k = static_cast<unsigned char>(key);
|
const auto k = static_cast<unsigned char>(key);
|
||||||
|
|
||||||
if (k <= 0xfe)
|
if (k <= 0xfe)
|
||||||
@ -18,7 +22,7 @@ namespace xna {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsKeyUp(Keys key) const {
|
constexpr bool IsKeyUp(Keys key) const {
|
||||||
return !IsKeyDown(key);
|
return !IsKeyDown(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,13 +214,21 @@ namespace xna {
|
|||||||
bool Reserved26 : 1;
|
bool Reserved26 : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Allows retrieval of keystrokes from a keyboard input device.
|
||||||
class Keyboard {
|
class Keyboard {
|
||||||
public:
|
public:
|
||||||
|
//Returns the current keyboard or Chatpad state.
|
||||||
static KeyboardState GetState();
|
static KeyboardState GetState();
|
||||||
//static bool IsConnected();
|
|
||||||
static void Initialize();
|
|
||||||
static bool IsConnected();
|
static bool IsConnected();
|
||||||
|
|
||||||
|
Keyboard() = delete;
|
||||||
|
Keyboard(Keyboard&) = delete;
|
||||||
|
Keyboard(Keyboard&&) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class Game;
|
||||||
|
static void Initialize();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct PlatformImplementation;
|
struct PlatformImplementation;
|
||||||
inline static uptr<PlatformImplementation> impl = nullptr;
|
inline static uptr<PlatformImplementation> impl = nullptr;
|
||||||
|
@ -15,19 +15,28 @@ namespace xna {
|
|||||||
int ScroolWheelValue{ 0 };
|
int ScroolWheelValue{ 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Allows retrieval of position and button clicks from a mouse input device.
|
||||||
class Mouse {
|
class Mouse {
|
||||||
public:
|
public:
|
||||||
|
//Gets the current state of the mouse, including mouse position and buttons pressed.
|
||||||
static MouseState GetState();
|
static MouseState GetState();
|
||||||
|
|
||||||
static bool IsConnected();
|
static bool IsConnected();
|
||||||
static bool IsVisible();
|
static bool IsVisible();
|
||||||
static void IsVisible(bool value);
|
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();
|
static void Initialize();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct PlatformImplementation;
|
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
|
// OTHERS INCLUDES
|
||||||
//--------------------------------//
|
//--------------------------------//
|
||||||
|
|
||||||
|
#include "../default.hpp"
|
||||||
#include "../exception.hpp"
|
#include "../exception.hpp"
|
||||||
#include "../graphics/blendstate.hpp"
|
#include "../graphics/blendstate.hpp"
|
||||||
#include "../graphics/adapter.hpp"
|
#include "../graphics/adapter.hpp"
|
||||||
@ -586,14 +587,14 @@ namespace xna {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct GamePad::PlatformImplementation {
|
struct GamePad::PlatformImplementation {
|
||||||
inline static uptr<DirectX::GamePad> _dxGamePad = nullptr;
|
uptr<DirectX::GamePad> _dxGamePad = unew<DirectX::GamePad>();
|
||||||
|
|
||||||
void Suspend() {
|
void Suspend() const {
|
||||||
if (_dxGamePad)
|
if (_dxGamePad)
|
||||||
_dxGamePad->Suspend();
|
_dxGamePad->Suspend();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Resume() {
|
void Resume() const {
|
||||||
if (_dxGamePad)
|
if (_dxGamePad)
|
||||||
_dxGamePad->Resume();
|
_dxGamePad->Resume();
|
||||||
}
|
}
|
||||||
@ -611,18 +612,18 @@ namespace xna {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Keyboard::PlatformImplementation {
|
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)
|
if (_dxKeyboard)
|
||||||
_dxKeyboard->ProcessMessage(message, wParam, lParam);
|
_dxKeyboard->ProcessMessage(message, wParam, lParam);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Mouse::PlatformImplementation {
|
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)
|
if (_dxMouse)
|
||||||
_dxMouse->ProcessMessage(message, wParam, lParam);
|
_dxMouse->ProcessMessage(message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user