symport/e32/include/e32event.h
changeset 1 0a7b44b10206
child 2 806186ab5e14
equal deleted inserted replaced
0:c55016431358 1:0a7b44b10206
       
     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 "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32\include\e32event.h
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __E32EVENT_H__
       
    19 #define __E32EVENT_H__
       
    20 #include <e32cmn.h>
       
    21 #include <e32btrace.h>
       
    22 
       
    23 /**
       
    24 @publishedAll
       
    25 @released
       
    26 */
       
    27 const TInt KUndefinedDeviceNumber = -1;
       
    28 
       
    29 /**
       
    30 @publishedAll
       
    31 @released
       
    32 
       
    33 Represents a raw hardware event as generated by hardware drivers of
       
    34 a pointer device, a keyboard etc.
       
    35 
       
    36 Raw hardware events are added to the kernel's event queue.
       
    37 */
       
    38 class TRawEvent
       
    39 	{
       
    40 public:
       
    41 
       
    42     /**
       
    43     Defines the event type.
       
    44     */
       
    45 	enum TType
       
    46 		{
       
    47 		
       
    48 		/**
       
    49 		Represents an uninitialised event object.
       
    50 		*/
       
    51 		ENone,
       
    52 		
       
    53 		/**
       
    54 		A pointer device (e.g. a pen) has moved. Only changes in Cartesian coordinates are tracked.
       
    55 		*/
       
    56 		EPointerMove,
       
    57 		
       
    58 		/**
       
    59 		A switch on event caused by a screen tap using a pointer device. 
       
    60 		*/
       
    61         EPointerSwitchOn,
       
    62         
       
    63         /**
       
    64         Represents a keyboard key down event.
       
    65         */
       
    66 		EKeyDown,
       
    67 		
       
    68 		/**
       
    69 		Represents a keyboard key up event.
       
    70 		*/
       
    71 		EKeyUp,
       
    72 		
       
    73 		/**
       
    74 		Represents a redraw event.
       
    75 		
       
    76 		Typically generated in an emulator environment in response
       
    77 		to a host OS redraw event.
       
    78 		*/
       
    79 		ERedraw,
       
    80 		
       
    81 		/**
       
    82 		Represents a device switch on event.
       
    83 		*/
       
    84 		ESwitchOn,
       
    85 		
       
    86 		/**
       
    87 		*/
       
    88         EActive,
       
    89         
       
    90   		/**
       
    91 		*/
       
    92 		EInactive,
       
    93 		
       
    94 		/**
       
    95 		Represents a modifier key being pressed.
       
    96 		*/
       
    97 		EUpdateModifiers,
       
    98 		
       
    99 		/**
       
   100 		Represents a button down event.
       
   101 		
       
   102 		This is typically used to represent a pointing device
       
   103 		coming into contact with a touch sensitive screen.
       
   104 		*/
       
   105 		EButton1Down,
       
   106 		
       
   107 		/**
       
   108 		Represents a button up event.
       
   109 		
       
   110 		This is typically used to represent a pointing device
       
   111 		being lifted away from a touch sensitive screen.
       
   112 		*/
       
   113 		EButton1Up,
       
   114 		
       
   115 		/**
       
   116 		Represents a button down event.
       
   117 		
       
   118 		This is typically used to represent a pointing device
       
   119 		coming into contact with a touch sensitive screen.
       
   120 		*/
       
   121 		EButton2Down,
       
   122 		
       
   123 		/**
       
   124 		Represents a button up event.
       
   125 		
       
   126 		This is typically used to represent a pointing device
       
   127 		being lifted away from a touch sensitive screen.
       
   128 		*/
       
   129 		EButton2Up,
       
   130 		
       
   131 		/**
       
   132 		Represents a button down event.
       
   133 		
       
   134 		This is typically used to represent a pointing device
       
   135 		coming into contact with a touch sensitive screen.
       
   136 		*/
       
   137 		EButton3Down,
       
   138 		
       
   139 		/**
       
   140 		Represents a button up event.
       
   141 		
       
   142 		This is typically used to represent a pointing device
       
   143 		being lifted away from a touch sensitive screen.
       
   144 		*/
       
   145 		EButton3Up,
       
   146 		
       
   147 		/**
       
   148 		Represents a device switch off event.
       
   149 		*/
       
   150 		ESwitchOff,
       
   151 		
       
   152 		/**
       
   153 		Represents a key being continually pressed event.
       
   154 		*/
       
   155 		EKeyRepeat,
       
   156 		
       
   157 		/**
       
   158 		Represents a case open event.
       
   159 		
       
   160 		The meaning of a case is hardware specific.
       
   161 		*/
       
   162 		ECaseOpen,
       
   163 		
       
   164 		/**
       
   165         Represents a case close event.
       
   166 		
       
   167 		The meaning of a case is hardware specific.
       
   168 		*/
       
   169 		ECaseClose,
       
   170 
       
   171 		/**
       
   172 		@prototype
       
   173         Represents a 3D pointer entering the detection volume event.
       
   174 		
       
   175 		This is typically used to represent a pointing device
       
   176 		coming into detection range of a sensitive screen.
       
   177 		*/
       
   178 		EPointer3DInRange,
       
   179 
       
   180 		/**
       
   181 		@prototype
       
   182         Represents a 3D pointer leaving the detection volume event.
       
   183 		
       
   184 		This is typically used to represent a pointing device
       
   185 		leaving the detection range of a sensitive screen.
       
   186 		*/
       
   187 		EPointer3DOutOfRange,
       
   188 
       
   189 		/**
       
   190 		@prototype
       
   191         Represents a 3D pointer tilt changes only event.
       
   192 		
       
   193 		This is typically sent by a 3D pointer driver when it detects
       
   194 		a change in the pointer's polar coordinates (Theta or Phi).
       
   195 		*/
       
   196 		EPointer3DTilt,
       
   197 
       
   198 		/**
       
   199 		@prototype
       
   200         Represents a 3D pointer rotation only event.
       
   201 		
       
   202 		This is typically sent by a 3D pointer driver when it detects
       
   203 		a rotation of the pointing device (along ist main axis).
       
   204 		*/
       
   205 		EPointer3DRotation,
       
   206 
       
   207 		/**
       
   208 		@prototype
       
   209         Represents a general 3D pointer changes event.
       
   210 		
       
   211 		This is typically sent by a 3D pointer driver when it detects
       
   212 		a change in the pointer's linear and/or polar coordinates and/or rotation.
       
   213 		*/
       
   214 		EPointer3DTiltAndMove,
       
   215 
       
   216 		/**
       
   217 		@prototype
       
   218 		Reserved for a 3D pointing device button down event.
       
   219 		*/
       
   220 		EButton4Down,
       
   221 		
       
   222 		/**
       
   223 		@prototype
       
   224 		Reserved for a 3D pointing device button up event.
       
   225 		*/
       
   226 		EButton4Up,
       
   227 
       
   228 		/**
       
   229 		@prototype
       
   230 		Reserved for a 3D pointing device button down event.
       
   231 		*/
       
   232 		EButton5Down,
       
   233 		
       
   234 		/**
       
   235 		@prototype
       
   236 		Reserved for a 3D pointing device button up event.
       
   237 		*/
       
   238 		EButton5Up,
       
   239 
       
   240 		/**
       
   241 		@prototype
       
   242 		Reserved for a 3D pointing device button down event.
       
   243 		*/
       
   244 		EButton6Down,
       
   245 		
       
   246 		/**
       
   247 		@prototype
       
   248 		Reserved for a 3D pointing device button up event.
       
   249 		*/
       
   250 		EButton6Up,
       
   251 
       
   252 		/**
       
   253 		Represents a device restart event.
       
   254 		*/
       
   255 		ERestartSystem
       
   256 		};
       
   257 public:
       
   258 
       
   259     /**
       
   260     Default constructor
       
   261     */
       
   262 	inline TRawEvent()
       
   263 		{ *(TInt*)&iType=0; }
       
   264 		
       
   265 	/**
       
   266 	Gets the event type
       
   267 	
       
   268 	@return The event type.
       
   269 	*/	
       
   270 	inline TType Type() const
       
   271 		{return TType(iType);}
       
   272 
       
   273 	/**
       
   274 	Gets the device number (eg. screen number)
       
   275 
       
   276 	@return The device number.
       
   277 	*/
       
   278 	inline TInt DeviceNumber() const
       
   279 		{return TInt(iDeviceNumber-1);}
       
   280 
       
   281 	/**
       
   282 	Sets the device number (eg. screen number)
       
   283 
       
   284 	@param aDeviceNumber The device number
       
   285 	*/
       
   286 	inline void SetDeviceNumber(TInt aDeviceNumber)
       
   287 		{iDeviceNumber = TUint8(aDeviceNumber+1);}
       
   288 
       
   289 	IMPORT_C TPoint Pos() const;
       
   290 	IMPORT_C TInt ScanCode() const;
       
   291     IMPORT_C TInt Modifiers() const;
       
   292     
       
   293     /**
       
   294     Gets the Cartesian coordinates of the 3D pointer end that is closer to the screen.
       
   295     
       
   296     @return The Cartesian coordinates of the point defined by the end of the 3D pointing device that is closer to the screen.
       
   297     */
       
   298 	IMPORT_C TPoint3D Pos3D() const;
       
   299     
       
   300 
       
   301 	/**
       
   302     Gets the angular spherical polar coordinates of the 3D pointer end that is closer to the screen.
       
   303     
       
   304     @return The angular spherical polar coordinates of the point defined by the end of the 3D pointing device that is closer to the screen.
       
   305 	@see TAngle3D
       
   306 	*/
       
   307 	IMPORT_C TAngle3D Tilt() const;
       
   308 
       
   309 	/**
       
   310     Gets the rotation angle of 3D pointing device.
       
   311 
       
   312     Some 3D pointing devices support information regarding the angle formed between the physical and magnetical poles,
       
   313 	as obtaining when rotating the pen along its main axis.
       
   314 
       
   315     @return The rotation angle of the 3D pointing device.
       
   316     */
       
   317 	IMPORT_C TInt Rotation() const;
       
   318 
       
   319     /**
       
   320     Gets the tick count value associated with the event.
       
   321     
       
   322     Note that the interval between tick counts is
       
   323     hardware dependent.
       
   324     
       
   325     @return The tick count value
       
   326     */
       
   327 	inline TUint Ticks() const
       
   328 		{return iTicks;}
       
   329 	/**
       
   330 	Gets the information on which end of the pointing device is closer to the screen
       
   331 	
       
   332 	@return A Boolean indicating which end of the pointing device is closer to the screen.
       
   333 	*/	
       
   334 	inline TBool IsTip() const
       
   335 		{return TBool(iTip);}
       
   336 	
       
   337 	/**
       
   338 	Sets the information on which end of the pointing device is closer to the screen
       
   339 	
       
   340 	@param aTip A Boolean indicating which end of the pointing device is closer to the screen.
       
   341 	*/	
       
   342 	inline void SetTip(TBool aTip)
       
   343 		{iTip = TUint8(aTip);
       
   344 #ifdef BTRACE_TRAWEVENT	
       
   345 		BTraceContext4(BTrace::ERawEvent, BTrace::ESetTipEvent,(TUint32)aTip);
       
   346 #endif
       
   347 		}
       
   348 
       
   349 	IMPORT_C void Set(TType aType,TInt aScanCode);
       
   350 	IMPORT_C void Set(TType aType,TInt aX,TInt aY);
       
   351 	IMPORT_C void Set(TType aType);
       
   352 
       
   353 	IMPORT_C void Set(TType aType,TInt aX,TInt aY,TInt aZ);
       
   354 	IMPORT_C void Set(TType aType,TInt aX,TInt aY,TInt aZ,TInt aPhi,TInt aTheta,TInt aAlpha);
       
   355 
       
   356 	IMPORT_C void SetTilt(TType aType,TInt aPhi,TInt aTheta);
       
   357 	IMPORT_C void SetRotation(TType aType,TInt aAlpha);
       
   358 
       
   359 	/**
       
   360 	@return the pointer number of the the event
       
   361 	*/
       
   362 	inline TUint8 PointerNumber() const
       
   363 		{
       
   364 		return iPointerNumber;
       
   365 		}
       
   366 
       
   367 
       
   368 	/**
       
   369 	The pointer number for the event is set
       
   370 	The pointer  number should be more or equal 0 and should be less than HALData::EPointerMaxPointers,
       
   371 	otherwise WSERV would ignore the event,ie 	0 <= aPointerNumber < HALData::EPointerMaxPointers 
       
   372 	@param	aPointerNumber
       
   373 	Error conditions: None.
       
   374 	*/
       
   375 	inline void SetPointerNumber(const TUint8 aPointerNumber)
       
   376 		{
       
   377 		iPointerNumber=aPointerNumber;	
       
   378 #ifdef BTRACE_TRAWEVENT	
       
   379 		BTraceContext4(BTrace::ERawEvent, BTrace::ESetPointerNumberEvent,(TUint32)aPointerNumber);
       
   380 #endif
       
   381 		}
       
   382 
       
   383     /**
       
   384 	Initialises the event with the supplied information	
       
   385 	@param	aType	The event type.
       
   386 	@param	aX		The X position.
       
   387 	@param	aY		The Y position.
       
   388 	@param	aZ		The Z position.
       
   389 	@param  aPointerNumber   The pointer number for the event
       
   390 	*/
       
   391 	IMPORT_C void Set (TType aType, TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber);
       
   392 	
       
   393 protected:
       
   394 	TUint8 iType;
       
   395 	TUint8 iTip;	/**< Indicates whether the tip or head of pointing device is closer to screen.*/
       
   396 	TUint8 iPointerNumber; //
       
   397 	TUint8 iDeviceNumber;
       
   398 	TUint iTicks;
       
   399 	union
       
   400 		{
       
   401 		struct {TInt x;TInt y;} pos;
       
   402 		struct {TInt x;TInt y;TInt z;TInt phi;TInt theta;TInt alpha;} pos3D;
       
   403 		TInt scanCode;
       
   404 		TInt modifiers;
       
   405 		} iU;
       
   406 	};
       
   407 
       
   408 
       
   409 
       
   410 
       
   411 /**
       
   412 @publishedAll
       
   413 @released
       
   414 
       
   415 Encapsulates a hardware event object as a descriptor (package buffer) for
       
   416 the purpose of data transfer.
       
   417 */
       
   418 class TRawEventBuf : public TPckgBuf<TRawEvent>
       
   419 	{
       
   420 public:
       
   421 
       
   422     /**
       
   423     Gets the hardware event object from the package buffer.
       
   424     
       
   425     @return The hardware event object.
       
   426     */
       
   427 	inline TRawEvent &Event() const {return(*((TRawEvent *)&iBuf[0]));}
       
   428 	};
       
   429 
       
   430 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
   431 #include <e32event_private.h>
       
   432 #endif
       
   433 
       
   434 #endif
       
   435