equal
deleted
inserted
replaced
|
1 #include "inputcontroller.h" |
|
2 #include "rotationcontroller.h" |
|
3 #include <QTime> |
|
4 #include <QDebug> |
|
5 #include <math.h> |
|
6 |
|
7 |
|
8 RotationController::RotationController(): InputController(), m_factor(0.5){ |
|
9 m_rotationSensor.connectToBackend(); |
|
10 m_rotationSensor.start(); |
|
11 connect(&m_rotationSensor, SIGNAL(readingChanged()), this, SLOT(update())); |
|
12 } |
|
13 |
|
14 RotationController::~RotationController(){ |
|
15 m_rotationSensor.stop(); |
|
16 disconnect(&m_rotationSensor); |
|
17 } |
|
18 |
|
19 |
|
20 |
|
21 void RotationController::update() |
|
22 { |
|
23 qreal pitch = m_rotationSensor.reading()->x(); |
|
24 qreal roll= m_rotationSensor.reading()->y(); |
|
25 |
|
26 m_dx = - m_factor* roll; |
|
27 m_dy = - m_factor * pitch; |
|
28 |
|
29 updateCoordinates(); |
|
30 } |
|
31 |
|
32 |
|
33 void RotationController::updateCoordinates(){ |
|
34 m_x +=m_dx; |
|
35 m_y +=m_dy; |
|
36 } |
|
37 |
|
38 |