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