|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef QSTMSTATEMACHINE_H_ |
|
20 #define QSTMSTATEMACHINE_H_ |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #include <qstmuievent_if.h> |
|
26 #include "qstmtimerinterface.h" |
|
27 #include "qstmstatemachine_v2.h" |
|
28 |
|
29 #include <qwindowdefs.h> |
|
30 |
|
31 class QSymbianEvent; |
|
32 |
|
33 #if !defined(Q_WS_X11) |
|
34 #define XEvent void |
|
35 #endif |
|
36 |
|
37 namespace qstmUiEventEngine |
|
38 { |
|
39 |
|
40 class QStm_CallbackTimer; |
|
41 class QStm_StateEngine; |
|
42 class QStm_HwEvent; |
|
43 class QStm_StateEngineConfiguration; |
|
44 |
|
45 |
|
46 class QStm_StateMachine : public QObject, public QStm_TimerInterfaceIf, public QStm_StateMachineIf |
|
47 { |
|
48 Q_OBJECT |
|
49 public: |
|
50 virtual QRect getTouchArea(int pointerNumber) ; |
|
51 virtual void setTouchTimeArea(long fingersize_mm) ; |
|
52 virtual void setTouchArea(long fingersize_mm) ; |
|
53 virtual QStm_AreaShape getTouchAreaShape() ; |
|
54 virtual void setTouchAreaShape(const QStm_AreaShape shape) ; |
|
55 virtual unsigned int getTouchTimeout() ; |
|
56 virtual void setTouchTimeout(unsigned int) ; |
|
57 virtual QRect getHoldArea(int pointerNumber) ; |
|
58 virtual void setHoldArea(long fingersize_mm) ; |
|
59 virtual QStm_AreaShape getHoldAreaShape() ; |
|
60 virtual void setHoldAreaShape(const QStm_AreaShape shape) ; |
|
61 virtual unsigned int getHoldTimeout(); |
|
62 virtual void setHoldTimeout(unsigned int a); |
|
63 virtual unsigned int getTouchSuppressTimeout() ; |
|
64 virtual void setTouchSuppressTimeout(unsigned int a) ; |
|
65 virtual unsigned int getMoveSuppressTimeout() ; |
|
66 virtual void setMoveSuppressTimeout(unsigned int a) ; |
|
67 virtual bool addUiEventObserver(QStm_UiEventObserverIf* observer) ; |
|
68 virtual bool removeUiEventObserver(QStm_UiEventObserverIf* observer) ; |
|
69 virtual bool wasLastMessageFiltered(int pointerNumber) ; |
|
70 virtual void enableCapacitiveUp(bool enable) ; |
|
71 virtual void enableLogging(bool aEnable) ; |
|
72 virtual void enableYadjustment(bool aEnable) ; |
|
73 virtual int getNumberOfPointers() ; |
|
74 |
|
75 /* |
|
76 virtual void setPointerBuffer(TPoint* aBufferPtr, int aBufSize) { m_pointBuffer = aBufferPtr; m_pointBufferSize = aBufSize; } |
|
77 |
|
78 virtual TPoint* getPointerBuffer() { return m_pointBuffer; } |
|
79 |
|
80 virtual int getPointerBufferSize() { return m_pointBufferSize; } |
|
81 */ |
|
82 virtual void setMoveTolerance(long fingersize_mm); |
|
83 |
|
84 QPoint getMoveTolerance(); |
|
85 |
|
86 |
|
87 bool handleSymbianPlatformEvent(const QSymbianEvent* platEvent); |
|
88 |
|
89 bool handleX11PlatformEvent(const XEvent* platEvent); |
|
90 |
|
91 bool handleStateEvent(const QStm_PlatformPointerEvent& platPointerEvent) ; |
|
92 /*! |
|
93 * Setting the Y adjustment useful in capacitive touch |
|
94 * Note that there are problems with the adjustment if done at this level, |
|
95 * the most proper place would be the window server. |
|
96 */ |
|
97 |
|
98 /** |
|
99 * MTimerInterface methods, these are internal and do not need to be exported |
|
100 */ |
|
101 virtual void startTouchTimer(int delay, int pointerNumber) ; |
|
102 virtual void cancelTouchTimer(int pointerNumber) ; |
|
103 virtual void startHoldTimer(int delay, int pointerNumber) ; |
|
104 virtual void cancelHoldTimer(int pointerNumber) ; |
|
105 virtual void startSuppressTimer(int delay, int pointerNumber) ; |
|
106 virtual void cancelSuppressTimer(int pointerNumber) ; |
|
107 |
|
108 |
|
109 //void dragEventFromPointBuffer(); |
|
110 |
|
111 public: |
|
112 ~QStm_StateMachine(); |
|
113 QStm_StateMachine(); |
|
114 private: |
|
115 |
|
116 void init(); |
|
117 |
|
118 inline /*static*/ int pointerIndex(const QStm_PlatformPointerEvent& platPointerEvent); |
|
119 |
|
120 /** |
|
121 * Convert pointer event into our own event format (including timestamp) |
|
122 */ |
|
123 void createHwEvent(QStm_HwEvent& event, const QStm_PlatformPointerEvent& platPointerEvent, void* target, const QTime& aTime) ; |
|
124 void createTimerEvent(QStm_HwEvent& event, QStm_StateMachineEvent eventCode) ; |
|
125 |
|
126 |
|
127 //int retrieveMovePointsBuffer(CCoeControl* aDestination); |
|
128 |
|
129 //void stopPointBuffering(); |
|
130 |
|
131 /** |
|
132 * the actual state machines implementing the transitions etc. |
|
133 */ |
|
134 QStm_StateEngine* m_impl[KMaxNumberOfPointers] ; |
|
135 /* |
|
136 * The configuration for state machines |
|
137 */ |
|
138 QStm_StateEngineConfiguration* m_config ; |
|
139 /*! |
|
140 * convert window coordinates to screen coordinates. |
|
141 */ |
|
142 QPoint screenCoordinates(const QPoint& pos, void* gestureTarget) ; |
|
143 |
|
144 // CCoeEnv* m_coeEnv; |
|
145 |
|
146 bool m_WasMessageFiltered ; |
|
147 bool m_wseventmonitoringenabled ; |
|
148 bool m_loggingenabled ; |
|
149 bool m_capacitiveup ; |
|
150 bool m_pointerBufferSupported; |
|
151 |
|
152 |
|
153 //TPoint* m_pointBuffer; |
|
154 //int m_pointBufferSize; |
|
155 //int m_pointBufferRetrieved; |
|
156 //int m_currentPointBuffIdx; |
|
157 //CCoeControl* m_destination; |
|
158 //CPeriodic* m_pointBufferTimer; |
|
159 //RArray<TPoint> m_pointBufferPoints; |
|
160 |
|
161 int m_3mminpixels ; |
|
162 bool m_adjustYposition ; |
|
163 // Use same naming scheme with the timers, and variables and methods |
|
164 // using macro expansion tricks (with multitouch support starts to look quite ugly): |
|
165 #define DECLARE_TIMER(x) \ |
|
166 void start##x##Timer(int aPointerNumber) ;\ |
|
167 QStm_CallbackTimer* m_##x##Timer[KMaxNumberOfPointers] ;\ |
|
168 void handle##x##Timer(int aPointerNumber) ;\ |
|
169 void cancel##x##Timer(int aPointerNumber) |
|
170 |
|
171 //public slots: |
|
172 DECLARE_TIMER(touch) ; |
|
173 DECLARE_TIMER(hold) ; |
|
174 DECLARE_TIMER(suppress) ; |
|
175 |
|
176 }; |
|
177 } // namespace |
|
178 |
|
179 |
|
180 #endif /* QSTMSTATEMACHINE_H_ */ |