kernel/eka/include/drivers/xyin.h
changeset 9 96e5fb8b040d
child 36 bbf8bed59bcb
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 // Copyright (c) 1998-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 // e32\include\drivers\xyin.h
       
    15 // Generic digitiser driver header
       
    16 //
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22 */
       
    23 
       
    24 #ifndef __M32XYIN_H__
       
    25 #define __M32XYIN_H__
       
    26 #include <kernel/kpower.h>
       
    27 #include <platform.h>
       
    28 #include <e32hal.h>
       
    29 
       
    30 #ifdef _DEBUG
       
    31 //#define __DIGITISER_DEBUG1__
       
    32 //#define __DIGITISER_DEBUG2__
       
    33 #endif
       
    34 #ifdef __DIGITISER_DEBUG1__
       
    35 #define __KTRACE_XY1(s) s;
       
    36 #else
       
    37 #define __KTRACE_XY1(s)
       
    38 #endif
       
    39 #ifdef __DIGITISER_DEBUG2__
       
    40 #define __KTRACE_XY2(s) s;
       
    41 #else
       
    42 #define __KTRACE_XY2(s)
       
    43 #endif
       
    44 
       
    45 /**
       
    46 @internalComponent
       
    47 */
       
    48 const TInt KMaxXYSamples=4;
       
    49 
       
    50 /**
       
    51 @publishedPartner
       
    52 @released
       
    53 */
       
    54 struct SDigitiserConfig
       
    55 	{
       
    56 	TInt iPenDownDiscard;	// number of samples to discard on entering the detection volume (area if 2 dimensional)
       
    57 	TInt iPenUpDiscard;		// number of samples to discard on leaving the detection volume (area if 2 dimensional)
       
    58 	TInt iDriveXRise;		// number of milliseconds to wait when driving horizontal edges
       
    59 	TInt iDriveYRise;		// number of milliseconds to wait when driving vertical edges
       
    60 	TInt iMinX;				// minimum valid X value
       
    61 	TInt iMaxX;				// maximum valid X value
       
    62 	TInt iSpreadX;			// maximum valid X spread
       
    63 	TInt iMinY;				// minimum valid Y value
       
    64 	TInt iMaxY;				// maximum valid Y value
       
    65 	TInt iSpreadY;			// maximum valid Y spread
       
    66 	TInt iMaxJumpX;			// maximum X movement per sample (pixels)
       
    67 	TInt iMaxJumpY;			// maximum Y movement per sample (pixels)
       
    68 	TInt iAccThresholdX;	// accumulated offset in pixels to cause movement in X direction
       
    69 	TInt iAccThresholdY;	// accumulated offset in pixels to cause movement in Y direction
       
    70 	TInt iNumXYSamples;		// number of samples to average
       
    71 	TBool iDisregardMinMax;	// TRUE if we want to disregard minimum and maximum
       
    72 	};
       
    73 
       
    74 /**
       
    75 @publishedPartner
       
    76 @prototype
       
    77 */
       
    78 struct SDigitiserConfigV01
       
    79 	{
       
    80 	SDigitiserConfig i2dConfig;
       
    81 	TInt iMinZ;				// minimum valid Z value (distance to screen): 0 when lighlty touching (no pressure applied)
       
    82 	TInt iMaxZ;				// maximum valid Z value: positive for distance to screen, negative for pressure
       
    83 	TInt iSpreadZ;			// maximum valid Z spread (in distance to screen units)
       
    84 	TInt iMaxJumpZ;			// maximum Z movement per sample (in distance to screen units)
       
    85 	TInt iAccThresholdX;	// accumulated offset in distance to screen units to cause movement in Z direction
       
    86 	};
       
    87 
       
    88 /**
       
    89 @publishedPartner
       
    90 @released
       
    91 */
       
    92 NONSHARABLE_CLASS(DDigitiser) : public DPowerHandler
       
    93 	{
       
    94 public:
       
    95 /**
       
    96 @internalComponent
       
    97 */
       
    98 	enum TState
       
    99 		{
       
   100 		EIdle=0,			// waiting for pen to go down
       
   101 		EDiscardOnPenDown,	// discarding just after pen down
       
   102 		EBufferFilling,		// buffer filling with samples
       
   103 		EBufferFull,		// delay line is now full
       
   104 		EPenDown,			// pen-down event has been delivered
       
   105 		};
       
   106 public:
       
   107 	// initialisation
       
   108 	static DDigitiser* New();
       
   109 	DDigitiser();
       
   110 	TInt Create();
       
   111 	virtual TInt DoCreate()=0;
       
   112 public:
       
   113 	// signals from hardware-dependent code
       
   114 	void RawSampleValid();
       
   115 	void PenUp();
       
   116 public:
       
   117 	// signals to hardware-dependent code
       
   118 	virtual void WaitForPenDown()=0;
       
   119 	virtual void WaitForPenUp()=0;
       
   120 	virtual void WaitForPenUpDebounce()=0;
       
   121 	virtual void DigitiserOn()=0;
       
   122 	virtual void DigitiserOff()=0;
       
   123 public:
       
   124 	// machine-configuration related things
       
   125 	virtual TInt DigitiserToScreen(const TPoint& aDigitiserPoint, TPoint& aScreenPoint)=0;
       
   126 	virtual void ScreenToDigitiser(TInt& aX, TInt& aY)=0;
       
   127 	virtual TInt SetXYInputCalibration(const TDigitizerCalibration& aCalibration)=0;
       
   128 	virtual TInt CalibrationPoints(TDigitizerCalibration& aCalibration)=0;
       
   129 	virtual TInt SaveXYInputCalibration()=0;
       
   130 	virtual TInt RestoreXYInputCalibration(TDigitizerCalibrationType aType)=0;
       
   131 	virtual void DigitiserInfo(TDigitiserInfoV01& aInfo)=0;
       
   132 public:
       
   133 	// Generic stuff
       
   134 /**
       
   135 @internalComponent
       
   136 */
       
   137 	void ProcessRawSample();
       
   138 /**
       
   139 @internalComponent
       
   140 */
       
   141 	void ProcessPenUp();
       
   142 /**
       
   143 @internalComponent
       
   144 */
       
   145 	TBool SamplesToPoint(TPoint& aPoint);
       
   146 /**
       
   147 @internalComponent
       
   148 */
       
   149 	TInt DelayAndConvertSample(const TPoint& aSample, TPoint& aScreenPoint);
       
   150 /**
       
   151 @internalComponent
       
   152 */
       
   153 	void IssuePenDownEvent();
       
   154 /**
       
   155 @internalComponent
       
   156 */
       
   157 	void IssuePenUpEvent();
       
   158 	void IssuePenMoveEvent(const TPoint& aPoint);
       
   159 	virtual void FilterPenMove(const TPoint& aPoint)=0;
       
   160 	virtual void ResetPenMoveFilter()=0;
       
   161 /**
       
   162 @internalComponent
       
   163 */
       
   164 	virtual TInt HalFunction(TInt aFunction, TAny* a1, TAny* a2);
       
   165 /**
       
   166 @internalComponent
       
   167 */
       
   168  	void HandleMsg(TMessageBase* aMsg);
       
   169 public:
       
   170 	TDfcQue* iDfcQ;
       
   171  	TMessageQue iMsgQ;
       
   172 	TDfc iSampleDfc;				// called when a raw sample is available
       
   173 	TDfc iPenUpDfc;					// called when the pen goes up
       
   174 	TInt iX[KMaxXYSamples];			// raw X samples from hardware
       
   175 	TInt iY[KMaxXYSamples];			// raw Y samples from hardware
       
   176 	SDigitiserConfig iCfg;			// configuration
       
   177 	TInt iBufferIndex;				// delay line index
       
   178 	TPoint* iBuffer;				// delay line for samples
       
   179 	TPoint iLastPos;				// last pen position
       
   180 	TState iState;
       
   181 	TInt iCount;
       
   182 	TUint8 iPointerOn;
       
   183 	};
       
   184 
       
   185 
       
   186 
       
   187 #endif