sl@0
|
1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Emulte key presses on pointer events
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32std.h>
|
sl@0
|
19 |
#include <e32hal.h>
|
sl@0
|
20 |
#include "server.h"
|
sl@0
|
21 |
#include "EVENT.H"
|
sl@0
|
22 |
|
sl@0
|
23 |
TInt WsKeyboardEmulator::iCurrentKeyDown;
|
sl@0
|
24 |
TBool WsKeyboardEmulator::iKeyIsDown=EFalse;
|
sl@0
|
25 |
|
sl@0
|
26 |
void WsKeyboardEmulator::RawKeyEvent(TRawEvent::TType aType)
|
sl@0
|
27 |
{
|
sl@0
|
28 |
if (aType==TRawEvent::EKeyUp)
|
sl@0
|
29 |
iKeyIsDown=EFalse;
|
sl@0
|
30 |
else
|
sl@0
|
31 |
iKeyIsDown=ETrue;
|
sl@0
|
32 |
TRawEvent rawEvent;
|
sl@0
|
33 |
rawEvent.Set(aType,iCurrentKeyDown);
|
sl@0
|
34 |
TWindowServerEvent::ProcessRawEvent(rawEvent);
|
sl@0
|
35 |
}
|
sl@0
|
36 |
|
sl@0
|
37 |
TBool WsKeyboardEmulator::PointerEvent(TPointerEvent::TType aPointerEventType,const TPoint &aPoint, TDblQue<TPointerKeyList> *aKeyList)
|
sl@0
|
38 |
{
|
sl@0
|
39 |
if (iKeyIsDown && (aPointerEventType==TPointerEvent::EButton1Up))
|
sl@0
|
40 |
RawKeyEvent(TRawEvent::EKeyUp);
|
sl@0
|
41 |
else if (!aKeyList)
|
sl@0
|
42 |
return(EFalse);
|
sl@0
|
43 |
else
|
sl@0
|
44 |
{
|
sl@0
|
45 |
TPointerKeyList *pkl=NULL;
|
sl@0
|
46 |
for(TDblQueIter<TPointerKeyList> iter(*aKeyList);(pkl=iter++)!=NULL;)
|
sl@0
|
47 |
if (pkl->iRect.Contains(aPoint))
|
sl@0
|
48 |
break;
|
sl@0
|
49 |
if (iKeyIsDown &&
|
sl@0
|
50 |
(aPointerEventType==TPointerEvent::EDrag ||
|
sl@0
|
51 |
aPointerEventType==TPointerEvent::EEnterHighPressure ||
|
sl@0
|
52 |
aPointerEventType==TPointerEvent::EExitHighPressure) &&
|
sl@0
|
53 |
(!pkl || iCurrentKeyDown!=pkl->iScanCode))
|
sl@0
|
54 |
{
|
sl@0
|
55 |
RawKeyEvent(TRawEvent::EKeyUp);
|
sl@0
|
56 |
}
|
sl@0
|
57 |
else if (pkl)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
if (aPointerEventType==TPointerEvent::EButton1Down ||
|
sl@0
|
60 |
(aPointerEventType==TPointerEvent::ESwitchOn && pkl->iActivatedByPointerSwitchOn))
|
sl@0
|
61 |
{
|
sl@0
|
62 |
if (iKeyIsDown)
|
sl@0
|
63 |
RawKeyEvent(TRawEvent::EKeyUp);
|
sl@0
|
64 |
iCurrentKeyDown=pkl->iScanCode;
|
sl@0
|
65 |
RawKeyEvent(TRawEvent::EKeyDown);
|
sl@0
|
66 |
if (aPointerEventType==TPointerEvent::ESwitchOn)
|
sl@0
|
67 |
RawKeyEvent(TRawEvent::EKeyUp);
|
sl@0
|
68 |
}
|
sl@0
|
69 |
}
|
sl@0
|
70 |
else
|
sl@0
|
71 |
return(EFalse);
|
sl@0
|
72 |
}
|
sl@0
|
73 |
return(ETrue);
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|