|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Implementation of a digitiser (touch-screen) driver. |
|
15 // This code assumes that an interrupt is generated on pen-down and pen-up events. |
|
16 // |
|
17 // |
|
18 |
|
19 #include <assp.h> |
|
20 #include <videodriver.h> |
|
21 #include <drivers/xyin.h> |
|
22 #include <assp/omap3530_assp/omap3530_gpio.h> |
|
23 #include <assp/omap3530_assp/omap3530_scm.h> |
|
24 #include "mconf.h" |
|
25 #include "../common/controller.h" |
|
26 |
|
27 |
|
28 // TODO replace DEBUG_PRINT( with __KTRACE_OPT(KHARDWARE, |
|
29 #define DEBUG_PRINT(x) x |
|
30 |
|
31 const TInt KXyinThreadPriority = 33; // might need to be updated.. |
|
32 _LIT(KXyinThreadName, "DigitizerThread"); |
|
33 // |
|
34 // TO DO: (mandatory) |
|
35 // |
|
36 // Define the following constants that describe the digitiser position & dimensions |
|
37 // This is only example code... you need to modify it for your hardware |
|
38 |
|
39 // digitiser origin & size in pixels |
|
40 const TUint KConfigXyOffsetX = 0; // digitiser origin - same as display area |
|
41 const TUint KConfigXyOffsetY = 0; |
|
42 const TUint KConfigXyWidth = 640; // 640 pixels per line |
|
43 const TUint KConfigXyHeight = 480; // 480 lines per panel |
|
44 |
|
45 // digitiser dimensions in digitiser co-ordinates |
|
46 const TInt KConfigXyBitsX = 12; |
|
47 const TInt KConfigXyBitsY = 12; |
|
48 const TInt KConfigXySpreadX = 1 << KConfigXyBitsX; // maximum valid X spread |
|
49 const TInt KConfigXySpreadY = 1 << KConfigXyBitsY; // maximum valid Y spread |
|
50 const TInt KConfigXyMinX = 0; // minimum valid X value |
|
51 const TInt KConfigXyMinY = 0; // minimum valid Y value |
|
52 const TInt KConfigXyMaxX = KConfigXySpreadX - 1; // maximum valid X value |
|
53 const TInt KConfigXyMaxY = KConfigXySpreadY - 1; // maximum valid Y value |
|
54 |
|
55 |
|
56 // Define a 2x2 matrix and two constants Tx and Ty to convert digitiser co-ordinates |
|
57 // to pixels such that |
|
58 // |
|
59 // (X<<16 Y<<16) = (x y) x (R11 R12) + (Tx Ty) |
|
60 // (R21 R22) |
|
61 // or : |
|
62 // |
|
63 // X = (x*R11 + y*R21 + TX) >> 16; |
|
64 // Y = (x*R12 + y*R22 + TY) >> 16; |
|
65 |
|
66 // |
|
67 // where x,y are digitiser coordinates, Tx,Ty are constant offsets and X,Y are screen |
|
68 // coordinates. Left shifting by 16 bits is used so as not to lose precision. |
|
69 // |
|
70 // These are default values to be used before calibration has taken place |
|
71 // These are best set by observation. |
|
72 // The example values given below are for a digitiser whose origin is at bottom left |
|
73 // (the screen origin is at top left) |
|
74 const TInt KConfigXyR11 = (KConfigXyWidth << 16) / KConfigXySpreadX; // 10240 |
|
75 const TInt KConfigXyR12 = 0; |
|
76 const TInt KConfigXyR21 = 0; |
|
77 const TInt KConfigXyR22 = - ((KConfigXyHeight << 16) / KConfigXySpreadY); // -7680 |
|
78 const TInt KConfigXyTx = 0; |
|
79 const TInt KConfigXyTy = (KConfigXyHeight << 16) / KConfigXySpreadY; |
|
80 |
|
81 // |
|
82 // TO DO: (optional) |
|
83 // |
|
84 // Define the following constants that describe the digitiser behaviour |
|
85 // This is only example code... you need to modify it for your hardware |
|
86 |
|
87 // After taking a sample, wait for the specified number of nano-kernel ticks (normally 1 ms) |
|
88 // before taking the next sample |
|
89 const TInt KInterSampleTime = 1; |
|
90 |
|
91 // After a group of samples has been processed by the DDigitiser::ProcessRawSample() DFC, |
|
92 // wait for the specified number of nano-kernel ticks before taking the next sample |
|
93 const TInt KInterGroupTime = 1; |
|
94 |
|
95 // After a pen-down interrupt, |
|
96 // wait for the specified number of nano-kernel ticks before taking the next sample |
|
97 const TInt KPenDownDelayTime = 2; |
|
98 |
|
99 // If powering up the device with the pen down, |
|
100 // wait for the specified number of nano-kernel ticks before taking the next sample |
|
101 const TInt KPenUpPollTime = 30; |
|
102 |
|
103 // After a pen-up interrupt, |
|
104 // wait for the specified number of nano-kernel ticks before calling PenUp() |
|
105 const TInt KPenUpDebounceTime = 10; |
|
106 |
|
107 // number of samples to discard on pen-down |
|
108 const TInt KConfigXyPenDownDiscard = 1; |
|
109 |
|
110 // number of samples to discard on pen-up |
|
111 const TInt KConfigXyPenUpDiscard = 1; |
|
112 |
|
113 // offset in pixels to cause movement in X direction |
|
114 const TInt KConfigXyAccThresholdX = 12; |
|
115 |
|
116 // offset in pixels to cause movement in Y direction |
|
117 const TInt KConfigXyAccThresholdY = 12; |
|
118 |
|
119 // number of samples to average - MUST be <= KMaxXYSamples |
|
120 const TInt KConfigXyNumXYSamples = 2; |
|
121 |
|
122 // disregard extremal values in each 4-sample group |
|
123 const TBool KConfigXyDisregardMinMax= EFalse; |
|
124 |
|
125 |
|
126 // obsolete constants : |
|
127 const TInt KConfigXyDriveXRise = 0; |
|
128 const TInt KConfigXyDriveYRise = 0; |
|
129 const TInt KConfigXyMaxJumpX = 0; |
|
130 const TInt KConfigXyMaxJumpY = 0; |
|
131 |
|
132 |
|
133 |
|
134 /****************************************************** |
|
135 * Main Digitiser Class |
|
136 ******************************************************/ |
|
137 |
|
138 // |
|
139 // TO DO: (optional) |
|
140 // |
|
141 // Add any private functions and data you require |
|
142 // |
|
143 NONSHARABLE_CLASS(DTemplateDigitiser) : public DDigitiser |
|
144 |
|
145 { |
|
146 public: |
|
147 enum TState |
|
148 { |
|
149 E_HW_PowerUp, |
|
150 E_HW_PenUpDebounce, |
|
151 E_HW_CollectSample |
|
152 }; |
|
153 |
|
154 public: |
|
155 // from DDigitiser - initialisation |
|
156 DTemplateDigitiser(); |
|
157 virtual TInt DoCreate(); |
|
158 void SetDefaultConfig(); |
|
159 |
|
160 // from DDigitiser - signals to hardware-dependent code |
|
161 virtual void WaitForPenDown(); |
|
162 virtual void WaitForPenUp(); |
|
163 virtual void WaitForPenUpDebounce(); |
|
164 virtual void DigitiserOn(); |
|
165 virtual void DigitiserOff(); |
|
166 virtual void FilterPenMove(const TPoint& aPoint); |
|
167 virtual void ResetPenMoveFilter(); |
|
168 |
|
169 // from DDigitiser - machine-configuration related things |
|
170 virtual TInt DigitiserToScreen(const TPoint& aDigitiserPoint, TPoint& aScreenPoint); |
|
171 virtual void ScreenToDigitiser(TInt& aX, TInt& aY); |
|
172 virtual TInt SetXYInputCalibration(const TDigitizerCalibration& aCalibration); |
|
173 virtual TInt CalibrationPoints(TDigitizerCalibration& aCalibration); |
|
174 virtual TInt SaveXYInputCalibration(); |
|
175 virtual TInt RestoreXYInputCalibration(TDigitizerCalibrationType aType); |
|
176 virtual void DigitiserInfo(TDigitiserInfoV01& aInfo); |
|
177 |
|
178 // from DPowerHandler |
|
179 virtual void PowerDown(TPowerState); |
|
180 virtual void PowerUp(); |
|
181 |
|
182 public: |
|
183 // implementation |
|
184 void TakeSample(); |
|
185 void PenInterrupt(); |
|
186 void DigitiserPowerUp(); |
|
187 void DoPowerUp(); |
|
188 |
|
189 private: |
|
190 static void TimerCallback(TAny* aPtr); |
|
191 static void TimerIntCallback(TAny* aPtr); |
|
192 static void TakeReadingDfc(TAny* aPtr); |
|
193 static void PowerUpDfc(TAny* aPtr); |
|
194 static void PowerDownDfc(TAny* aPtr); |
|
195 static void PenIsr(TAny* aPtr); |
|
196 |
|
197 TouchController iController; |
|
198 NTimer iTimer; |
|
199 NTimer iTimerInt; |
|
200 TDfc iTakeReadingDfc; |
|
201 TDfc iPowerDownDfc; |
|
202 TDfc iPowerUpDfc; |
|
203 TInt iSamplesCount; |
|
204 TState iState; |
|
205 TUint8 iPoweringDown; |
|
206 |
|
207 TSize iScreenSize; |
|
208 TActualMachineConfig& iMachineConfig; |
|
209 }; |
|
210 |
|
211 /****************************************************** |
|
212 * Digitiser main code |
|
213 ******************************************************/ |
|
214 |
|
215 |
|
216 /** |
|
217 Creates a new instance of DDigitiser. |
|
218 Called by extension entry point (PIL) to create a DDigitiser-derived object. |
|
219 |
|
220 @return a pointer to a DTemplateDigitiser object |
|
221 */ |
|
222 DDigitiser* DDigitiser::New() |
|
223 { |
|
224 return new DTemplateDigitiser; |
|
225 } |
|
226 |
|
227 DTemplateDigitiser::DTemplateDigitiser() : |
|
228 iTimer(TimerCallback,this), |
|
229 iTimerInt(TimerIntCallback,this), |
|
230 iTakeReadingDfc(TakeReadingDfc,this,5), |
|
231 iPowerDownDfc(PowerDownDfc,this,5), |
|
232 iPowerUpDfc(PowerUpDfc,this,5), |
|
233 iMachineConfig(TheActualMachineConfig()) |
|
234 { |
|
235 } |
|
236 |
|
237 |
|
238 TInt DTemplateDigitiser::DoCreate() |
|
239 { |
|
240 __KTRACE_OPT(KEXTENSION,Kern::Printf("DTemplateDigitiser::DoCreate")); |
|
241 DEBUG_PRINT(Kern::Printf("DTemplateDigitiser::DoCreate")); |
|
242 |
|
243 if (Kern::ColdStart()) |
|
244 { |
|
245 __KTRACE_OPT(KEXTENSION,Kern::Printf("Resetting digitiser calibration")); |
|
246 |
|
247 // Emergency digitiser calibration values |
|
248 iMachineConfig.iCalibration.iR11 = KConfigXyR11; |
|
249 iMachineConfig.iCalibration.iR12 = KConfigXyR12; |
|
250 iMachineConfig.iCalibration.iR21 = KConfigXyR21; |
|
251 iMachineConfig.iCalibration.iR22 = KConfigXyR22; |
|
252 iMachineConfig.iCalibration.iTx = KConfigXyTx; |
|
253 iMachineConfig.iCalibration.iTy = KConfigXyTy; |
|
254 } |
|
255 |
|
256 // create a DFCQ for this driver |
|
257 TInt r = Kern::DfcQCreate(iDfcQ, KXyinThreadPriority, &KXyinThreadName); |
|
258 if(r != KErrNone) |
|
259 { |
|
260 __KTRACE_OPT(KIIC, Kern::Printf("Digitizer: DFC Queue creation failed, ch: %d, r = %d\n", r)); |
|
261 return r; |
|
262 } |
|
263 iTakeReadingDfc.SetDfcQ(iDfcQ); |
|
264 iPowerDownDfc.SetDfcQ(iDfcQ); |
|
265 iPowerUpDfc.SetDfcQ(iDfcQ); |
|
266 |
|
267 |
|
268 #ifdef USE_SYMBIAN_PRM |
|
269 // register power handler |
|
270 Add(); |
|
271 #endif |
|
272 |
|
273 // setup the DAV (data ready/available) pin by binding to the GPIO pin.. |
|
274 r = GPIO::BindInterrupt(KDataReadyPin, PenIsr, this); |
|
275 if(r != KErrNone) |
|
276 { |
|
277 Kern::Printf("GPIO::BindInterrupt() failed for pin %d, r=%d", KDataReadyPin, r); |
|
278 return r; |
|
279 } |
|
280 |
|
281 r = GPIO::SetPinDirection(KDataReadyPin, GPIO::EInput); |
|
282 if(r == KErrNone) |
|
283 { |
|
284 r = GPIO::SetInterruptTrigger(KDataReadyPin, GPIO::EEdgeRising); |
|
285 if(r == KErrNone) |
|
286 { |
|
287 GPIO::SetDebounceTime(KDataReadyPin, 500); |
|
288 SCM::SetPadConfig(CONTROL_PADCONF_MMC2_DAT0, SCM::EMsw, SCM::EMode4 | SCM::EInputEnable); // 133 (mmc2dat1) |
|
289 r = GPIO::SetPinMode(KDataReadyPin, GPIO::EEnabled); |
|
290 } |
|
291 } |
|
292 |
|
293 if (r == KErrNone) |
|
294 { |
|
295 // set up the default configuration |
|
296 SetDefaultConfig(); |
|
297 |
|
298 // some of the pre-configuration of the touch controller could be done here.. |
|
299 iController.HardReset(); |
|
300 iController.SetTouchMode(TouchController::ESingle); |
|
301 |
|
302 TPoint winStart, winStop; |
|
303 winStart.iX = 0; |
|
304 winStart.iY = 0; |
|
305 winStop.iX = 0xfff; |
|
306 winStop.iY = 0xfff; |
|
307 iController.EnableWindowMode(winStart, winStop); |
|
308 |
|
309 iController.SetNumberOfRows(8); |
|
310 iController.SetNumberOfColumns(8); |
|
311 |
|
312 DigitiserPowerUp(); |
|
313 } |
|
314 return r; |
|
315 } |
|
316 |
|
317 /** |
|
318 Initialise the DDigitiser::iCfg structure |
|
319 */ |
|
320 void DTemplateDigitiser::SetDefaultConfig() |
|
321 { |
|
322 iCfg.iPenDownDiscard = KConfigXyPenDownDiscard; // number of samples to discard on pen-down |
|
323 iCfg.iPenUpDiscard = KConfigXyPenUpDiscard; // number of samples to discard on pen-up |
|
324 iCfg.iDriveXRise = KConfigXyDriveXRise; // number of milliseconds to wait when driving horizontal edges |
|
325 iCfg.iDriveYRise = KConfigXyDriveYRise; // number of milliseconds to wait when driving vertical edges |
|
326 iCfg.iMinX = KConfigXyMinX; // minimum valid X value |
|
327 iCfg.iMaxX = KConfigXyMaxX; // maximum valid X value |
|
328 iCfg.iSpreadX = KConfigXySpreadX; // maximum valid X spread |
|
329 iCfg.iMinY = KConfigXyMinY; // minimum valid Y value |
|
330 iCfg.iMaxY = KConfigXyMaxY; // maximum valid Y value |
|
331 iCfg.iSpreadY = KConfigXySpreadY; // maximum valid Y spread |
|
332 iCfg.iMaxJumpX = KConfigXyMaxJumpX; // maximum X movement per sample (pixels) |
|
333 iCfg.iMaxJumpY = KConfigXyMaxJumpY; // maximum Y movement per sample (pixels) |
|
334 iCfg.iAccThresholdX = KConfigXyAccThresholdX; // offset in pixels to cause movement in X direction |
|
335 iCfg.iAccThresholdY = KConfigXyAccThresholdY; // offset in pixels to cause movement in Y direction |
|
336 iCfg.iNumXYSamples = KConfigXyNumXYSamples; // number of samples to average |
|
337 iCfg.iDisregardMinMax = KConfigXyDisregardMinMax; // disregard extremal values in each 4-sample group |
|
338 } |
|
339 |
|
340 /** |
|
341 Takes a sample from the digitiser. |
|
342 Called in the context of a DFC thread. |
|
343 */ |
|
344 void DTemplateDigitiser::TakeSample() |
|
345 { |
|
346 #ifdef USE_SYMBIAN_PRM |
|
347 TTemplatePowerController::WakeupEvent(); // notify of pendown (wakeup event) and let the power controller sort |
|
348 // out if it needs propagation |
|
349 #endif |
|
350 |
|
351 // TO DO: (mandatory) |
|
352 // Read from appropriate hardware register to determine whether digitiser panel is being touched |
|
353 // Set penDown to ETrue if touched or EFalse if not touched. |
|
354 // |
|
355 |
|
356 // DEBUG_PRINT(Kern::Printf("TS: S%d PD%d Sp%d", (TInt)iState, penDown?1:0, iSamplesCount)); |
|
357 TInt penDown = iController.NumOfTouches(); |
|
358 Kern::Printf("Num touches: %d", penDown); |
|
359 if (iState==E_HW_PowerUp) |
|
360 { |
|
361 // waiting for pen to go up after switch on due to pen down or through the HAL |
|
362 // coverity[dead_error_condition] |
|
363 // The next line should be reachable when this template file is edited for use |
|
364 if (!penDown) // pen has gone up -> transition to new state |
|
365 { |
|
366 iState=E_HW_CollectSample; |
|
367 iSamplesCount=0; // reset sample buffer |
|
368 |
|
369 // TO DO: (mandatory) |
|
370 // Write to the appropriate hardware register to clear the digitiser interrupt |
|
371 // |
|
372 |
|
373 // TO DO: (mandatory) |
|
374 // Write to the appropriate hardware register(s) to allow the hardware |
|
375 // to detect when the digitizer panel is touched |
|
376 // |
|
377 |
|
378 // Interrupt::Enable(KIntIdDigitiser); // enable pen-down interrupt |
|
379 |
|
380 // TO DO: (mandatory) |
|
381 // Write to the appropriate hardware register to enable the digitiser interrupt |
|
382 // |
|
383 |
|
384 } |
|
385 else // pen is still down, wait a bit longer in this state |
|
386 { |
|
387 iTimer.OneShot(KPenUpPollTime); |
|
388 } |
|
389 return; |
|
390 } |
|
391 |
|
392 if (!penDown) |
|
393 { |
|
394 if (iState==E_HW_PenUpDebounce) |
|
395 { |
|
396 iState=E_HW_CollectSample; // back to initial state, no samples collected |
|
397 iSamplesCount=0; // reset sample buffer |
|
398 // Need to lock the kernel to simulate ISR context and thus defer preemption, |
|
399 // since PenUp() expects an ISR context and calls TDfc::Add(). |
|
400 NKern::Lock(); |
|
401 PenUp(); // adds DFC |
|
402 NKern::Unlock(); |
|
403 } |
|
404 else // iState=E_HW_CollectSample |
|
405 { |
|
406 iState=E_HW_PenUpDebounce; |
|
407 iTimer.OneShot(KPenUpDebounceTime); // wait a bit to make sure pen still up |
|
408 } |
|
409 return; |
|
410 } |
|
411 else if (iState==E_HW_PenUpDebounce) // pen down |
|
412 { |
|
413 // false alarm - pen is down again |
|
414 iState=E_HW_CollectSample; // take a new set of samples |
|
415 iSamplesCount=0; // reset sample buffer |
|
416 } |
|
417 // default: pen down and iState=E_HW_CollectSample |
|
418 // TO DO: (mandatory) |
|
419 // Read from appropriate hardware register to get the current digitiser coordinates |
|
420 // of the point that is being touched. Set aResults accordingly. |
|
421 // This is only example code... you need to modify it for your hardware |
|
422 // |
|
423 TPoint aResults; |
|
424 |
|
425 TPoint points[4]; |
|
426 TInt num_points = 0; |
|
427 TInt r = iController.GetMeasurements(points, num_points); |
|
428 Kern::Printf("Measurments: (r: %d)", r); |
|
429 for(TInt i = 0; i < 4/* num_points*/; i++) |
|
430 { |
|
431 Kern::Printf("%d: iX: %d, iY: %d",i, points[i].iX, points[i].iY); |
|
432 } |
|
433 |
|
434 // X axis |
|
435 iX[iSamplesCount] = aResults.iX; |
|
436 // Y axis |
|
437 iY[iSamplesCount] = aResults.iY; |
|
438 |
|
439 DEBUG_PRINT(Kern::Printf("Raw: X=%d Y=%d",iX[iSamplesCount],iY[iSamplesCount])); |
|
440 |
|
441 // Put the hardware back into pen-detect mode |
|
442 |
|
443 // TO DO: (mandatory) |
|
444 // Write to the appropriate hardware register(s) to allow the hardware |
|
445 // to detect when the digitizer panel is touched |
|
446 // |
|
447 |
|
448 // count samples collected - if it's less than minimum, |
|
449 // schedule the reading of another sample |
|
450 if (++iSamplesCount < iCfg.iNumXYSamples) // iX[] and iY[] are 4 levels deep in xyin.h... |
|
451 { |
|
452 if(KInterSampleTime > 0) // need to check this config param as it might be zero! |
|
453 iTimer.OneShot(KInterSampleTime); // haven't got a complete group yet, so queue timer to sample again |
|
454 else |
|
455 iTakeReadingDfc.Enque(); |
|
456 return; |
|
457 } |
|
458 |
|
459 // Have a complete group of samples so pass up to processing layer (PIL) |
|
460 |
|
461 // Need to lock the kernel to simulate ISR context and thus defer preemption, |
|
462 // since RawSampleValid() expects an ISR context and calls TDfc::Add(). |
|
463 NKern::Lock(); |
|
464 RawSampleValid(); // adds DFC |
|
465 NKern::Unlock(); |
|
466 } |
|
467 |
|
468 /** |
|
469 Request for an interrupt to be generated when the pen is next down |
|
470 Called by PIL at startup or when pen leaves digitiser after pen-up event issued |
|
471 */ |
|
472 void DTemplateDigitiser::WaitForPenDown() |
|
473 { |
|
474 // Called at startup or when pen leaves digitiser after pen-up event issued |
|
475 DEBUG_PRINT(Kern::Printf("WD: PowerDownMask %x",iPoweringDown)); |
|
476 if (iPoweringDown) |
|
477 { |
|
478 // powering down |
|
479 |
|
480 // TO DO: (mandatory) |
|
481 // Write to the appropriate hardware register(s) to allow the hardware |
|
482 // to detect when the digitizer panel is touched and wakes up the system if in standby |
|
483 // |
|
484 |
|
485 // |
|
486 // TO DO: (optional) |
|
487 // |
|
488 // Relinquish request on power resources |
|
489 // This will place the peripheral hardware in a low power "Sleep" mode which is Interrupt detection capable |
|
490 // EXAMPLE ONLY |
|
491 #ifdef USE_SYMBIAN_PRM |
|
492 TemplateResourceManager* aManager = TTemplatePowerController::ResourceManager(); |
|
493 aManager -> ModifyToLevel(TemplateResourceManager::AsynchMlResourceUsedByXOnly, 50 /* a percentage */); |
|
494 aManager -> SharedBResource1() -> Release(); |
|
495 #endif |
|
496 |
|
497 iPoweringDown = EFalse; |
|
498 PowerDownDone(); |
|
499 } |
|
500 else |
|
501 { |
|
502 |
|
503 // TO DO: (mandatory) |
|
504 // Write to the appropriate hardware register to clear the digitiser interrupt |
|
505 // |
|
506 |
|
507 // TO DO: (mandatory) |
|
508 // Write to the appropriate hardware register(s) to allow the hardware |
|
509 // to detect when the digitizer panel is touched |
|
510 // |
|
511 |
|
512 if ((iTimer.iState == NTimer::EIdle) && (iTimerInt.iState == NTimer::EIdle)) |
|
513 { |
|
514 GPIO::EnableInterrupt(KDataReadyPin); // enable pen-down interrupt |
|
515 } |
|
516 } |
|
517 } |
|
518 |
|
519 /** |
|
520 Called by PIL after it has processed a group of raw samples while pen is down. |
|
521 Used to indicate that the iX, iY buffers may be re-used |
|
522 */ |
|
523 void DTemplateDigitiser::WaitForPenUp() |
|
524 { |
|
525 DEBUG_PRINT(Kern::Printf("WU")); |
|
526 iState = E_HW_CollectSample; |
|
527 iSamplesCount = 0; // reset sample buffer |
|
528 if(KInterGroupTime > 0) // need to check this config param as it might be zero! |
|
529 { |
|
530 iTimer.OneShot(KInterGroupTime); |
|
531 } |
|
532 else |
|
533 { |
|
534 iTakeReadingDfc.Enque(); |
|
535 } |
|
536 } |
|
537 |
|
538 /** |
|
539 Called by PIL if the group of samples collected is not good enough |
|
540 Used to indicate that the iX, iY buffers may be re-used |
|
541 */ |
|
542 void DTemplateDigitiser::WaitForPenUpDebounce() |
|
543 { |
|
544 DEBUG_PRINT(Kern::Printf("WUDB")); |
|
545 iState = E_HW_CollectSample; |
|
546 iSamplesCount = 0; // reset sample buffer |
|
547 if(KInterGroupTime > 0) // need to check this config param as it might be zero! |
|
548 iTimer.OneShot(KInterGroupTime); |
|
549 else |
|
550 iTakeReadingDfc.Enque(); |
|
551 } |
|
552 |
|
553 /** |
|
554 Pen up/down interrupt service routine (ISR) |
|
555 */ |
|
556 static TUint IsrCnt = 0; |
|
557 void DTemplateDigitiser::PenInterrupt() |
|
558 { |
|
559 DEBUG_PRINT(Kern::Printf("I: %d ", IsrCnt++)); |
|
560 |
|
561 // Interrupt::Clear(KIntIdDigitiser); // should already have been cleared |
|
562 // GPIO::DisableInterrupt(KDataReadyPin); |
|
563 |
|
564 // TO DO: (mandatory) |
|
565 // Read from appropriate hardware register to determine whether digitiser panel is being touched |
|
566 // Set penDown to ETrue if touched or EFalse if not touched. |
|
567 // This is only example code... you need to modify it for your hardware |
|
568 // GPIO::DisableInterrupt(KDataReadyPin); |
|
569 |
|
570 |
|
571 // TBool penDown = iController.NumOfTouches(); |
|
572 TBool penDown = 1; |
|
573 |
|
574 // coverity[dead_error_condition] |
|
575 if(!penDown) // pen up |
|
576 { |
|
577 |
|
578 // TO DO: (mandatory) |
|
579 // Write to the appropriate hardware register to clear the digitiser interrupt |
|
580 // |
|
581 |
|
582 // TO DO: (mandatory) |
|
583 // Write to the appropriate hardware register(s) to allow the hardware |
|
584 // to detect when the digitizer panel is touched |
|
585 // |
|
586 |
|
587 return; // ... and exit! |
|
588 } |
|
589 |
|
590 // Interrupt::Disable(KIntIdDigitiser); // do NOT disable the capability to generate interrupts at the source |
|
591 |
|
592 // Add the timing of pen interrupts as entropy data for the RNG |
|
593 // Interrupt::AddTimingEntropy(); |
|
594 |
|
595 if(0) |
|
596 // if (KPenDownDelayTime>0) // need to check this config param as it might be zero! |
|
597 { |
|
598 iTimerInt.OneShot(KPenDownDelayTime); // start a debounce timer which will queue a DFC to process the interrupt |
|
599 } |
|
600 else |
|
601 { |
|
602 |
|
603 // TO DO: (mandatory) |
|
604 // Write to the appropriate hardware register to clear the digitiser interrupt |
|
605 // This will re-trigger the interrupt mechanism to catch the next interrupt... |
|
606 // |
|
607 |
|
608 iTakeReadingDfc.Add(); |
|
609 } |
|
610 } |
|
611 |
|
612 |
|
613 |
|
614 void DTemplateDigitiser::TimerCallback(TAny* aPtr) |
|
615 { |
|
616 DTemplateDigitiser* pD=(DTemplateDigitiser*)aPtr; |
|
617 DEBUG_PRINT(Kern::Printf("T")); |
|
618 pD->iTakeReadingDfc.Add(); |
|
619 } |
|
620 |
|
621 /** |
|
622 Debounce timer callback |
|
623 schedules a DFC to process a pen-down interrupt |
|
624 |
|
625 @param aPtr a pointer to DTemplateDigitiser |
|
626 */ |
|
627 void DTemplateDigitiser::TimerIntCallback(TAny* aPtr) |
|
628 { |
|
629 DTemplateDigitiser* pD=(DTemplateDigitiser*)aPtr; |
|
630 DEBUG_PRINT(Kern::Printf("TI")); |
|
631 // GPIO::DisableInterrupt(KDataReadyPin); |
|
632 // clear xy interrupt -> re-triggers the interrupt mechanism to catch the next IRQ |
|
633 |
|
634 // TO DO: (mandatory) |
|
635 // Write to the appropriate hardware register to clear the digitiser interrupt |
|
636 // |
|
637 |
|
638 pD->iTakeReadingDfc.Add(); |
|
639 } |
|
640 |
|
641 /** |
|
642 Pen-up/down interrupt handler |
|
643 |
|
644 @param aPtr a pointer to DTemplateDigitiser |
|
645 */ |
|
646 void DTemplateDigitiser::PenIsr(TAny* aPtr) |
|
647 { |
|
648 DTemplateDigitiser* pD=(DTemplateDigitiser*)aPtr; |
|
649 pD->PenInterrupt(); |
|
650 } |
|
651 |
|
652 /** |
|
653 DFC for taking a sample |
|
654 |
|
655 @param aPtr a pointer to DTemplateDigitiser |
|
656 */ |
|
657 void DTemplateDigitiser::TakeReadingDfc(TAny* aPtr) |
|
658 { |
|
659 DTemplateDigitiser* pD=(DTemplateDigitiser*)aPtr; |
|
660 pD->TakeSample(); |
|
661 } |
|
662 |
|
663 |
|
664 void DTemplateDigitiser::PowerUp() |
|
665 { |
|
666 iPowerUpDfc.Enque(); // queue a DFC in this driver's context |
|
667 } |
|
668 |
|
669 void DTemplateDigitiser::PowerUpDfc(TAny* aPtr) |
|
670 { |
|
671 DTemplateDigitiser* pD=(DTemplateDigitiser*)aPtr; |
|
672 pD->DoPowerUp(); |
|
673 } |
|
674 |
|
675 void DTemplateDigitiser::DoPowerUp() |
|
676 { |
|
677 __KTRACE_OPT(KPOWER, Kern::Printf("DTemplateDigitiser::PowerUpDfc()")); |
|
678 DigitiserOn(); |
|
679 PowerUpDone(); // must be called from a different thread than PowerUp() |
|
680 } |
|
681 |
|
682 /** |
|
683 Turn the digitiser on |
|
684 May be called as a result of a power transition or from the HAL |
|
685 If called from HAL, then the digitiser may be already be on (iPointerOn == ETrue) |
|
686 */ |
|
687 void DTemplateDigitiser::DigitiserOn() |
|
688 { |
|
689 __KTRACE_OPT(KPOWER,Kern::Printf("DTemplateDigitiser::DigitiserOn() iPointerOn=%d", iPointerOn)); |
|
690 |
|
691 if (!iPointerOn) // may have been powered up already |
|
692 DigitiserPowerUp(); |
|
693 } |
|
694 |
|
695 /** |
|
696 Power-up the digitiser. Assumes digitiser is off. |
|
697 */ |
|
698 void DTemplateDigitiser::DigitiserPowerUp() |
|
699 { |
|
700 __KTRACE_OPT(KPOWER, Kern::Printf("DigitiserPowerUp")); |
|
701 iPointerOn = ETrue; // now turned on |
|
702 |
|
703 // TO DO: (mandatory) |
|
704 // Write to the appropriate hardware register to clear the digitiser interrupt |
|
705 // |
|
706 |
|
707 // |
|
708 // TO DO: (optional) |
|
709 // |
|
710 // Reassert request on power resources |
|
711 // This will move the peripheral hardware out of low power "Sleep" mode back to fully operational |
|
712 // EXAMPLE ONLY |
|
713 // |
|
714 #ifdef USE_SYMBIAN_PRM |
|
715 TemplateResourceManager* aManager = TTemplatePowerController::ResourceManager(); |
|
716 aManager -> ModifyToLevel(TemplateResourceManager::AsynchMlResourceUsedByXOnly, 100 /* a percentage */); |
|
717 aManager -> SharedBResource1() -> Use(); |
|
718 #endif |
|
719 // TO DO: (mandatory) |
|
720 // Write to the appropriate hardware register(s) to allow the hardware |
|
721 // to detect when the digitizer panel is touched |
|
722 // |
|
723 |
|
724 iState = E_HW_PowerUp; // so we wait for pen up if necessary |
|
725 iTakeReadingDfc.Enque(); |
|
726 } |
|
727 |
|
728 |
|
729 void DTemplateDigitiser::PowerDown(TPowerState /*aPowerState*/) |
|
730 { |
|
731 iPoweringDown = ETrue; |
|
732 iPowerDownDfc.Enque(); // queue a DFC in this driver's context |
|
733 } |
|
734 |
|
735 |
|
736 void DTemplateDigitiser::PowerDownDfc(TAny* aPtr) |
|
737 { |
|
738 DTemplateDigitiser* pD=(DTemplateDigitiser*)aPtr; |
|
739 pD->DigitiserOff(); |
|
740 } |
|
741 |
|
742 |
|
743 |
|
744 /** |
|
745 Turn the digitiser off |
|
746 May be called as a result of a power transition or from the HAL |
|
747 If called from Power Manager, then the digitiser may be already be off (iPointerOn == EFalse) |
|
748 if the platform is in silent running mode |
|
749 */ |
|
750 void DTemplateDigitiser::DigitiserOff() |
|
751 { |
|
752 __KTRACE_OPT(KPOWER,Kern::Printf("DTemplateDigitiser::DigitiserOff() iPointerOn=%d", iPointerOn)); |
|
753 if (iPointerOn) // can have been powered down from HAL |
|
754 { |
|
755 iPointerOn = EFalse; |
|
756 // Interrupt::Disable(KIntIdDigitiser); |
|
757 |
|
758 // TO DO: (mandatory) |
|
759 // Write to the appropriate hardware register to disable the digitiser interrupt |
|
760 // |
|
761 |
|
762 iTimer.Cancel(); |
|
763 iTimerInt.Cancel(); |
|
764 iTakeReadingDfc.Cancel(); |
|
765 if (iState != E_HW_CollectSample) |
|
766 { |
|
767 // Need to lock the kernel to simulate ISR context and thus defer preemption, |
|
768 // since PenUp() expects an ISR context and calls TDfc::Add(). |
|
769 NKern::Lock(); |
|
770 PenUp(); // adds DFC (will call WaitForPenDown) |
|
771 NKern::Unlock(); |
|
772 } |
|
773 else |
|
774 { |
|
775 |
|
776 // TO DO: (mandatory) |
|
777 // Write to the appropriate hardware register(s) to allow the hardware |
|
778 // to detect when the digitizer panel is touched and wakes up the system if in standby |
|
779 // |
|
780 |
|
781 // |
|
782 // TO DO: (optional) |
|
783 // |
|
784 // Relinquish request on power resources as we are being powered down |
|
785 // This will place the peripheral hardware in a low power "Sleep" mode which is Interrupt detection capable |
|
786 // EXAMPLE ONLY |
|
787 // |
|
788 #ifdef USE_SYMBIAN_PRM |
|
789 TemplateResourceManager* aManager = TTemplatePowerController::ResourceManager(); |
|
790 aManager -> ModifyToLevel(TemplateResourceManager::AsynchMlResourceUsedByXOnly, 0 /* a percentage */); |
|
791 aManager -> SharedBResource1() -> Release(); |
|
792 #endif |
|
793 if (iPoweringDown) // came here through PowerDown |
|
794 { |
|
795 iPoweringDown = EFalse; |
|
796 PowerDownDone(); |
|
797 } |
|
798 } |
|
799 } |
|
800 else // already powered down (by HAL) |
|
801 { |
|
802 if (iPoweringDown) // came here through PowerDown |
|
803 { |
|
804 iPoweringDown = EFalse; |
|
805 PowerDownDone(); |
|
806 } |
|
807 } |
|
808 } |
|
809 |
|
810 |
|
811 |
|
812 |
|
813 /** |
|
814 Convert digitiser coordinates to screen coordinates |
|
815 |
|
816 @param aDigitiserPoint the digitiser coordinates |
|
817 @param aScreenPoint A TPoint supplied by the caller. |
|
818 On return, set to the converted screen coordinates in pixels. |
|
819 |
|
820 @return KErrNone if successful |
|
821 */ |
|
822 TInt DTemplateDigitiser::DigitiserToScreen(const TPoint& aDigitiserPoint, TPoint& aScreenPoint) |
|
823 { |
|
824 NKern::LockSystem(); |
|
825 TInt R11 = iMachineConfig.iCalibration.iR11; |
|
826 TInt R12 = iMachineConfig.iCalibration.iR12; |
|
827 TInt R21 = iMachineConfig.iCalibration.iR21; |
|
828 TInt R22 = iMachineConfig.iCalibration.iR22; |
|
829 TInt TX = iMachineConfig.iCalibration.iTx; |
|
830 TInt TY = iMachineConfig.iCalibration.iTy; |
|
831 NKern::UnlockSystem(); |
|
832 TInt X = aDigitiserPoint.iX; |
|
833 TInt Y = aDigitiserPoint.iY; |
|
834 |
|
835 aScreenPoint.iX = (X*R11 + Y*R21 + TX) >> 16; |
|
836 aScreenPoint.iY = (X*R12 + Y*R22 + TY) >> 16; |
|
837 |
|
838 DEBUG_PRINT(Kern::Printf("DtS: Dp.x %d, Dp.y %d, Sp.x %d, Sp.y %d", X,Y,aScreenPoint.iX,aScreenPoint.iY)); |
|
839 |
|
840 return KErrNone; |
|
841 } |
|
842 |
|
843 /** |
|
844 Convert screen coordinates back into digitiser coordinates |
|
845 using the current constants from the superpage |
|
846 |
|
847 @param aX The screen X coordinate in pixels; On return, set to the digitiser X coordinate. |
|
848 @param aY The screen Y coordinate in pixels; On return, set to the digitiser Y coordinate. |
|
849 */ |
|
850 void DTemplateDigitiser::ScreenToDigitiser(TInt& aX, TInt& aY) |
|
851 { |
|
852 NKern::LockSystem(); |
|
853 Int64 R11 = iMachineConfig.iCalibration.iR11; |
|
854 Int64 R12 = iMachineConfig.iCalibration.iR12; |
|
855 Int64 R21 = iMachineConfig.iCalibration.iR21; |
|
856 Int64 R22 = iMachineConfig.iCalibration.iR22; |
|
857 Int64 TX = iMachineConfig.iCalibration.iTx; |
|
858 Int64 TY = iMachineConfig.iCalibration.iTy; |
|
859 NKern::UnlockSystem(); |
|
860 Int64 X = aX; |
|
861 Int64 Y = aY; |
|
862 // |
|
863 // Xd=(Xs<<16)*R22-(Ys<<16)*R21-(TX*R22)+(TY*R21) |
|
864 // ------------------------------------------- |
|
865 // (R22*R11)-(R21*R12) |
|
866 // |
|
867 // |
|
868 // Yd=(Xs<<16)*R12-(Ys<<16)*R11-(TX*R12)+(TY*R11) |
|
869 // ------------------------------------------- |
|
870 // (R21*R12)-(R22*R11) |
|
871 // |
|
872 // where Xd and Yd are digitiser coordinates |
|
873 // Xs and Ys are supplied screen coordinates |
|
874 // |
|
875 X<<=16; |
|
876 Y<<=16; |
|
877 |
|
878 Int64 d=Int64(R21)*Int64(R12)-Int64(R22)*Int64(R11); |
|
879 |
|
880 Int64 r=(X*R12)-(Y*R11)-(TX*R12)+(TY*R11); |
|
881 |
|
882 r=r/d; |
|
883 |
|
884 aY=(TInt)r; |
|
885 |
|
886 r=(X*R22)-(Y*R21)-(TX*R22)+(TY*R21); |
|
887 |
|
888 r=r/(-d); |
|
889 |
|
890 aX=(TInt)r; |
|
891 } |
|
892 |
|
893 /** |
|
894 Calculate values for R11, R12, R21, R22, TX and TY |
|
895 |
|
896 @param aCalibration the screen coordinates of points touched |
|
897 @return KErrNone if successful |
|
898 */ |
|
899 TInt DTemplateDigitiser::SetXYInputCalibration(const TDigitizerCalibration& aCalibration) |
|
900 { |
|
901 TInt R11,R12,R21,R22,TX,TY; |
|
902 // |
|
903 // Get coords of expected points |
|
904 // |
|
905 TDigitizerCalibration cal; |
|
906 TInt ret=CalibrationPoints(cal); |
|
907 if (ret!=KErrNone) |
|
908 return ret; |
|
909 |
|
910 TInt Xp1=cal.iTl.iX; |
|
911 TInt Yp1=cal.iTl.iY; |
|
912 TInt Xp2=cal.iBl.iX; |
|
913 TInt Yp2=cal.iBl.iY; |
|
914 TInt Xp3=cal.iBr.iX; |
|
915 TInt Yp3=cal.iBr.iY; |
|
916 // |
|
917 // Get coords of points touched in screen coordinates |
|
918 // |
|
919 TInt X1=aCalibration.iTl.iX; |
|
920 TInt Y1=aCalibration.iTl.iY; |
|
921 TInt X2=aCalibration.iBl.iX; |
|
922 TInt Y2=aCalibration.iBl.iY; |
|
923 TInt X3=aCalibration.iBr.iX; |
|
924 TInt Y3=aCalibration.iBr.iY; |
|
925 // |
|
926 // Convert back to raw digitiser coordinates |
|
927 // |
|
928 ScreenToDigitiser(X1,Y1); |
|
929 ScreenToDigitiser(X2,Y2); |
|
930 ScreenToDigitiser(X3,Y3); |
|
931 // |
|
932 // (Y1-Y2)(Xp1-Xp3) - (Y1-Y3)(Xp1-Xp2) |
|
933 // ----------------------------------- = R11 |
|
934 // (Y1-Y2)(X1-X3) - (Y1-Y3)(X1-X2) |
|
935 // |
|
936 Int64 r=((Int64(Y1-Y2)*Int64(Xp1-Xp3))-(Int64(Y1-Y3)*Int64(Xp1-Xp2))); |
|
937 r<<=16; |
|
938 r/=(Int64(Y1-Y2)*Int64(X1-X3)-Int64(Y1-Y3)*Int64(X1-X2)); |
|
939 R11=(TInt)r; |
|
940 // |
|
941 // (Y1-Y2)(Yp1-Yp3) - (Y1-Y3)(Yp1-Yp2) |
|
942 // ----------------------------------- = R12 |
|
943 // (Y1-Y2)(X1-X3) - (Y1-Y3)(X1-X2) |
|
944 // |
|
945 r=((Int64(Y1-Y2)*Int64(Yp1-Yp3))-(Int64(Y1-Y3)*Int64(Yp1-Yp2))); |
|
946 r<<=16; |
|
947 r/=(Int64(Y1-Y2)*Int64(X1-X3)-Int64(Y1-Y3)*Int64(X1-X2)); |
|
948 R12=(TInt)r; |
|
949 // |
|
950 // (X1-X3)(Xp2-Xp3) - (X2-X3)(Xp1-Xp3) |
|
951 // ----------------------------------- = R21 |
|
952 // (Y2-Y3)(X1-X3) - (Y1-Y3)(X2-X3) |
|
953 // |
|
954 r=(((X1-X3)*(Xp2-Xp3))-((X2-X3)*(Xp1-Xp3))); |
|
955 r<<=16; |
|
956 r/=(Int64(Y2-Y3)*Int64(X1-X3)-Int64(Y1-Y3)*Int64(X2-X3)); |
|
957 R21=(TInt)r; |
|
958 // |
|
959 // (X1-X3)(Yp2-Yp3) - (X2-X3)(Yp1-Yp3) |
|
960 // ----------------------------------- = R22 |
|
961 // (Y2-Y3)(X1-X3) - (Y1-Y3)(X2-X3) |
|
962 // |
|
963 r=((Int64(X1-X3)*Int64(Yp2-Yp3))-(Int64(X2-X3)*Int64(Yp1-Yp3))); |
|
964 r<<=16; |
|
965 r/=(Int64(Y2-Y3)*Int64(X1-X3)-Int64(Y1-Y3)*Int64(X2-X3)); |
|
966 R22=(TInt)r; |
|
967 // |
|
968 // TX = Xp1 - X1*R11 - Y1*R21 |
|
969 // |
|
970 TX=(Xp1<<16)-(X1*R11)-(Y1*R21); |
|
971 // |
|
972 // TY = Yp1 - X1*R12 - Y1*R22 |
|
973 // |
|
974 TY=(Yp1<<16)-(X1*R12)-(Y1*R22); |
|
975 |
|
976 // |
|
977 // Write new values into the superpage |
|
978 // |
|
979 NKern::LockSystem(); |
|
980 iMachineConfig.iCalibration.iR11 = R11; |
|
981 iMachineConfig.iCalibration.iR12 = R12; |
|
982 iMachineConfig.iCalibration.iR21 = R21; |
|
983 iMachineConfig.iCalibration.iR22 = R22; |
|
984 iMachineConfig.iCalibration.iTx = TX; |
|
985 iMachineConfig.iCalibration.iTy = TY; |
|
986 NKern::UnlockSystem(); |
|
987 |
|
988 return(KErrNone); |
|
989 } |
|
990 |
|
991 /** |
|
992 Informs the user-side calibration application where to draw |
|
993 the cross-hairs on the screen |
|
994 |
|
995 @param aCalibration On return contains the for points on the screen (in screen coordinates) |
|
996 where the cross-hairs should be drawn |
|
997 @return KErrNone if succcessful |
|
998 */ |
|
999 TInt DTemplateDigitiser::CalibrationPoints(TDigitizerCalibration& aCalibration) |
|
1000 { |
|
1001 TVideoInfoV01Buf buf; |
|
1002 TVideoInfoV01& vidinfo=buf(); |
|
1003 TInt r = Kern::HalFunction(EHalGroupDisplay, EDisplayHalCurrentModeInfo, (TAny*)&buf, NULL); |
|
1004 if (r!=KErrNone) |
|
1005 return r; |
|
1006 iScreenSize=vidinfo.iSizeInPixels; |
|
1007 |
|
1008 aCalibration.iBl.iX = aCalibration.iTl.iX = iScreenSize.iWidth/10; |
|
1009 aCalibration.iTr.iY = aCalibration.iTl.iY = iScreenSize.iHeight/10; |
|
1010 aCalibration.iBr.iY = aCalibration.iBl.iY = iScreenSize.iHeight-iScreenSize.iHeight/10; |
|
1011 aCalibration.iTr.iX = aCalibration.iBr.iX = iScreenSize.iWidth-iScreenSize.iWidth/10; |
|
1012 return r; |
|
1013 } |
|
1014 /** |
|
1015 Saves the digitiser calibration to the persistent machine configuration area |
|
1016 so that it can be restored after a power-down/up |
|
1017 |
|
1018 @return KErrNone if succcessful |
|
1019 */ |
|
1020 TInt DTemplateDigitiser::SaveXYInputCalibration() |
|
1021 { |
|
1022 NKern::LockSystem(); |
|
1023 iMachineConfig.iCalibrationSaved = iMachineConfig.iCalibration; |
|
1024 NKern::UnlockSystem(); |
|
1025 return(KErrNone); |
|
1026 } |
|
1027 |
|
1028 /** |
|
1029 Restores the digitiser calibration from the persistent machine configuration area |
|
1030 following a power-up |
|
1031 |
|
1032 @param aType indicates whether to restore factory or saved settings |
|
1033 @return KErrNone if succcessful |
|
1034 */ |
|
1035 TInt DTemplateDigitiser::RestoreXYInputCalibration(TDigitizerCalibrationType aType) |
|
1036 { |
|
1037 TInt r=KErrNone; |
|
1038 NKern::LockSystem(); |
|
1039 switch (aType) |
|
1040 { |
|
1041 case EFactory: |
|
1042 iMachineConfig.iCalibration=iMachineConfig.iCalibrationFactory; |
|
1043 break; |
|
1044 case ESaved: |
|
1045 iMachineConfig.iCalibration=iMachineConfig.iCalibrationSaved; |
|
1046 break; |
|
1047 default: |
|
1048 r=KErrNotSupported; |
|
1049 break; |
|
1050 } |
|
1051 NKern::UnlockSystem(); |
|
1052 return r; |
|
1053 } |
|
1054 |
|
1055 /** |
|
1056 Gets the digitiser configuration information |
|
1057 |
|
1058 @param aInfo On return, contains information about the digitiser's dimensions etc. |
|
1059 */ |
|
1060 void DTemplateDigitiser::DigitiserInfo(TDigitiserInfoV01& aInfo) |
|
1061 { |
|
1062 __KTRACE_OPT(KEXTENSION,Kern::Printf("DTemplateDigitiser::DigitiserInfo")); |
|
1063 aInfo.iDigitiserSize.iWidth=KConfigXyWidth; |
|
1064 aInfo.iDigitiserSize.iHeight=KConfigXyHeight; |
|
1065 aInfo.iOffsetToDisplay.iX=KConfigXyOffsetX; |
|
1066 aInfo.iOffsetToDisplay.iY=KConfigXyOffsetY; |
|
1067 } |
|
1068 |
|
1069 /** |
|
1070 Issues a pen move event if the distance from the last point is greater than the threshold |
|
1071 |
|
1072 @param aPoint the pen position in screen coordinates |
|
1073 */ |
|
1074 void DTemplateDigitiser::FilterPenMove(const TPoint& aPoint) |
|
1075 { |
|
1076 TPoint offset=aPoint; |
|
1077 offset.iX-=iLastPos.iX; |
|
1078 offset.iY-=iLastPos.iY; |
|
1079 if (Abs(offset.iX)>=iCfg.iAccThresholdX || Abs(offset.iY)>=iCfg.iAccThresholdY) |
|
1080 { |
|
1081 iLastPos=aPoint; |
|
1082 IssuePenMoveEvent(aPoint); |
|
1083 } |
|
1084 } |
|
1085 |
|
1086 /** |
|
1087 Reset the pen move filter |
|
1088 */ |
|
1089 void DTemplateDigitiser::ResetPenMoveFilter() |
|
1090 { |
|
1091 } |
|
1092 |