|
1 /* |
|
2 * Copyright (c) 2009 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: Functional implentation of pointer event service. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPOINTEREVENTHANDLER_H |
|
20 #define CPOINTEREVENTHANDLER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <HTIServicePluginInterface.h> |
|
24 #include <w32std.h> |
|
25 |
|
26 // CONSTANTS |
|
27 |
|
28 // MACROS |
|
29 |
|
30 // DATA TYPES |
|
31 |
|
32 // FUNCTION PROTOTYPES |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * Functional implentation of pointer event service. |
|
40 */ |
|
41 class CPointerEventHandler : public CActive |
|
42 { |
|
43 public: |
|
44 |
|
45 enum TError |
|
46 { |
|
47 EMissingCommand = 0x01, |
|
48 EUnrecognizedCommand = 0x02, |
|
49 ENotReadyCommand = 0x03, |
|
50 EInvalidParameters = 0x9A |
|
51 }; |
|
52 |
|
53 enum TCommand |
|
54 { |
|
55 ETapScreen = 0x10, |
|
56 ETapAndDrag = 0x11, |
|
57 ETapAndDragMultipoint = 0x12, |
|
58 EPressPointerDown = 0x13, |
|
59 ELiftPointerUp = 0x14, |
|
60 EResultOk = 0xFF // only for response message |
|
61 }; |
|
62 |
|
63 enum TPointerState |
|
64 { |
|
65 EPointerUp, |
|
66 EPointerDown, |
|
67 EPointerMoving |
|
68 }; |
|
69 |
|
70 /** |
|
71 * Two-phased constructor. |
|
72 */ |
|
73 static CPointerEventHandler* NewL(); |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 */ |
|
78 virtual ~CPointerEventHandler(); |
|
79 |
|
80 /** |
|
81 * Called by the HtiKeyEventServicePlugin when a pointer event |
|
82 * command is received. |
|
83 * @param aMessage message body destinated to the servive |
|
84 * @param aPriority message priority |
|
85 */ |
|
86 void ProcessMessageL( const TDesC8& aMessage, |
|
87 THtiMessagePriority aPriority ); |
|
88 |
|
89 /** |
|
90 * Sets the dispatcher to send outgoing messages to. |
|
91 * @param aDispatcher pointer to dispatcher instance |
|
92 */ |
|
93 void SetDispatcher( MHtiDispatcher* aDispatcher ); |
|
94 |
|
95 |
|
96 protected: // Functions from base classes |
|
97 |
|
98 // From CActive |
|
99 void RunL(); |
|
100 TInt RunError(TInt aError); |
|
101 void DoCancel(); |
|
102 |
|
103 private: |
|
104 |
|
105 /** |
|
106 * C++ default constructor. |
|
107 */ |
|
108 CPointerEventHandler(); |
|
109 |
|
110 /** |
|
111 * 2nd phase constructor. |
|
112 */ |
|
113 void ConstructL(); |
|
114 |
|
115 // Helper methods |
|
116 void HandleTapScreenL( const TDesC8& aData ); |
|
117 void HandleTapAndDragL( const TDesC8& aData ); |
|
118 void HandleTapAndDragMultipointL( const TDesC8& aData ); |
|
119 void HandlePointerDownOrUpL( const TDesC8& aData ); |
|
120 |
|
121 void SendOkMsgL(); |
|
122 void SendErrorMessageL( TInt aError, const TDesC8& aDescription ); |
|
123 |
|
124 void ChangePointerStateL(); |
|
125 void MoveToNextPointL(); |
|
126 void PointerDown(); |
|
127 void PointerUp(); |
|
128 void PointerMove(); |
|
129 void SimulatePointerEvent( TRawEvent::TType aType ); |
|
130 |
|
131 |
|
132 private: // data |
|
133 |
|
134 RWsSession iWsSession; |
|
135 MHtiDispatcher* iDispatcher; // referenced |
|
136 |
|
137 RTimer iTimer; |
|
138 TBool iReady; |
|
139 TUint8 iCommand; |
|
140 TInt iX; |
|
141 TInt iY; |
|
142 TInt iTapCount; |
|
143 TTimeIntervalMicroSeconds32 iEventDelay; |
|
144 TTimeIntervalMicroSeconds32 iActionDelay; |
|
145 TPointerState iState; |
|
146 RArray<TInt>* iCoords; |
|
147 }; |
|
148 |
|
149 #endif // CKEYEVENTHANDLER_H |