os/graphics/windowing/windowserver/nga/SERVER/KEYBEMUL.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1996-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 "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 // Emulte key presses on pointer events
    15 // 
    16 //
    17 
    18 #include <e32std.h>
    19 #include <e32hal.h>
    20 #include "server.h"
    21 #include "EVENT.H"
    22 
    23 TInt WsKeyboardEmulator::iCurrentKeyDown;
    24 TBool WsKeyboardEmulator::iKeyIsDown=EFalse;
    25 
    26 void WsKeyboardEmulator::RawKeyEvent(TRawEvent::TType aType)
    27 	{
    28 	if (aType==TRawEvent::EKeyUp)
    29 		iKeyIsDown=EFalse;
    30 	else
    31 		iKeyIsDown=ETrue;
    32 	TRawEvent rawEvent;
    33 	rawEvent.Set(aType,iCurrentKeyDown);
    34 	TWindowServerEvent::ProcessRawEvent(rawEvent);
    35 	}
    36 
    37 TBool WsKeyboardEmulator::PointerEvent(TPointerEvent::TType aPointerEventType,const TPoint &aPoint, TDblQue<TPointerKeyList> *aKeyList)
    38 	{
    39 	if (iKeyIsDown && (aPointerEventType==TPointerEvent::EButton1Up))
    40 		RawKeyEvent(TRawEvent::EKeyUp);
    41 	else if (!aKeyList)
    42 		return(EFalse);
    43 	else
    44 		{
    45 		TPointerKeyList *pkl=NULL;
    46 		for(TDblQueIter<TPointerKeyList> iter(*aKeyList);(pkl=iter++)!=NULL;)
    47 			if (pkl->iRect.Contains(aPoint))
    48 				break;
    49 		if (iKeyIsDown && 
    50 			(aPointerEventType==TPointerEvent::EDrag || 
    51 			 aPointerEventType==TPointerEvent::EEnterHighPressure ||
    52 			 aPointerEventType==TPointerEvent::EExitHighPressure) && 
    53 			(!pkl || iCurrentKeyDown!=pkl->iScanCode))
    54 			{
    55 			RawKeyEvent(TRawEvent::EKeyUp);
    56 			}
    57 		else if (pkl)
    58 			{
    59 			if (aPointerEventType==TPointerEvent::EButton1Down ||
    60 			    (aPointerEventType==TPointerEvent::ESwitchOn && pkl->iActivatedByPointerSwitchOn))
    61 				{
    62 				if (iKeyIsDown)
    63 					RawKeyEvent(TRawEvent::EKeyUp);
    64 				iCurrentKeyDown=pkl->iScanCode;
    65 				RawKeyEvent(TRawEvent::EKeyDown);
    66 				if (aPointerEventType==TPointerEvent::ESwitchOn)
    67 					RawKeyEvent(TRawEvent::EKeyUp);
    68 				}
    69 			}
    70 		else
    71 			return(EFalse);
    72 		}
    73 	return(ETrue);
    74 	}
    75