os/kernelhwsrv/kernel/eka/include/drivers/xyin.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/drivers/xyin.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,187 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\include\drivers\xyin.h
    1.18 +// Generic digitiser driver header
    1.19 +//
    1.20 +//
    1.21 +
    1.22 +/**
    1.23 + @file
    1.24 + @internalComponent
    1.25 +*/
    1.26 +
    1.27 +#ifndef __M32XYIN_H__
    1.28 +#define __M32XYIN_H__
    1.29 +#include <kernel/kpower.h>
    1.30 +#include <platform.h>
    1.31 +#include <e32hal.h>
    1.32 +
    1.33 +#ifdef _DEBUG
    1.34 +//#define __DIGITISER_DEBUG1__
    1.35 +//#define __DIGITISER_DEBUG2__
    1.36 +#endif
    1.37 +#ifdef __DIGITISER_DEBUG1__
    1.38 +#define __KTRACE_XY1(s) s;
    1.39 +#else
    1.40 +#define __KTRACE_XY1(s)
    1.41 +#endif
    1.42 +#ifdef __DIGITISER_DEBUG2__
    1.43 +#define __KTRACE_XY2(s) s;
    1.44 +#else
    1.45 +#define __KTRACE_XY2(s)
    1.46 +#endif
    1.47 +
    1.48 +/**
    1.49 +@internalComponent
    1.50 +*/
    1.51 +const TInt KMaxXYSamples=4;
    1.52 +
    1.53 +/**
    1.54 +@publishedPartner
    1.55 +@released
    1.56 +*/
    1.57 +struct SDigitiserConfig
    1.58 +	{
    1.59 +	TInt iPenDownDiscard;	// number of samples to discard on entering the detection volume (area if 2 dimensional)
    1.60 +	TInt iPenUpDiscard;		// number of samples to discard on leaving the detection volume (area if 2 dimensional)
    1.61 +	TInt iDriveXRise;		// number of milliseconds to wait when driving horizontal edges
    1.62 +	TInt iDriveYRise;		// number of milliseconds to wait when driving vertical edges
    1.63 +	TInt iMinX;				// minimum valid X value
    1.64 +	TInt iMaxX;				// maximum valid X value
    1.65 +	TInt iSpreadX;			// maximum valid X spread
    1.66 +	TInt iMinY;				// minimum valid Y value
    1.67 +	TInt iMaxY;				// maximum valid Y value
    1.68 +	TInt iSpreadY;			// maximum valid Y spread
    1.69 +	TInt iMaxJumpX;			// maximum X movement per sample (pixels)
    1.70 +	TInt iMaxJumpY;			// maximum Y movement per sample (pixels)
    1.71 +	TInt iAccThresholdX;	// accumulated offset in pixels to cause movement in X direction
    1.72 +	TInt iAccThresholdY;	// accumulated offset in pixels to cause movement in Y direction
    1.73 +	TInt iNumXYSamples;		// number of samples to average
    1.74 +	TBool iDisregardMinMax;	// TRUE if we want to disregard minimum and maximum
    1.75 +	};
    1.76 +
    1.77 +/**
    1.78 +@publishedPartner
    1.79 +@prototype
    1.80 +*/
    1.81 +struct SDigitiserConfigV01
    1.82 +	{
    1.83 +	SDigitiserConfig i2dConfig;
    1.84 +	TInt iMinZ;				// minimum valid Z value (distance to screen): 0 when lighlty touching (no pressure applied)
    1.85 +	TInt iMaxZ;				// maximum valid Z value: positive for distance to screen, negative for pressure
    1.86 +	TInt iSpreadZ;			// maximum valid Z spread (in distance to screen units)
    1.87 +	TInt iMaxJumpZ;			// maximum Z movement per sample (in distance to screen units)
    1.88 +	TInt iAccThresholdX;	// accumulated offset in distance to screen units to cause movement in Z direction
    1.89 +	};
    1.90 +
    1.91 +/**
    1.92 +@publishedPartner
    1.93 +@released
    1.94 +*/
    1.95 +NONSHARABLE_CLASS(DDigitiser) : public DPowerHandler
    1.96 +	{
    1.97 +public:
    1.98 +/**
    1.99 +@internalComponent
   1.100 +*/
   1.101 +	enum TState
   1.102 +		{
   1.103 +		EIdle=0,			// waiting for pen to go down
   1.104 +		EDiscardOnPenDown,	// discarding just after pen down
   1.105 +		EBufferFilling,		// buffer filling with samples
   1.106 +		EBufferFull,		// delay line is now full
   1.107 +		EPenDown,			// pen-down event has been delivered
   1.108 +		};
   1.109 +public:
   1.110 +	// initialisation
   1.111 +	static DDigitiser* New();
   1.112 +	DDigitiser();
   1.113 +	TInt Create();
   1.114 +	virtual TInt DoCreate()=0;
   1.115 +public:
   1.116 +	// signals from hardware-dependent code
   1.117 +	void RawSampleValid();
   1.118 +	void PenUp();
   1.119 +public:
   1.120 +	// signals to hardware-dependent code
   1.121 +	virtual void WaitForPenDown()=0;
   1.122 +	virtual void WaitForPenUp()=0;
   1.123 +	virtual void WaitForPenUpDebounce()=0;
   1.124 +	virtual void DigitiserOn()=0;
   1.125 +	virtual void DigitiserOff()=0;
   1.126 +public:
   1.127 +	// machine-configuration related things
   1.128 +	virtual TInt DigitiserToScreen(const TPoint& aDigitiserPoint, TPoint& aScreenPoint)=0;
   1.129 +	virtual void ScreenToDigitiser(TInt& aX, TInt& aY)=0;
   1.130 +	virtual TInt SetXYInputCalibration(const TDigitizerCalibration& aCalibration)=0;
   1.131 +	virtual TInt CalibrationPoints(TDigitizerCalibration& aCalibration)=0;
   1.132 +	virtual TInt SaveXYInputCalibration()=0;
   1.133 +	virtual TInt RestoreXYInputCalibration(TDigitizerCalibrationType aType)=0;
   1.134 +	virtual void DigitiserInfo(TDigitiserInfoV01& aInfo)=0;
   1.135 +public:
   1.136 +	// Generic stuff
   1.137 +/**
   1.138 +@internalComponent
   1.139 +*/
   1.140 +	void ProcessRawSample();
   1.141 +/**
   1.142 +@internalComponent
   1.143 +*/
   1.144 +	void ProcessPenUp();
   1.145 +/**
   1.146 +@internalComponent
   1.147 +*/
   1.148 +	TBool SamplesToPoint(TPoint& aPoint);
   1.149 +/**
   1.150 +@internalComponent
   1.151 +*/
   1.152 +	TInt DelayAndConvertSample(const TPoint& aSample, TPoint& aScreenPoint);
   1.153 +/**
   1.154 +@internalComponent
   1.155 +*/
   1.156 +	void IssuePenDownEvent();
   1.157 +/**
   1.158 +@internalComponent
   1.159 +*/
   1.160 +	void IssuePenUpEvent();
   1.161 +	void IssuePenMoveEvent(const TPoint& aPoint);
   1.162 +	virtual void FilterPenMove(const TPoint& aPoint)=0;
   1.163 +	virtual void ResetPenMoveFilter()=0;
   1.164 +/**
   1.165 +@internalComponent
   1.166 +*/
   1.167 +	virtual TInt HalFunction(TInt aFunction, TAny* a1, TAny* a2);
   1.168 +/**
   1.169 +@internalComponent
   1.170 +*/
   1.171 + 	void HandleMsg(TMessageBase* aMsg);
   1.172 +public:
   1.173 +	TDfcQue* iDfcQ;
   1.174 + 	TMessageQue iMsgQ;
   1.175 +	TDfc iSampleDfc;				// called when a raw sample is available
   1.176 +	TDfc iPenUpDfc;					// called when the pen goes up
   1.177 +	TInt iX[KMaxXYSamples];			// raw X samples from hardware
   1.178 +	TInt iY[KMaxXYSamples];			// raw Y samples from hardware
   1.179 +	SDigitiserConfig iCfg;			// configuration
   1.180 +	TInt iBufferIndex;				// delay line index
   1.181 +	TPoint* iBuffer;				// delay line for samples
   1.182 +	TPoint iLastPos;				// last pen position
   1.183 +	TState iState;
   1.184 +	TInt iCount;
   1.185 +	TUint8 iPointerOn;
   1.186 +	};
   1.187 +
   1.188 +
   1.189 +
   1.190 +#endif