1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00

Remove Keyboard::IsConnected

This commit is contained in:
Danilo 2024-08-01 11:18:07 -03:00
parent a5b9ca4485
commit 231b0f22f9
3 changed files with 20 additions and 14 deletions

View File

@ -1,4 +1,3 @@
#include "xna/input/keyboard.hpp"
#include "xna/xna-dx.hpp"
namespace xna {
@ -15,12 +14,5 @@ namespace xna {
void Keyboard::Initialize() {
impl = unew<PlatformImplementation>();
}
bool Keyboard::IsConnected() {
if (!impl || !impl->_dxKeyboard)
return false;
return impl->_dxKeyboard->IsConnected();
}
}
}

View File

@ -10,6 +10,8 @@ namespace xna {
//same implementation of the DirectX::Keyboard::State structure
//
public:
//Returns whether a specified key is currently being pressed.
constexpr bool IsKeyDown(Keys key) const {
const auto k = static_cast<unsigned char>(key);
@ -22,10 +24,19 @@ namespace xna {
return false;
}
//Returns whether a specified key is currently not pressed.
constexpr bool IsKeyUp(Keys key) const {
return !IsKeyDown(key);
}
//Returns the state of a particular key.
KeyState operator[](Keys key) {
const auto isDown = IsKeyDown(key);
const auto state = static_cast<KeyState>(static_cast<int>(isDown));
return state;
}
private:
bool Reserved0 : 8;
bool Back : 1; // VK_BACK, 0x8
@ -217,9 +228,8 @@ namespace xna {
//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();
//Returns the current keyboard.
static KeyboardState GetState();
private:
friend class Game;

View File

@ -635,9 +635,13 @@ namespace xna {
};
struct Keyboard::PlatformImplementation {
uptr<DirectX::Keyboard> _dxKeyboard = unew<DirectX::Keyboard>();
PlatformImplementation() {
_dxKeyboard = unew<DirectX::Keyboard>();
}
void ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam) const {
uptr<DirectX::Keyboard> _dxKeyboard = nullptr;
inline void ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam) const {
if (_dxKeyboard)
_dxKeyboard->ProcessMessage(message, wParam, lParam);
}