os/kernelhwsrv/kernel/eka/euser/us_evnt.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1995-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\euser\us_evnt.cpp
    15 // 
    16 //
    17 
    18 
    19 #include "us_std.h"
    20 
    21 
    22 
    23 /**
    24 Gets the mouse or digitiser X-Y position.
    25 
    26 @return The position.
    27 */
    28 EXPORT_C TPoint TRawEvent::Pos() const
    29 	{
    30 
    31 	__ASSERT_DEBUG(iType==EPointerMove || 
    32                     iType==EPointerSwitchOn ||
    33 					iType==EButton1Down ||
    34 					iType==EButton1Up ||
    35 					iType==EButton2Down ||
    36 					iType==EButton2Up ||
    37 					iType==EButton3Down ||
    38 					iType==EButton3Up
    39 					,Panic(ETEventNotMoveType));
    40 	return(TPoint(iU.pos.x,iU.pos.y));
    41 	}
    42 
    43 /**
    44 Gets the 3D pointing device Cartesian coordinates.
    45 
    46 @return The position.
    47 */
    48 EXPORT_C TPoint3D TRawEvent::Pos3D() const
    49 	{
    50 
    51 	__ASSERT_DEBUG(iType==EPointerMove || 
    52 					iType==EPointer3DTiltAndMove ||
    53                     iType==EPointerSwitchOn ||
    54 					iType==EButton1Down ||
    55 					iType==EButton1Up ||
    56 					iType==EButton2Down ||
    57 					iType==EButton2Up ||
    58 					iType==EButton3Down ||
    59 					iType==EButton3Up
    60 					,Panic(ETEventNotMoveType));
    61 	TPoint3D p;
    62 	p.iX=iU.pos.x;
    63 	p.iY=iU.pos.y;
    64 	p.iZ=iU.pos3D.z;
    65 	return p;
    66 	}
    67 
    68 /** Gets the 3D pointing device polar coordinates and rotation.
    69 
    70 	@return The polar coordinates and rotation.
    71  */
    72 EXPORT_C TAngle3D TRawEvent::Tilt() const
    73 	{
    74 	__ASSERT_DEBUG(iType==EPointer3DTilt || 
    75 					iType==EPointer3DTiltAndMove
    76 					,Panic(ETEventNotMoveType));
    77 	TAngle3D p;
    78 	p.iPhi=iU.pos3D.phi;
    79 	p.iTheta=iU.pos3D.theta;
    80 	return p;
    81 	}
    82 
    83 /** Gets the rotation angle of 3D pointing device.
    84     
    85     @return The rotation angle of the 3D pointing device.
    86  */
    87 EXPORT_C TInt TRawEvent::Rotation() const
    88 	{
    89 	__ASSERT_DEBUG(iType==EPointer3DRotation || 
    90 					iType==EPointer3DTiltAndMove
    91 					,Panic(ETEventNotMoveType));
    92 	return (iU.pos3D.alpha);
    93 	}
    94 
    95 /**
    96 Gets the scancode.
    97 
    98 @return The scancode.
    99 */
   100 EXPORT_C TInt TRawEvent::ScanCode() const
   101 	{
   102 
   103 	__ASSERT_DEBUG(iType==EKeyDown || iType==EKeyUp || iType==EKeyRepeat,Panic(ETEventNotKeyType));
   104 	return(iU.key.scanCode);
   105 	}
   106 
   107 
   108 
   109 
   110 /**
   111 Gets the repeat count.
   112 
   113 @return The repeat count.
   114 */
   115 EXPORT_C TInt TRawEvent::Repeats() const
   116 	{
   117 	__ASSERT_DEBUG(iType==EKeyRepeat,Panic(ETEventNotKeyRepeatType));
   118 	return(iU.key.repeats);
   119 	}
   120 
   121 
   122 
   123 
   124 /**
   125 Gets the modifiers.
   126 
   127 @return The modifiers.
   128 
   129 @panic EUSER 34 If the event does not represent a modifier key being pressed,
   130                 i.e. if the event type is not TRawEvent::EUpdateModifiers
   131        
   132 @see TRawEvent::EUpdateModifiers
   133 */
   134 EXPORT_C TInt TRawEvent::Modifiers() const
   135 	{
   136 
   137 	__ASSERT_DEBUG(iType==EUpdateModifiers,Panic(ETEventNotUpdateModifiersType));
   138 	return(iU.modifiers);
   139 	}
   140 
   141 
   142 
   143 
   144 /**
   145 Sets the event up as a scancode event.
   146 
   147 @param	aType	  The event type.
   148 @param	aScanCode The scancode.
   149 */
   150 EXPORT_C void TRawEvent::Set(TType aType,TInt aScanCode)
   151 	{
   152 
   153 	iType=(TUint8)aType;
   154 	iU.key.scanCode=aScanCode;
   155 	iU.key.repeats=0;
   156 	BTraceContext8(BTrace::ERawEvent, BTrace::ESetEvent ,(TUint32)aType, (TUint32)aScanCode);
   157 	iTicks=User::TickCount();
   158 	}
   159 
   160 
   161 /**
   162 Sets the event up as a repeating scancode event.
   163 
   164 @param	aType	  The event type.
   165 @param	aScanCode The scancode.
   166 @param	aRepeats  The repeat count.
   167 */
   168 EXPORT_C void TRawEvent::SetRepeat(TType aType,TInt aScanCode,TInt aRepeats)
   169 	{
   170 
   171 	iType=(TUint8)aType;
   172 	iU.key.scanCode=aScanCode;
   173 	iU.key.repeats=aRepeats;
   174 	BTraceContext12(BTrace::ERawEvent, BTrace::ESetEvent ,(TUint32)aType, (TUint32)aScanCode, (TUint32)aRepeats);
   175 	iTicks=User::TickCount();
   176 	}
   177 
   178 
   179 /**
   180 Sets the event up as a mouse/pen event.
   181 
   182 @param	aType	The event type.
   183 @param	aX		The X position.
   184 @param	aY		The Y position.
   185 */
   186 EXPORT_C void TRawEvent::Set(TType aType,TInt aX,TInt aY)
   187 	{
   188 
   189 	iType=(TUint8)aType;
   190 	iU.pos.x=aX;
   191 	iU.pos.y=aY;
   192 	BTraceContext12(BTrace::ERawEvent, BTrace::ESetEvent ,(TUint32)aType, (TUint32)aX,(TUint32)aY);
   193 	iTicks=User::TickCount();
   194 	}
   195 
   196 	
   197 /**
   198 Sets the event up as a 3D pointer linear move event.
   199 
   200 @param	aType	The event type.
   201 @param	aX		The X position.
   202 @param	aY		The Y position.
   203 @param	aZ		The Z position (defaults to 0 on 2D detection devices) .
   204 */
   205 EXPORT_C void TRawEvent::Set(TType aType,TInt aX,TInt aY,TInt aZ)
   206 	{
   207 
   208 	iType=(TUint8)aType;
   209 	iU.pos.x=aX;
   210 	iU.pos.y=aY;
   211 	iU.pos3D.z=aZ;
   212 	//Form the Trace Data
   213 	TUint32 traceData[2];
   214     traceData[0] =aY;
   215 	traceData[1] =aZ;
   216     BTraceContextN(BTrace::ERawEvent, BTrace::ESetEvent ,(TUint32)aType, (TUint32)aX,traceData, sizeof(traceData));    
   217 	iTicks=User::TickCount();
   218 	}
   219 
   220 
   221 /**
   222 Sets up an event without specific parameters.
   223 
   224 @param	aType The event type.
   225 */
   226 EXPORT_C void TRawEvent::Set(TType aType)
   227 	{
   228 
   229 	iType=(TUint8)aType;
   230 	BTraceContext4(BTrace::ERawEvent, BTrace::ESetEvent ,(TUint32)aType);
   231 	iTicks=User::TickCount();
   232 	}
   233 
   234 /**
   235 Sets the event up as a 3D pointer linear move and tilt and rotation change event.
   236 
   237 @param	aType	The event type.
   238 @param	aX		The X position (or TPhi polar coordinate).
   239 @param	aY		The Y position (or Theta polar coordinate).
   240 @param	aZ		The Z position (or rotation).
   241 @param	aPhi	The Phi polar coordinate.
   242 @param	aTheta	The Theta polar coordinate.
   243 @param	aAlpha	The rotation angle.
   244  */
   245 EXPORT_C void TRawEvent::Set(TType aType,TInt aX,TInt aY,TInt aZ,TInt aPhi,TInt aTheta,TInt aAlpha)
   246 	{
   247     
   248 	iType=(TUint8)aType;
   249 	iU.pos.x=aX;
   250 	iU.pos.y=aY;
   251 	iU.pos3D.z=aZ;
   252 	iU.pos3D.phi=aPhi;
   253 	iU.pos3D.theta=aTheta;
   254 	iU.pos3D.alpha=aAlpha;	
   255 	//Form the Trace Data
   256 	TUint32 traceData[5];
   257     traceData[0] =aY;
   258 	traceData[1] =aZ;
   259 	traceData[2] =aPhi;
   260 	traceData[3] =aTheta;
   261 	traceData[4] =aAlpha;
   262 	BTraceContextN(BTrace::ERawEvent, BTrace::ESetEvent ,(TUint32)aType, (TUint32)aX,traceData, sizeof(traceData));	
   263 	iTicks=User::TickCount();
   264 	}
   265 
   266 /**
   267 Sets the event up as 3D pointer tilt change event.
   268 
   269 @param	aType	The event type.
   270 @param	aPhi	The Phi coordinate.
   271 @param	aTheta	The Theta coordinate.
   272 */
   273 EXPORT_C void TRawEvent::SetTilt(TType aType,TInt aPhi,TInt aTheta)
   274 	{
   275 
   276 	iType=(TUint8)aType;
   277 	iU.pos3D.phi=aPhi;
   278 	iU.pos3D.theta=aTheta;	
   279 	BTraceContext12(BTrace::ERawEvent, BTrace::ESetTiltEvent,(TUint32)aType, (TUint32)aPhi,(TUint32)aTheta);
   280 	iTicks=User::TickCount();
   281 	}
   282 
   283 /**
   284 Sets the event up as 3D pointer rotation event.
   285 
   286 @param	aType	The event type.
   287 @param	aAlpha	The rotation angle.
   288 */
   289 EXPORT_C void TRawEvent::SetRotation(TType aType,TInt aAlpha)
   290 	{
   291 
   292 	iType=(TUint8)aType;
   293 	iU.pos3D.alpha=aAlpha;
   294 	BTraceContext8(BTrace::ERawEvent, BTrace::ESetRotationtEvent,(TUint32)aType, (TUint32)aAlpha);
   295 	iTicks=User::TickCount();
   296 	}
   297 
   298 
   299 /**
   300 Sets the event up as a 3D pointer linear move event with pointer number 
   301 @param	aType	The event type.
   302 @param	aX		The X position.
   303 @param	aY		The Y position.
   304 @param	aZ		The Z position .
   305 @param  aPointerNumber   The pointer number for the event 
   306 */
   307 
   308 EXPORT_C void TRawEvent::Set (TType aType, TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber)
   309 	{
   310 
   311 	iType=(TUint8)aType;
   312 	iU.pos3D.x=aX;
   313 	iU.pos3D.y=aY;
   314 	iU.pos3D.z=aZ;
   315 	iPointerNumber=aPointerNumber;		
   316 	//Form the Trace Data
   317 	TUint32 traceData[3];
   318     traceData[0] =aY;
   319 	traceData[1] =aZ;
   320 	traceData[2] =aPointerNumber;
   321     BTraceContextN(BTrace::ERawEvent, BTrace::ESetEvent ,(TUint32)aType, (TUint32)aX,traceData, sizeof(traceData));    	
   322 	iTicks=User::TickCount();
   323 	}
   324