Sleeping Wombat GUI
0.100
swGUI
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
swInputLibrary
InputCore
MouseDevice.h
Go to the documentation of this file.
1
#pragma once
2
8
#include "
Device.h
"
9
10
#include "
MouseState.h
"
11
#include "
InputDeviceInfo.h
"
12
#include "
InputDeviceEvent.h
"
13
14
#include "
EventQueue.h
"
15
16
#include <vector>
17
18
19
namespace
sw
{
20
namespace
input
21
{
22
23
27
class
MouseDevice
:
public
Device
28
{
29
private
:
30
31
InputDeviceInfo
m_info
;
32
MouseState
m_state
;
33
34
EventQueue< DeviceEvent >
m_events
;
35
36
protected
:
37
public
:
38
explicit
MouseDevice
() =
default
;
39
~MouseDevice
() =
default
;
40
41
42
const
InputDeviceInfo
&
GetInfo
()
const
{
return
m_info
; }
43
const
MouseState
&
GetState
()
const
{
return
m_state
; }
44
45
EventQueue< DeviceEvent >
&
GetEventsQueue
() {
return
m_events
; }
46
47
void
ApplyAllEvents
();
48
DeviceEvent
ApplyNextEvent
();
49
Timestamp
GetNextEvtTimestamp
();
50
51
void
RemoveEvents
();
52
53
public
:
56
59
void
AddEvent
(
const
DeviceEvent
& event );
60
62
};
63
64
65
DEFINE_OPTR_TYPE
( MouseDevice );
66
67
//====================================================================================//
68
// Inline implementation
69
//====================================================================================//
70
71
// ================================ //
72
//
73
inline
void
MouseDevice::ApplyAllEvents
()
74
{
75
while
( !
m_events
.NoMoreEvents() )
76
{
77
auto
&
event
=
m_events
.PopEvent();
78
m_state
.
ApplyEvent
( event );
79
}
80
}
81
82
// ================================ //
83
//
84
inline
DeviceEvent
MouseDevice::ApplyNextEvent
()
85
{
86
if
(
m_events
.NoMoreEvents() )
87
return
DeviceEvent
();
88
89
auto
& nextEvent =
m_events
.PopEvent();
90
m_state
.
ApplyEvent
( nextEvent );
91
92
return
nextEvent;
93
}
94
95
// ================================ //
96
//
97
inline
Timestamp
MouseDevice::GetNextEvtTimestamp
()
98
{
99
if
(
m_events
.NoMoreEvents() )
100
return
std::numeric_limits< Timestamp >::max();
101
102
return
m_events
.FrontEvent().LogicalTime;
103
}
104
105
// ================================ //
106
//
107
inline
void
MouseDevice::RemoveEvents
()
108
{
109
m_state
.
RemoveEvents
();
110
m_events
.ClearReadEvents();
111
}
112
113
114
// ================================ //
115
//
116
inline
void
MouseDevice::AddEvent
(
const
DeviceEvent
& event )
117
{
118
m_events
.AddEvent( event );
119
}
120
121
122
123
124
}
// input
125
}
// sw
126
127
InputDeviceInfo
Information about device. For future use.
Definition:
InputDeviceInfo.h:14
sw::input::MouseDevice::RemoveEvents
void RemoveEvents()
Definition:
MouseDevice.h:107
Device.h
sw::input::Timestamp
uint16 Timestamp
Definition:
InputDeviceEvent.h:19
sw::input::MouseState
State of mouse.
Definition:
MouseState.h:27
MouseState.h
sw::input::MouseDevice::GetInfo
const InputDeviceInfo & GetInfo() const
Definition:
MouseDevice.h:42
sw::input::MouseDevice::GetNextEvtTimestamp
Timestamp GetNextEvtTimestamp()
Definition:
MouseDevice.h:97
sw::input::MouseDevice::ApplyAllEvents
void ApplyAllEvents()
Definition:
MouseDevice.h:73
sw::input::MouseDevice::m_info
InputDeviceInfo m_info
Definition:
MouseDevice.h:31
sw
Definition:
DirectInputModule.cpp:11
sw::input::MouseDevice::GetState
const MouseState & GetState() const
Definition:
MouseDevice.h:43
sw::input::MouseDevice::~MouseDevice
~MouseDevice()=default
sw::input::DeviceEvent
KeyStates changed events.
Definition:
InputDeviceEvent.h:313
sw::input::MouseDevice::m_state
MouseState m_state
Definition:
MouseDevice.h:32
sw::input::MouseDevice::AddEvent
void AddEvent(const DeviceEvent &event)
Add event to event queue. This function doesn't change KeyboardState.
Definition:
MouseDevice.h:116
sw::input::MouseState::ApplyEvent
void ApplyEvent(const ButtonEvent &event)
Updates state depending on event.
Definition:
MouseState.h:107
sw::input::MouseDevice::MouseDevice
MouseDevice()=default
sw::input::MouseState::RemoveEvents
void RemoveEvents()
Czyści tablicę z eventów o wciśnięciu klawiszy, ale podtrzymuje stan przycisków.
Definition:
MouseState.h:99
sw::input::Device
Interface class for input devices.
Definition:
Device.h:21
sw::input::MouseDevice::GetEventsQueue
EventQueue< DeviceEvent > & GetEventsQueue()
Definition:
MouseDevice.h:45
sw::input::MouseDevice::m_events
EventQueue< DeviceEvent > m_events
Definition:
MouseDevice.h:34
InputDeviceEvent.h
sw::input::MouseDevice
Mouse state and events.
Definition:
MouseDevice.h:27
sw::input::EventQueue
Abstraction of event queue.
Definition:
EventQueue.h:26
EventQueue.h
InputDeviceInfo.h
sw::input::DEFINE_OPTR_TYPE
DEFINE_OPTR_TYPE(Device)
sw::input::MouseDevice::ApplyNextEvent
DeviceEvent ApplyNextEvent()
Definition:
MouseDevice.h:84
Generated on Tue May 9 2017 15:46:02 for Sleeping Wombat GUI by
1.8.9.1