-
Notifications
You must be signed in to change notification settings - Fork 0
/
input_delegator.cpp
87 lines (80 loc) · 1.91 KB
/
input_delegator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "input_delegator.hpp"
#include "console/object.hpp"
#include <sge/systems/instance.hpp>
#include <sge/input/keyboard/collector.hpp>
#include <sge/input/mouse/collector.hpp>
#include <sge/input/keyboard/key_event.hpp>
#include <sge/input/keyboard/key.hpp>
#include <fcppt/math/almost_zero.hpp>
#include <functional>
insula::input_delegator::input_delegator(
sge::systems::instance const &systems,
console::object &_con)
:
con_(
_con),
c1(
systems.keyboard_collector()->key_callback(
std::bind(
&input_delegator::key_callback_internal,
this,
std::placeholders::_1))),
c2(
systems.mouse_collector()->axis_callback(
std::bind(
&input_delegator::mouse_axis_callback_internal,
this,
std::placeholders::_1))),
c3(
systems.mouse_collector()->button_callback(
std::bind(
&input_delegator::mouse_button_callback_internal,
this,
std::placeholders::_1)))
{
}
fcppt::signal::auto_connection
insula::input_delegator::key_callback(
sge::input::keyboard::key_callback const &c)
{
return key_signal_.connect(c);
}
fcppt::signal::auto_connection
insula::input_delegator::mouse_axis_callback(
sge::input::mouse::axis_callback const &c)
{
return mouse_axis_signal_.connect(c);
}
fcppt::signal::auto_connection
insula::input_delegator::mouse_button_callback(
sge::input::mouse::button_callback const &c)
{
return mouse_button_signal_.connect(c);
}
void
insula::input_delegator::key_callback_internal(
sge::input::keyboard::key_event const &c)
{
if(
c.key().code() == sge::input::keyboard::key_code::f1 &&
!c.pressed())
con_.view().active(
!con_.view().active());
if (!con_.view().active())
key_signal_(
c);
}
void
insula::input_delegator::mouse_axis_callback_internal(
sge::input::mouse::axis_event const &e)
{
mouse_axis_signal_(
e);
}
void
insula::input_delegator::mouse_button_callback_internal(
sge::input::mouse::button_event const &b)
{
mouse_button_signal_(
b);
}