|
5 | 5 | #include "../mat3.hpp"
|
6 | 6 | #include "../../input_delegator.hpp"
|
7 | 7 | #include "parameters.hpp"
|
8 |
| -#include <sge/input/key_pair.hpp> |
9 |
| -#include <sge/input/system.hpp> |
| 8 | +#include <sge/input/mouse/axis_event.hpp> |
| 9 | +#include <sge/input/mouse/axis.hpp> |
| 10 | +#include <sge/input/keyboard/key_event.hpp> |
10 | 11 | #include <fcppt/math/matrix/perspective.hpp>
|
11 | 12 | #include <fcppt/math/matrix/translation.hpp>
|
12 | 13 | #include <fcppt/math/matrix/rotation_axis.hpp>
|
13 | 14 | #include <fcppt/math/matrix/transpose.hpp>
|
14 |
| -#include <fcppt/math/almost_zero.hpp> |
15 |
| -#include <fcppt/math/compare.hpp> |
16 |
| -#include <fcppt/math/pi.hpp> |
17 | 15 | #include <fcppt/io/cout.hpp>
|
18 | 16 | #include <fcppt/assert.hpp>
|
19 | 17 |
|
|
23 | 21 | insula::graphics::camera::object::object(
|
24 | 22 | parameters const ¶ms)
|
25 | 23 | :
|
26 |
| - input_connection_( |
27 |
| - params.input_delegator.register_callback( |
| 24 | + key_callback_( |
| 25 | + params.input_delegator.key_callback( |
28 | 26 | std::bind(
|
29 |
| - &object::input_callback, |
| 27 | + &object::key_callback, |
| 28 | + this, |
| 29 | + std::placeholders::_1))), |
| 30 | + mouse_axis_callback_( |
| 31 | + params.input_delegator.mouse_axis_callback( |
| 32 | + std::bind( |
| 33 | + &object::mouse_axis_callback, |
30 | 34 | this,
|
31 | 35 | std::placeholders::_1))),
|
32 | 36 | aspect_(
|
@@ -161,15 +165,46 @@ insula::graphics::camera::object::movement(
|
161 | 165 | }
|
162 | 166 |
|
163 | 167 | void
|
164 |
| -insula::graphics::camera::object::input_callback( |
165 |
| - sge::input::key_pair const &k) |
| 168 | +insula::graphics::camera::object::key_callback( |
| 169 | + sge::input::keyboard::key_event const &k) |
| 170 | +{ |
| 171 | + switch (k.key().code()) |
| 172 | + { |
| 173 | + case sge::input::keyboard::key_code::space: |
| 174 | + dirs_[1] = !k.pressed() ? 0 : 1; |
| 175 | + break; |
| 176 | + case sge::input::keyboard::key_code::lctrl: |
| 177 | + dirs_[1] = !k.pressed() ? 0 : -1; |
| 178 | + break; |
| 179 | + case sge::input::keyboard::key_code::up: |
| 180 | + dirs_[2] = !k.pressed() ? 0 : -1; |
| 181 | + break; |
| 182 | + case sge::input::keyboard::key_code::down: |
| 183 | + dirs_[2] = !k.pressed() ? 0 : 1; |
| 184 | + break; |
| 185 | + case sge::input::keyboard::key_code::left: |
| 186 | + dirs_[0] = !k.pressed() ? 0 : -1; |
| 187 | + break; |
| 188 | + case sge::input::keyboard::key_code::right: |
| 189 | + dirs_[0] = !k.pressed() ? 0 : 1; |
| 190 | + break; |
| 191 | + default: |
| 192 | + break; |
| 193 | + } |
| 194 | +} |
| 195 | + |
| 196 | +void |
| 197 | +insula::graphics::camera::object::mouse_axis_callback( |
| 198 | + sge::input::mouse::axis_event const &k) |
166 | 199 | {
|
167 | 200 | scalar const angle =
|
168 |
| - static_cast<scalar>(k.value())/rotation_speed_; |
| 201 | + static_cast<scalar>( |
| 202 | + k.axis_position()) |
| 203 | + /rotation_speed_; |
169 | 204 |
|
170 |
| - switch (k.key().code()) |
| 205 | + switch (k.axis()) |
171 | 206 | {
|
172 |
| - case sge::input::kc::mouse_x_axis: |
| 207 | + case sge::input::mouse::axis::x: |
173 | 208 | {
|
174 | 209 | using fcppt::math::matrix::rotation_axis;
|
175 | 210 | using fcppt::math::vector::narrow_cast;
|
@@ -203,7 +238,7 @@ insula::graphics::camera::object::input_callback(
|
203 | 238 | .right(normalize(right));
|
204 | 239 | }
|
205 | 240 | break;
|
206 |
| - case sge::input::kc::mouse_y_axis: |
| 241 | + case sge::input::mouse::axis::y: |
207 | 242 | {
|
208 | 243 | using fcppt::math::matrix::rotation_axis;
|
209 | 244 | using fcppt::math::vector::narrow_cast;
|
@@ -231,24 +266,7 @@ insula::graphics::camera::object::input_callback(
|
231 | 266 | .right(normalize(right));
|
232 | 267 | }
|
233 | 268 | break;
|
234 |
| - case sge::input::kc::key_space: |
235 |
| - dirs_[1] = !k.value() ? 0 : 1; |
236 |
| - break; |
237 |
| - case sge::input::kc::key_lctrl: |
238 |
| - dirs_[1] = !k.value() ? 0 : -1; |
239 |
| - break; |
240 |
| - default: |
241 |
| - if (k.key().code() == sge::input::kc::key_up) |
242 |
| - dirs_[2] = !k.value() ? 0 : -1; |
243 |
| - |
244 |
| - if (k.key().code() == sge::input::kc::key_down) |
245 |
| - dirs_[2] = !k.value() ? 0 : 1; |
246 |
| - |
247 |
| - if (k.key().code() == sge::input::kc::key_left) |
248 |
| - dirs_[0] = !k.value() ? 0 : -1; |
249 |
| - |
250 |
| - if (k.key().code() == sge::input::kc::key_right) |
251 |
| - dirs_[0] = !k.value() ? 0 : 1; |
252 |
| - break; |
| 269 | + case sge::input::mouse::axis::wheel: |
| 270 | + break; |
253 | 271 | }
|
254 | 272 | }
|
0 commit comments