windowing/windowserver/inc/Graphics/wskeyrouter.h
changeset 188 1b081cb0800b
equal deleted inserted replaced
187:9f66f99ee56f 188:1b081cb0800b
       
     1 // Copyright (c) 2010 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 "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 // Key Event Routing Plug-in API
       
    15 
       
    16 /**
       
    17 @file
       
    18 @publishedPartner
       
    19 @prototype
       
    20 */
       
    21 
       
    22 #ifndef WSKEYROUTER_H
       
    23 #define WSKEYROUTER_H
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <w32std.h>
       
    27 
       
    28 /**
       
    29 Interface Uid
       
    30 */
       
    31 const TUid KKeyRouterPluginUid = { 0x102872e1 };
       
    32 
       
    33 /**
       
    34 Key Capture Type
       
    35 */
       
    36 enum TKeyCaptureType
       
    37 	{
       
    38 	ECaptureTypeKey = 0,
       
    39 	ECaptureTypeLongKey = 1,
       
    40 	ECaptureTypeKeyUpDown = 2
       
    41 	};
       
    42 
       
    43 /**
       
    44 Key Capture Request
       
    45 */
       
    46 struct TKeyCaptureRequest
       
    47 	{
       
    48 	/** Capture type */
       
    49 	TKeyCaptureType	iType;
       
    50 
       
    51 	/** Keycode or scancode to be captured */
       
    52 	TUint			iInputCode;
       
    53 
       
    54 	/** Output keycode or scancode. When iInputCode is captured, RouteKey()
       
    55 		places iOutputCode in TKeyEventRouterOutput.iKeyEvent */
       
    56 	TUint			iOutputCode;
       
    57 
       
    58 	/** Bitmask of modifier keys of interest. Key events are captured only
       
    59 		when the modifier keys specified by iModifierMask are in the states
       
    60 		specified by iModifiers */
       
    61 	TUint			iModifierMask;
       
    62 
       
    63 	/** Bitmask of modifier key states */
       
    64 	TUint			iModifiers;
       
    65 
       
    66 	/** Opaque handle for this request */
       
    67 	TAny*			iHandle;
       
    68 
       
    69 	/** Opaque handle to window group through which request was made */
       
    70 	TAny*			iWindowGroup;
       
    71 
       
    72 	/** Identifier of the window group through which request was made */
       
    73 	TInt			iWindowGroupId;
       
    74 
       
    75 	/** UID of application that made the capture request */
       
    76 	TUid			iAppUid;
       
    77 
       
    78 	/** Capture priority for this request. If more than one window group has
       
    79 		requested capture for the same key event, the one with the highest
       
    80 		priority will capture it (unless overridden by application specific
       
    81 		rules). */
       
    82 	TInt			iPriority;
       
    83 
       
    84 	/** Reserved for future use */
       
    85 	TInt			iReserved[2];
       
    86 	};
       
    87 
       
    88 /**
       
    89 Input parameters for RouteKey()
       
    90 */
       
    91 struct TKeyEventRouterInput
       
    92 	{
       
    93 	inline TKeyEventRouterInput(TKeyCaptureType aType, const TKeyEvent& aKeyEvent, TAny* aFocusWindowGroup, TUid aFocusAppUid);
       
    94 
       
    95 	/** Capture type */
       
    96 	TKeyCaptureType		iType;
       
    97 
       
    98 	/** Input key event */
       
    99 	TKeyEvent			iKeyEvent;
       
   100 
       
   101 	/** Opaque handle to current focussed window group */
       
   102 	TAny*				iFocusWindowGroup;
       
   103 
       
   104 	/** UID of client application with current focussed window group */
       
   105 	TUid				iFocusAppUid;
       
   106 
       
   107 	/** Reserved for future use */
       
   108 	TInt				iReserved[2];
       
   109 	};
       
   110 
       
   111 /**
       
   112 Result codes for RouteKey()
       
   113 */
       
   114 enum TKeyEventRouterResult
       
   115 	{
       
   116 	/** Key routed, no capture */
       
   117 	ERouted = 0,
       
   118 
       
   119 	/** Key captured and routed */
       
   120 	ECaptured = 1,
       
   121 
       
   122 	/** Key consumed, do not deliver event */
       
   123 	EConsumed = 2
       
   124 	};
       
   125 
       
   126 /**
       
   127 Output parameters for RouteKey()
       
   128 */
       
   129 struct TKeyEventRouterOutput
       
   130 	{
       
   131 	/** Result code */
       
   132 	TKeyEventRouterResult	iResult;
       
   133 
       
   134 	/** Output key event as translated by plug-in. Key code may be set by
       
   135 		RWindowGroup::CaptureLongKey() via TKeyCaptureRequest.iOutputCode **/
       
   136 	TKeyEvent				iKeyEvent;
       
   137 
       
   138 	/** Opaque handle to destination window group or NULL if captured by WServ
       
   139 		(hotkey). Plug-in must set this to either the window group from the
       
   140 		matching capture request or to TKeyEventRouterInput.iFocusWindowGroup */
       
   141 	TAny*					iWindowGroup;
       
   142 
       
   143 	/** Opaque handle from matching capture request or NULL if none */
       
   144 	TAny*					iCaptureHandle;
       
   145 
       
   146 	/** Reserved for future use */
       
   147 	TInt					iReserved[2];
       
   148 	};
       
   149 
       
   150 /**
       
   151 Key Event Router Interface
       
   152 
       
   153 This class is implemented by a plug-in DLL in order to perform customised
       
   154 routing of window server key events.
       
   155 
       
   156 The Key Event Routing plug-in is a polymorphic DLL that implements the
       
   157 CKeyEventRouter interface. Its UID1 and UID2 must be KDynamicLibraryUid and
       
   158 KKeyRouterPluginUid respectively. UID3 identifies a particular implementation
       
   159 of the plug-in. The first and only exported function should create and return
       
   160 an object of the CKeyEventRouter sub-class.
       
   161 */
       
   162 class CKeyEventRouter : public CBase
       
   163 	{
       
   164 public:
       
   165 	/**
       
   166 	Create and return an instance of CKeyEventRouter
       
   167 
       
   168 	@return	Pointer to new router instance
       
   169 	*/
       
   170 	IMPORT_C static CKeyEventRouter* NewL();
       
   171 
       
   172 	/**
       
   173 	Add a new key capture request
       
   174 
       
   175 	@param	aRequest	Capture request details
       
   176 	*/
       
   177 	virtual void AddCaptureKeyL(const TKeyCaptureRequest& aRequest) = 0;
       
   178 	   
       
   179 	/**
       
   180 	Update an existing key capture request
       
   181 
       
   182 	@param	aRequest	Updated capture request details
       
   183 	*/
       
   184 	virtual void UpdateCaptureKeyL(const TKeyCaptureRequest& aRequest) = 0;
       
   185 
       
   186 	/**
       
   187 	Cancel a key capture request
       
   188 
       
   189 	@param	aType		Capture type
       
   190 	@param	aHandle		Opaque handle of request to be cancelled
       
   191 	*/
       
   192 	virtual void CancelCaptureKey(TKeyCaptureType aType, TAny* aHandle) = 0;
       
   193 
       
   194 	/**
       
   195 	Route the key event described by aInput and return its destination
       
   196 	in iOutput.
       
   197 
       
   198 	@param	aInput		Input data with key event to be routed
       
   199 	@param	aOutput		Output key event and routing results
       
   200 	*/
       
   201 	virtual void RouteKey(const TKeyEventRouterInput& aInput,
       
   202 						  TKeyEventRouterOutput& aOutput) = 0;
       
   203 
       
   204 	/**
       
   205 	Reserved for future use
       
   206 	*/
       
   207 private:
       
   208 	virtual void Reserved1() {};
       
   209 	virtual void Reserved2() {};
       
   210 	};
       
   211 
       
   212 inline TKeyEventRouterInput::TKeyEventRouterInput(TKeyCaptureType aType, const TKeyEvent& aKeyEvent, TAny* aFocusWindowGroup, TUid aFocusAppUid) : iType(aType), iKeyEvent(aKeyEvent), iFocusWindowGroup(aFocusWindowGroup), iFocusAppUid(aFocusAppUid)
       
   213 	{
       
   214 	}
       
   215 
       
   216 #endif // WSKEYROUTER_H