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