271
|
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 the License "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 |
// e32test\window\d_keyrepeat.cpp
|
|
15 |
// LDD for testing class TRawEvent kernel side keyrepeat entries
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include <kernel/kernel.h>
|
|
20 |
|
|
21 |
#include "d_keyrepeat.h"
|
|
22 |
|
|
23 |
class DKLDDFactory : public DLogicalDevice
|
|
24 |
//
|
|
25 |
// Test LDD factory
|
|
26 |
//
|
|
27 |
{
|
|
28 |
public:
|
|
29 |
DKLDDFactory();
|
|
30 |
virtual TInt Install(); //overriding pure virtual
|
|
31 |
virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual
|
|
32 |
virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual
|
|
33 |
};
|
|
34 |
|
|
35 |
class DKLDDChannel : public DLogicalChannelBase
|
|
36 |
//
|
|
37 |
// Test logical channel
|
|
38 |
//
|
|
39 |
{
|
|
40 |
public:
|
|
41 |
virtual ~DKLDDChannel();
|
|
42 |
protected:
|
|
43 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
|
|
44 |
virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
|
|
45 |
public:
|
|
46 |
RKeyEvent iStoredKeyEvent;
|
|
47 |
TRawEvent iStoredEvent;
|
|
48 |
};
|
|
49 |
|
|
50 |
|
|
51 |
DECLARE_STANDARD_LDD()
|
|
52 |
{
|
|
53 |
return new DKLDDFactory;
|
|
54 |
}
|
|
55 |
|
|
56 |
//
|
|
57 |
// Constructor
|
|
58 |
//
|
|
59 |
DKLDDFactory::DKLDDFactory()
|
|
60 |
{
|
|
61 |
}
|
|
62 |
|
|
63 |
TInt DKLDDFactory::Create(DLogicalChannelBase*& aChannel)
|
|
64 |
{
|
|
65 |
//
|
|
66 |
// Create new channel
|
|
67 |
//
|
|
68 |
aChannel=new DKLDDChannel;
|
|
69 |
return aChannel?KErrNone:KErrNoMemory;
|
|
70 |
}
|
|
71 |
|
|
72 |
TInt DKLDDFactory::Install()
|
|
73 |
//
|
|
74 |
// Install the LDD - overriding pure virtual
|
|
75 |
{
|
|
76 |
return SetName(&KLddName);
|
|
77 |
}
|
|
78 |
|
|
79 |
void DKLDDFactory::GetCaps(TDes8& /*aDes*/) const
|
|
80 |
//
|
|
81 |
// Get capabilities - overriding pure virtual
|
|
82 |
//
|
|
83 |
{
|
|
84 |
}
|
|
85 |
|
|
86 |
TInt DKLDDChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
|
|
87 |
//
|
|
88 |
// Create channel
|
|
89 |
//
|
|
90 |
{
|
|
91 |
return KErrNone;
|
|
92 |
}
|
|
93 |
|
|
94 |
DKLDDChannel::~DKLDDChannel()
|
|
95 |
//
|
|
96 |
// Destructor
|
|
97 |
//
|
|
98 |
{
|
|
99 |
}
|
|
100 |
|
|
101 |
RKeyEvent::RKeyEvent()
|
|
102 |
//
|
|
103 |
// default constructor
|
|
104 |
//
|
|
105 |
{
|
|
106 |
}
|
|
107 |
|
|
108 |
TInt DKLDDChannel::Request(TInt aReqNo, TAny* a1, TAny* /*a2*/)
|
|
109 |
{
|
|
110 |
TInt r=KErrNone;
|
|
111 |
TInt repeats=0;
|
|
112 |
|
|
113 |
switch(aReqNo)
|
|
114 |
{
|
|
115 |
case RTestKeyRepeatLdd::ESetRepeat:
|
|
116 |
kumemget(&iStoredKeyEvent,a1,sizeof(RKeyEvent));
|
|
117 |
iStoredEvent.SetRepeat(TRawEvent::EKeyRepeat, iStoredKeyEvent.iKey, iStoredKeyEvent.iRepeatCount);
|
|
118 |
NKern::ThreadEnterCS();
|
|
119 |
r=Kern::AddEvent(iStoredEvent);
|
|
120 |
NKern::ThreadLeaveCS();
|
|
121 |
break;
|
|
122 |
case RTestKeyRepeatLdd::ERepeats:
|
|
123 |
repeats = iStoredEvent.Repeats();
|
|
124 |
if (repeats!=iStoredKeyEvent.iRepeatCount)
|
|
125 |
{
|
|
126 |
r=KErrGeneral;
|
|
127 |
}
|
|
128 |
break;
|
|
129 |
|
|
130 |
default:
|
|
131 |
r=KErrNotSupported;
|
|
132 |
break;
|
|
133 |
}
|
|
134 |
return r;
|
|
135 |
}
|
|
136 |
|
|
137 |
|
|
138 |
|