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