equal
deleted
inserted
replaced
|
1 |
|
2 |
|
3 #include "keycontroller.h" |
|
4 #include "orientationcontroller.h" |
|
5 #include "view.h" |
|
6 |
|
7 |
|
8 OrientationController::OrientationController(): KeyController(){ |
|
9 m_delay=10; |
|
10 m_step=10; |
|
11 m_orientationSensor.connectToBackend(); |
|
12 m_orientationSensor.start(); |
|
13 connect(&m_orientationSensor, SIGNAL(readingChanged()), this, SLOT(update())); |
|
14 |
|
15 } |
|
16 |
|
17 OrientationController::~OrientationController(){ |
|
18 m_orientationSensor.stop(); |
|
19 disconnect(&m_orientationSensor); |
|
20 } |
|
21 |
|
22 void OrientationController::updateCoordinates(){ |
|
23 handleKeyPress(m_exCode); |
|
24 m_step = m_exCode!=0 ? m_step+5 : 10; |
|
25 } |
|
26 |
|
27 |
|
28 void OrientationController::update() |
|
29 { |
|
30 switch (m_orientationSensor.reading()->orientation()){ |
|
31 case QTM_NAMESPACE::QOrientationReading::TopUp: |
|
32 m_exCode = Qt::Key_Up; |
|
33 break; |
|
34 case QTM_NAMESPACE::QOrientationReading::TopDown: |
|
35 m_exCode = Qt::Key_Down; |
|
36 break; |
|
37 case QTM_NAMESPACE::QOrientationReading::LeftUp: |
|
38 m_exCode = Qt::Key_Left; |
|
39 break; |
|
40 case QTM_NAMESPACE::QOrientationReading::RightUp: |
|
41 m_exCode = Qt::Key_Right; |
|
42 break; |
|
43 default: |
|
44 m_exCode = 0; |
|
45 return; |
|
46 } |
|
47 handleKeyPress(m_exCode); |
|
48 } |
|
49 |
|
50 |
|
51 |
|
52 |