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