sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\include\drivers\xyin.h sl@0: // Generic digitiser driver header sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #ifndef __M32XYIN_H__ sl@0: #define __M32XYIN_H__ sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #ifdef _DEBUG sl@0: //#define __DIGITISER_DEBUG1__ sl@0: //#define __DIGITISER_DEBUG2__ sl@0: #endif sl@0: #ifdef __DIGITISER_DEBUG1__ sl@0: #define __KTRACE_XY1(s) s; sl@0: #else sl@0: #define __KTRACE_XY1(s) sl@0: #endif sl@0: #ifdef __DIGITISER_DEBUG2__ sl@0: #define __KTRACE_XY2(s) s; sl@0: #else sl@0: #define __KTRACE_XY2(s) sl@0: #endif sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: const TInt KMaxXYSamples=4; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: */ sl@0: struct SDigitiserConfig sl@0: { sl@0: TInt iPenDownDiscard; // number of samples to discard on entering the detection volume (area if 2 dimensional) sl@0: TInt iPenUpDiscard; // number of samples to discard on leaving the detection volume (area if 2 dimensional) sl@0: TInt iDriveXRise; // number of milliseconds to wait when driving horizontal edges sl@0: TInt iDriveYRise; // number of milliseconds to wait when driving vertical edges sl@0: TInt iMinX; // minimum valid X value sl@0: TInt iMaxX; // maximum valid X value sl@0: TInt iSpreadX; // maximum valid X spread sl@0: TInt iMinY; // minimum valid Y value sl@0: TInt iMaxY; // maximum valid Y value sl@0: TInt iSpreadY; // maximum valid Y spread sl@0: TInt iMaxJumpX; // maximum X movement per sample (pixels) sl@0: TInt iMaxJumpY; // maximum Y movement per sample (pixels) sl@0: TInt iAccThresholdX; // accumulated offset in pixels to cause movement in X direction sl@0: TInt iAccThresholdY; // accumulated offset in pixels to cause movement in Y direction sl@0: TInt iNumXYSamples; // number of samples to average sl@0: TBool iDisregardMinMax; // TRUE if we want to disregard minimum and maximum sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: */ sl@0: struct SDigitiserConfigV01 sl@0: { sl@0: SDigitiserConfig i2dConfig; sl@0: TInt iMinZ; // minimum valid Z value (distance to screen): 0 when lighlty touching (no pressure applied) sl@0: TInt iMaxZ; // maximum valid Z value: positive for distance to screen, negative for pressure sl@0: TInt iSpreadZ; // maximum valid Z spread (in distance to screen units) sl@0: TInt iMaxJumpZ; // maximum Z movement per sample (in distance to screen units) sl@0: TInt iAccThresholdX; // accumulated offset in distance to screen units to cause movement in Z direction sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: */ sl@0: NONSHARABLE_CLASS(DDigitiser) : public DPowerHandler sl@0: { sl@0: public: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: enum TState sl@0: { sl@0: EIdle=0, // waiting for pen to go down sl@0: EDiscardOnPenDown, // discarding just after pen down sl@0: EBufferFilling, // buffer filling with samples sl@0: EBufferFull, // delay line is now full sl@0: EPenDown, // pen-down event has been delivered sl@0: }; sl@0: public: sl@0: // initialisation sl@0: static DDigitiser* New(); sl@0: DDigitiser(); sl@0: TInt Create(); sl@0: virtual TInt DoCreate()=0; sl@0: public: sl@0: // signals from hardware-dependent code sl@0: void RawSampleValid(); sl@0: void PenUp(); sl@0: public: sl@0: // signals to hardware-dependent code sl@0: virtual void WaitForPenDown()=0; sl@0: virtual void WaitForPenUp()=0; sl@0: virtual void WaitForPenUpDebounce()=0; sl@0: virtual void DigitiserOn()=0; sl@0: virtual void DigitiserOff()=0; sl@0: public: sl@0: // machine-configuration related things sl@0: virtual TInt DigitiserToScreen(const TPoint& aDigitiserPoint, TPoint& aScreenPoint)=0; sl@0: virtual void ScreenToDigitiser(TInt& aX, TInt& aY)=0; sl@0: virtual TInt SetXYInputCalibration(const TDigitizerCalibration& aCalibration)=0; sl@0: virtual TInt CalibrationPoints(TDigitizerCalibration& aCalibration)=0; sl@0: virtual TInt SaveXYInputCalibration()=0; sl@0: virtual TInt RestoreXYInputCalibration(TDigitizerCalibrationType aType)=0; sl@0: virtual void DigitiserInfo(TDigitiserInfoV01& aInfo)=0; sl@0: public: sl@0: // Generic stuff sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: void ProcessRawSample(); sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: void ProcessPenUp(); sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: TBool SamplesToPoint(TPoint& aPoint); sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: TInt DelayAndConvertSample(const TPoint& aSample, TPoint& aScreenPoint); sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: void IssuePenDownEvent(); sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: void IssuePenUpEvent(); sl@0: void IssuePenMoveEvent(const TPoint& aPoint); sl@0: virtual void FilterPenMove(const TPoint& aPoint)=0; sl@0: virtual void ResetPenMoveFilter()=0; sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: virtual TInt HalFunction(TInt aFunction, TAny* a1, TAny* a2); sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: void HandleMsg(TMessageBase* aMsg); sl@0: public: sl@0: TDfcQue* iDfcQ; sl@0: TMessageQue iMsgQ; sl@0: TDfc iSampleDfc; // called when a raw sample is available sl@0: TDfc iPenUpDfc; // called when the pen goes up sl@0: TInt iX[KMaxXYSamples]; // raw X samples from hardware sl@0: TInt iY[KMaxXYSamples]; // raw Y samples from hardware sl@0: SDigitiserConfig iCfg; // configuration sl@0: TInt iBufferIndex; // delay line index sl@0: TPoint* iBuffer; // delay line for samples sl@0: TPoint iLastPos; // last pen position sl@0: TState iState; sl@0: TInt iCount; sl@0: TUint8 iPointerOn; sl@0: }; sl@0: sl@0: sl@0: sl@0: #endif