4 #define DIRECTINPUT_VERSION 0x0800 12 static Keyboard& Create(IDirectInput8& directInput,
13 const HWND windowHandle) noexcept;
25 void Update() noexcept;
27 __forceinline
const std::uint8_t* GetKeysCurrentState()
const noexcept
29 return mKeysCurrentState;
31 __forceinline
const std::uint8_t* GetKeysLastState()
const noexcept
33 return mKeysLastState;
35 __forceinline
bool IsKeyUp(
const std::uint8_t key)
const noexcept
37 return (mKeysCurrentState[key] & 0x80) == 0U;
39 __forceinline
bool IsKeyDown(
const std::uint8_t key)
const noexcept
41 return (mKeysCurrentState[key] & 0x80) != 0U;
43 __forceinline
bool WasKeyUp(
const std::uint8_t key)
const noexcept
45 return (mKeysLastState[key] & 0x80) == 0U;
47 __forceinline
bool WasKeyDown(
const std::uint8_t key)
const noexcept
49 return (mKeysLastState[key] & 0x80) != 0U;
51 __forceinline
bool WasKeyPressedThisFrame(
const std::uint8_t key)
const noexcept
53 return IsKeyDown(key) && WasKeyUp(key);
55 __forceinline
bool WasKeyReleasedThisFrame(
const std::uint8_t key)
const noexcept
57 return IsKeyUp(key) && WasKeyDown(key);
59 __forceinline
bool IsKeyHeldDown(
const std::uint8_t key)
const noexcept
61 return IsKeyDown(key) && WasKeyDown(key);
65 explicit Keyboard(IDirectInput8& directInput,
const HWND windowHandle);
67 static const uint32_t sNumKeys = 256U;
69 IDirectInput8& mDirectInput;
70 LPDIRECTINPUTDEVICE8 mDevice{
nullptr };
71 std::uint8_t mKeysCurrentState[sNumKeys] = {};
72 std::uint8_t mKeysLastState[sNumKeys] = {};