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=20; |
|
10 m_step=7; |
|
11 } |
|
12 |
|
13 |
|
14 void OrientationController::startSensor() |
|
15 { |
|
16 m_orientationSensor.connectToBackend(); |
|
17 m_orientationSensor.start(); |
|
18 connect(&m_orientationSensor, SIGNAL(readingChanged()), this, SLOT(update())); |
|
19 } |
|
20 |
|
21 void OrientationController::stopSensor(){ m_orientationSensor.stop();} |
|
22 |
|
23 |
|
24 void OrientationController::updateCoordinates(){ |
|
25 handleKeyPress(m_exCode); |
|
26 m_step = m_exCode!=0? m_step+2 : 5; |
|
27 } |
|
28 |
|
29 |
|
30 void OrientationController::update() |
|
31 { |
|
32 switch (m_orientationSensor.reading()->orientation()){ |
|
33 case QTM_NAMESPACE::QOrientationReading::TopUp: |
|
34 m_exCode = Qt::Key_Up; |
|
35 break; |
|
36 case QTM_NAMESPACE::QOrientationReading::TopDown: |
|
37 m_exCode = Qt::Key_Down; |
|
38 break; |
|
39 case QTM_NAMESPACE::QOrientationReading::LeftUp: |
|
40 m_exCode = Qt::Key_Left; |
|
41 break; |
|
42 case QTM_NAMESPACE::QOrientationReading::RightUp: |
|
43 m_exCode = Qt::Key_Right; |
|
44 break; |
|
45 default: |
|
46 m_exCode = 0; |
|
47 return; |
|
48 } |
|
49 handleKeyPress(m_exCode); |
|
50 } |
|
51 |
|
52 |
|
53 |
|
54 |