Sleeping Wombat GUI
0.100
swGUI
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
swInputLibrary
InputCore
KeyboardDevice.h
Go to the documentation of this file.
1
#pragma once
2
8
#include "
Device.h
"
9
10
#include "
KeyboardState.h
"
11
#include "
InputDeviceInfo.h
"
12
#include "
InputDeviceEvent.h
"
13
14
#include "
EventQueue.h
"
15
16
#include <queue>
17
18
19
namespace
sw
{
20
namespace
input
21
{
22
23
40
class
KeyboardDevice
:
public
Device
41
{
42
private
:
43
44
InputDeviceInfo
m_info
;
45
KeyboardState
m_state
;
46
47
EventQueue< DeviceEvent >
m_events
;
48
49
protected
:
50
public
:
51
explicit
KeyboardDevice
() =
default
;
52
~KeyboardDevice
() =
default
;
53
54
55
const
InputDeviceInfo
&
GetInfo
()
const
{
return
m_info
; }
56
const
KeyboardState
&
GetState
()
const
{
return
m_state
; }
57
58
EventQueue< DeviceEvent >
&
GetEventsQueue
() {
return
m_events
; }
59
60
void
ApplyAllEvents
();
61
DeviceEvent
ApplyNextEvent
();
62
Timestamp
GetNextEvtTimestamp
();
63
64
void
RemoveEvents
();
65
66
public
:
67
70
73
void
AddEvent
(
const
DeviceEvent
& event );
74
76
77
};
78
79
DEFINE_OPTR_TYPE
( KeyboardDevice );
80
81
//====================================================================================//
82
// Inline implementation
83
//====================================================================================//
84
85
86
// ================================ //
87
//
88
inline
void
KeyboardDevice::ApplyAllEvents
()
89
{
90
while
( !
m_events
.NoMoreEvents() )
91
{
92
auto
&
event
=
m_events
.PopEvent();
93
94
// Characters don't influence KeyboardState.
95
if
( event.Type ==
DeviceEventType::KeyboardEvent
)
96
m_state
.
ApplyEvent
( event );
97
}
98
}
99
100
// ================================ //
101
//
102
inline
DeviceEvent
KeyboardDevice::ApplyNextEvent
()
103
{
104
if
(
m_events
.NoMoreEvents() )
105
return
DeviceEvent
();
106
107
108
auto
& nextEvent =
m_events
.PopEvent();
109
m_state
.
ApplyEvent
( nextEvent );
110
111
return
nextEvent;
112
}
113
114
// ================================ //
115
//
116
inline
Timestamp
KeyboardDevice::GetNextEvtTimestamp
()
117
{
118
return
m_events
.FrontEvent().LogicalTime;
119
}
120
121
// ================================ //
122
//
123
inline
void
KeyboardDevice::RemoveEvents
()
124
{
125
m_state
.
RemoveEvents
();
126
m_events
.ClearReadEvents();
127
}
128
129
130
// ================================ //
131
//
132
inline
void
KeyboardDevice::AddEvent
(
const
DeviceEvent
& event )
133
{
134
m_events
.AddEvent( event );
135
}
136
137
138
}
// input
139
}
// sw
140
sw::input::KeyboardDevice::GetEventsQueue
EventQueue< DeviceEvent > & GetEventsQueue()
Definition:
KeyboardDevice.h:58
InputDeviceInfo
Information about device. For future use.
Definition:
InputDeviceInfo.h:14
Device.h
sw::input::Timestamp
uint16 Timestamp
Definition:
InputDeviceEvent.h:19
sw::input::KeyboardDevice::GetNextEvtTimestamp
Timestamp GetNextEvtTimestamp()
Definition:
KeyboardDevice.h:116
sw::input::KeyboardDevice::ApplyNextEvent
DeviceEvent ApplyNextEvent()
Definition:
KeyboardDevice.h:102
sw
Definition:
DirectInputModule.cpp:11
sw::input::KeyboardState::RemoveEvents
void RemoveEvents()
Removes information about pressed or unpressed buttons. Key states remain unchanged.
Definition:
KeyboardState.h:71
sw::input::KeyboardDevice::m_events
EventQueue< DeviceEvent > m_events
Definition:
KeyboardDevice.h:47
sw::input::DeviceEvent
KeyStates changed events.
Definition:
InputDeviceEvent.h:313
sw::input::KeyboardDevice::AddEvent
void AddEvent(const DeviceEvent &event)
Add event to event queue. This function doesn't change KeyboardState.
Definition:
KeyboardDevice.h:132
sw::input::KeyboardDevice::m_info
InputDeviceInfo m_info
Definition:
KeyboardDevice.h:44
sw::input::KeyboardDevice::RemoveEvents
void RemoveEvents()
Definition:
KeyboardDevice.h:123
sw::input::KeyboardDevice::~KeyboardDevice
~KeyboardDevice()=default
sw::input::KeyboardDevice::GetInfo
const InputDeviceInfo & GetInfo() const
Definition:
KeyboardDevice.h:55
sw::input::KeyboardDevice
Keyboard state and events.
Definition:
KeyboardDevice.h:40
sw::input::KeyboardDevice::ApplyAllEvents
void ApplyAllEvents()
Definition:
KeyboardDevice.h:88
sw::input::Device
Interface class for input devices.
Definition:
Device.h:21
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::EventQueue
Abstraction of event queue.
Definition:
EventQueue.h:26
sw::input::KeyboardDevice::m_state
KeyboardState m_state
Definition:
KeyboardDevice.h:45
sw::input::DeviceEventType::KeyboardEvent
EventQueue.h
sw::input::KeyboardDevice::KeyboardDevice
KeyboardDevice()=default
InputDeviceInfo.h
KeyboardState.h
sw::input::DEFINE_OPTR_TYPE
DEFINE_OPTR_TYPE(Device)
sw::input::KeyboardDevice::GetState
const KeyboardState & GetState() const
Definition:
KeyboardDevice.h:56
Generated on Tue May 9 2017 15:46:02 for Sleeping Wombat GUI by
1.8.9.1