sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Emulte key presses on pointer events sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "server.h" sl@0: #include "EVENT.H" sl@0: sl@0: TInt WsKeyboardEmulator::iCurrentKeyDown; sl@0: TBool WsKeyboardEmulator::iKeyIsDown=EFalse; sl@0: sl@0: void WsKeyboardEmulator::RawKeyEvent(TRawEvent::TType aType) sl@0: { sl@0: if (aType==TRawEvent::EKeyUp) sl@0: iKeyIsDown=EFalse; sl@0: else sl@0: iKeyIsDown=ETrue; sl@0: TRawEvent rawEvent; sl@0: rawEvent.Set(aType,iCurrentKeyDown); sl@0: TWindowServerEvent::ProcessRawEvent(rawEvent); sl@0: } sl@0: sl@0: TBool WsKeyboardEmulator::PointerEvent(TPointerEvent::TType aPointerEventType,const TPoint &aPoint, TDblQue *aKeyList) sl@0: { sl@0: if (iKeyIsDown && (aPointerEventType==TPointerEvent::EButton1Up)) sl@0: RawKeyEvent(TRawEvent::EKeyUp); sl@0: else if (!aKeyList) sl@0: return(EFalse); sl@0: else sl@0: { sl@0: TPointerKeyList *pkl=NULL; sl@0: for(TDblQueIter iter(*aKeyList);(pkl=iter++)!=NULL;) sl@0: if (pkl->iRect.Contains(aPoint)) sl@0: break; sl@0: if (iKeyIsDown && aPointerEventType==TPointerEvent::EDrag && (!pkl || iCurrentKeyDown!=pkl->iScanCode)) sl@0: RawKeyEvent(TRawEvent::EKeyUp); sl@0: else if (pkl) sl@0: { sl@0: if (aPointerEventType==TPointerEvent::EButton1Down || sl@0: (aPointerEventType==TPointerEvent::ESwitchOn && pkl->iActivatedByPointerSwitchOn)) sl@0: { sl@0: if (iKeyIsDown) sl@0: RawKeyEvent(TRawEvent::EKeyUp); sl@0: iCurrentKeyDown=pkl->iScanCode; sl@0: RawKeyEvent(TRawEvent::EKeyDown); sl@0: if (aPointerEventType==TPointerEvent::ESwitchOn) sl@0: RawKeyEvent(TRawEvent::EKeyUp); sl@0: } sl@0: } sl@0: else sl@0: return(EFalse); sl@0: } sl@0: return(ETrue); sl@0: } sl@0: