Sleeping Wombat GUI
0.100
swGUI
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
swInputLibrary
InputCore
KeyboardState.h
Go to the documentation of this file.
1
#pragma once
2
9
#include "
InputDeviceEvent.h
"
10
#include "
KeyState.h
"
11
12
#include <vector>
13
14
15
namespace
sw
{
16
namespace
input
17
{
18
19
20
const
uint8
KEYBOARD_STATE_KEYS_NUMBER
= 255;
21
22
26
class
KeyboardState
27
{
28
private
:
29
30
KeyState
m_keyboardState
[
KEYBOARD_STATE_KEYS_NUMBER
];
31
32
public
:
33
explicit
KeyboardState
();
34
~KeyboardState
();
35
38
const
KeyState
*
GetKeyboardState
()
const
{
return
m_keyboardState
; }
39
41
const
KeyState
&
operator[]
(
Keyboard::PhysicalKeys
key )
const
{
return
m_keyboardState[ key ]; }
42
45
KeyState
*
KeysState
() {
return
m_keyboardState
; }
46
void
RemoveEvents
();
48
50
void
ApplyEvent
(
const
DeviceEvent
& event );
51
52
public
:
53
54
};
55
56
57
59
inline
KeyboardState::KeyboardState
()
60
{
61
for
(
auto
& val :
m_keyboardState
)
62
val = 0;
63
}
64
66
inline
KeyboardState::~KeyboardState
()
67
{}
68
71
inline
void
KeyboardState::RemoveEvents
()
72
{
73
for
(
int
i = 0; i <
KEYBOARD_STATE_KEYS_NUMBER
; ++i )
74
m_keyboardState
[ i ].HoldState();
75
}
76
77
78
// ================================ //
79
//
80
inline
void
KeyboardState::ApplyEvent
(
const
DeviceEvent
& event )
81
{
82
if
( event.
Type
==
DeviceEventType::KeyboardEvent
)
83
{
84
const
KeyEvent
& keyEvent =
event
.
Key
;
85
KeyState
& state =
m_keyboardState
[ keyEvent.
Key
];
86
state = keyEvent.
State
.
IsPressed
();
87
}
88
}
89
90
91
92
93
94
}
// input
95
}
// sw
96
sw::input::KeyboardState::operator[]
const KeyState & operator[](Keyboard::PhysicalKeys key) const
Access state of specific key.
Definition:
KeyboardState.h:41
sw::input::KeyboardState::m_keyboardState
KeyState m_keyboardState[KEYBOARD_STATE_KEYS_NUMBER]
Definition:
KeyboardState.h:30
sw
Definition:
DirectInputModule.cpp:11
sw::input::KeyEvent::State
KeyState State
Only up or down state.
Definition:
InputDeviceEvent.h:276
sw::input::KeyboardState::RemoveEvents
void RemoveEvents()
Removes information about pressed or unpressed buttons. Key states remain unchanged.
Definition:
KeyboardState.h:71
sw::input::KeyEvent::Key
Keyboard::PhysicalKeys Key
Definition:
InputDeviceEvent.h:277
sw::input::KEYBOARD_STATE_KEYS_NUMBER
const uint8 KEYBOARD_STATE_KEYS_NUMBER
Definition:
KeyboardState.h:20
KeyState.h
sw::input::DeviceEvent
KeyStates changed events.
Definition:
InputDeviceEvent.h:313
sw::input::KeyboardState::GetKeyboardState
const KeyState * GetKeyboardState() const
Gets array with keyboard state. Array has size KEYBOARD_STATE_KEYS_NUMBER. You can use Keyboard::Phys...
Definition:
KeyboardState.h:38
sw::input::KeyboardState::KeyboardState
KeyboardState()
Definition:
KeyboardState.h:59
sw::input::KeyboardState::~KeyboardState
~KeyboardState()
Definition:
KeyboardState.h:66
sw::input::KeyboardState
State of keyboard buttons.
Definition:
KeyboardState.h:26
InputDeviceEvent.h
sw::input::KeyboardState::ApplyEvent
void ApplyEvent(const DeviceEvent &event)
Sets state depending on event.
Definition:
KeyboardState.h:80
sw::input::KeyState
Button state structure..
Definition:
KeyState.h:26
uint8
uint8_t uint8
Definition:
TypesDefinitions.h:27
sw::input::KeyState::IsPressed
bool IsPressed() const
Definition:
KeyState.h:45
sw::input::DeviceEventType::KeyboardEvent
sw::input::KeyEvent
Keyboard key change event.
Definition:
InputDeviceEvent.h:274
sw::input::DeviceEvent::Type
DeviceEventType Type
Definition:
InputDeviceEvent.h:324
sw::input::KeyboardState::KeysState
KeyState * KeysState()
Definition:
KeyboardState.h:45
sw::input::Keyboard::PhysicalKeys
PhysicalKeys
Physical keys numbers. Numbers are the same as in DirectInput.
Definition:
InputDeviceEvent.h:29
Generated on Tue May 9 2017 15:46:02 for Sleeping Wombat GUI by
1.8.9.1