44
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0""
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: peninput VKB data manager
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <aknfeppeninputenums.h>
|
|
19 |
#include <peninputlayoutbasecontrol.h>
|
|
20 |
#include <peninputcommonlayoutglobalenum.h>
|
|
21 |
#include <peninputdataconverter.h>
|
|
22 |
#include <peninputlayoutcontext.h>
|
|
23 |
#include <peninputlayoutvkb.h>
|
|
24 |
#include <PtiEngine.h>
|
|
25 |
|
|
26 |
#include "PeninputVkbKrDbg.h"
|
|
27 |
#include "PeninputVkbKr.hrh"
|
|
28 |
#include "PeninputVkbKrUiStateStandby.h"
|
|
29 |
|
|
30 |
const TInt KSingleCharacter = 1;
|
|
31 |
|
|
32 |
// ---------------------------------------------------------------------------
|
|
33 |
// Constructors & Destructors
|
|
34 |
// ---------------------------------------------------------------------------
|
|
35 |
//
|
|
36 |
|
|
37 |
CPeninputVkbKrUiStateStandby* CPeninputVkbKrUiStateStandby::NewLC(
|
|
38 |
MPeninputUiStateMgr* aUiStateMgr,
|
|
39 |
MPeninputLayoutContext* aContext,
|
|
40 |
CPtiEngine& aPtiEngine)
|
|
41 |
{
|
|
42 |
CPeninputVkbKrUiStateStandby* self =
|
|
43 |
new (ELeave) CPeninputVkbKrUiStateStandby(aUiStateMgr,aContext,aPtiEngine);
|
|
44 |
CleanupStack::PushL(self);
|
|
45 |
self->ConstructL();
|
|
46 |
return self;
|
|
47 |
}
|
|
48 |
|
|
49 |
CPeninputVkbKrUiStateStandby* CPeninputVkbKrUiStateStandby::NewL(
|
|
50 |
MPeninputUiStateMgr* aUiStateMgr,
|
|
51 |
MPeninputLayoutContext* aContext,
|
|
52 |
CPtiEngine& aPtiEngine)
|
|
53 |
{
|
|
54 |
CPeninputVkbKrUiStateStandby* self =
|
|
55 |
CPeninputVkbKrUiStateStandby::NewLC(aUiStateMgr,aContext,aPtiEngine);
|
|
56 |
CleanupStack::Pop(); // self;
|
|
57 |
return self;
|
|
58 |
}
|
|
59 |
|
|
60 |
CPeninputVkbKrUiStateStandby::CPeninputVkbKrUiStateStandby(
|
|
61 |
MPeninputUiStateMgr* aUiStateMgr,
|
|
62 |
MPeninputLayoutContext* aContext,
|
|
63 |
CPtiEngine& aPtiEngine)
|
|
64 |
: CPeninputVkbKrUiStateBase(aUiStateMgr,aContext,aPtiEngine),
|
|
65 |
iTextCommited(EFalse)
|
|
66 |
{
|
|
67 |
// No implementation required
|
|
68 |
}
|
|
69 |
|
|
70 |
void CPeninputVkbKrUiStateStandby::ConstructL()
|
|
71 |
{
|
|
72 |
}
|
|
73 |
|
|
74 |
CPeninputVkbKrUiStateStandby::~CPeninputVkbKrUiStateStandby()
|
|
75 |
{
|
|
76 |
}
|
|
77 |
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
// from CPeninputVkbKrUiStateBase
|
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
|
|
83 |
TBool CPeninputVkbKrUiStateStandby::HandleKeyEventL(
|
|
84 |
const TRawEvent& aData)
|
|
85 |
{
|
|
86 |
LOG1("Vkb.UiState.Standby.HandleKeyEventL %d",aData.ScanCode());
|
|
87 |
TBool ret(EFalse);
|
|
88 |
return ret;
|
|
89 |
}
|
|
90 |
|
|
91 |
TBool CPeninputVkbKrUiStateStandby::HandleControlEvent(
|
|
92 |
TInt aEventType,
|
|
93 |
const TDesC& aEventData)
|
|
94 |
{
|
|
95 |
TBool ret(EFalse);
|
|
96 |
TBool clearAutomata(ETrue);
|
|
97 |
switch ( aEventType )
|
|
98 |
{
|
|
99 |
case EEventButtonDown:
|
|
100 |
case EEventButtonUp:
|
|
101 |
case EEventVirtualKeyDown:
|
|
102 |
clearAutomata=EFalse;
|
|
103 |
break;
|
|
104 |
case EEventVirtualKeyUp:
|
|
105 |
ret=HandleVkbEvent( aEventType, aEventData );
|
|
106 |
clearAutomata=EFalse;
|
|
107 |
break;
|
|
108 |
case EPeninputLayoutEventBack:
|
|
109 |
ret=HandleBackEvent( aEventType, aEventData );
|
|
110 |
clearAutomata=EFalse;
|
|
111 |
break;
|
|
112 |
case EPeninputLayoutEventLeftArrow:
|
|
113 |
case EPeninputLayoutEventRightArrow:
|
|
114 |
SendKey( aEventData );
|
|
115 |
break;
|
|
116 |
case EPeninputLayoutEventTab:
|
|
117 |
ret=HandleTabEvent( aEventType, aEventData );
|
|
118 |
break;
|
|
119 |
case EPeninputLayoutEventEnter:
|
|
120 |
case EPeninputLayoutEventSpace:
|
|
121 |
ret=HandleEnterSpaceEvent( aEventType, aEventData );
|
|
122 |
break;
|
|
123 |
case EPeninputLayoutEventClose:
|
|
124 |
default:
|
|
125 |
break;
|
|
126 |
}
|
|
127 |
LOG2(
|
|
128 |
"Vkb.UiState.Standby.HandleControlEvent %d - %d",
|
|
129 |
aEventType,
|
|
130 |
ret);
|
|
131 |
|
|
132 |
if (clearAutomata)
|
|
133 |
{
|
|
134 |
LOG("Vkb.UiState.Standby.HandleControlEvent CLEAR AUTOMATA !!");
|
|
135 |
iPtiEngine.ClearCurrentWord();
|
|
136 |
}
|
|
137 |
|
|
138 |
return ret;
|
|
139 |
}
|
|
140 |
|
|
141 |
void CPeninputVkbKrUiStateStandby::KeyTimerExpired()
|
|
142 |
{
|
|
143 |
//TPtrC eventData(iPtiEngine.CurrentWord());
|
|
144 |
//SendKey( eventData );
|
|
145 |
iTextCommited=ETrue;
|
|
146 |
}
|
|
147 |
|
|
148 |
void CPeninputVkbKrUiStateStandby::LastWordInSelectionList()
|
|
149 |
{
|
|
150 |
|
|
151 |
}
|
|
152 |
|
|
153 |
void CPeninputVkbKrUiStateStandby::FirstWordInSelectionList()
|
|
154 |
{
|
|
155 |
|
|
156 |
}
|
|
157 |
|
|
158 |
// ---------------------------------------------------------------------------
|
|
159 |
// Internal use
|
|
160 |
// ---------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
|
|
163 |
TBool CPeninputVkbKrUiStateStandby::HandleVkbEvent(
|
|
164 |
TInt /*aEventType*/,
|
|
165 |
const TDesC& aEventData )
|
|
166 |
{
|
|
167 |
TBool ret(EFalse);
|
|
168 |
if (IsKoreanRange())
|
|
169 |
{
|
|
170 |
ret=HandleKoreanKey(aEventData);
|
|
171 |
}
|
|
172 |
|
|
173 |
if (IsKoreanShiftLayout())
|
|
174 |
{
|
|
175 |
iContext->SendEventToWindow(EPeninputLayoutEventShift,NULL);
|
|
176 |
}
|
|
177 |
|
|
178 |
if (!ret)
|
|
179 |
{
|
|
180 |
iPtiEngine.ClearCurrentWord();
|
|
181 |
ret=SendKey(aEventData);
|
|
182 |
}
|
|
183 |
|
|
184 |
return ret;
|
|
185 |
}
|
|
186 |
|
|
187 |
// --------------------------------------------------------------------------
|
|
188 |
// CPeninputUiStateVkbStandby::HandleBackEvent
|
|
189 |
// (other items were commented in a header)
|
|
190 |
// --------------------------------------------------------------------------
|
|
191 |
//
|
|
192 |
TBool CPeninputVkbKrUiStateStandby::HandleBackEvent(
|
|
193 |
TInt /*aEventType*/,
|
|
194 |
const TDesC& aEventData )
|
|
195 |
{
|
|
196 |
TBool ret(EFalse);
|
|
197 |
if (IsKoreanRange())
|
|
198 |
{
|
|
199 |
ret=HandleKoreanKey(aEventData);
|
|
200 |
}
|
|
201 |
|
|
202 |
if (!ret)
|
|
203 |
{
|
|
204 |
iPtiEngine.ClearCurrentWord();
|
|
205 |
ret=SendKey(aEventData);
|
|
206 |
}
|
|
207 |
return ret;
|
|
208 |
}
|
|
209 |
|
|
210 |
TBool CPeninputVkbKrUiStateStandby::HandleEnterSpaceEvent(
|
|
211 |
TInt /*aEventType*/,
|
|
212 |
const TDesC& aEventData )
|
|
213 |
{
|
|
214 |
return SendKey( aEventData );
|
|
215 |
}
|
|
216 |
|
|
217 |
TBool CPeninputVkbKrUiStateStandby::HandleTabEvent(
|
|
218 |
TInt /*aEventType*/,
|
|
219 |
const TDesC& aEventData )
|
|
220 |
{
|
|
221 |
SendKey( aEventData );
|
|
222 |
return EFalse;
|
|
223 |
}
|
|
224 |
|
|
225 |
TBool CPeninputVkbKrUiStateStandby::IsKoreanRange()
|
|
226 |
{
|
|
227 |
TInt range = CPeninputDataConverter::AnyToInt(
|
|
228 |
iContext->RequestData(EPeninputDataTypeCurrentRange));
|
|
229 |
return range==ERangeNative;
|
|
230 |
}
|
|
231 |
|
|
232 |
TBool CPeninputVkbKrUiStateStandby::IsKoreanShiftLayout()
|
|
233 |
{
|
|
234 |
TInt vkbLayout = CPeninputDataConverter::AnyToInt(
|
|
235 |
iContext->RequestData(EPeninputDataTypeVkbLayout));
|
|
236 |
return vkbLayout==EPeninputVkbLayoutNativeCharShift;
|
|
237 |
}
|
|
238 |
|
|
239 |
TInt CPeninputVkbKrUiStateStandby::GetVkbLayout()
|
|
240 |
{
|
|
241 |
TInt layout = CPeninputDataConverter::AnyToInt(
|
|
242 |
iContext->RequestData(EPeninputDataTypeVkbLayout));
|
|
243 |
return layout;
|
|
244 |
}
|
|
245 |
|
|
246 |
TBool CPeninputVkbKrUiStateStandby::HandleKoreanKey(const TDesC& aEventData)
|
|
247 |
{
|
|
248 |
TBool ret(EFalse);
|
|
249 |
|
|
250 |
TUint16 keyCodeOrig;
|
|
251 |
TUint16 keyCodePti;
|
|
252 |
if (aEventData.Length()>1)
|
|
253 |
{
|
|
254 |
TVirtualKeyEventData* data = (TVirtualKeyEventData*)aEventData.Ptr();
|
|
255 |
|
|
256 |
__ASSERT_ALWAYS(data->iKeyData.Length()==1,User::Panic(_L("Multiple Key"),__LINE__));
|
|
257 |
|
|
258 |
if (!(0x3130<=data->iKey->KeyCode()&&data->iKey->KeyCode()<=0x318F))
|
|
259 |
{
|
|
260 |
return EFalse;
|
|
261 |
}
|
|
262 |
keyCodeOrig=data->iKey->ScanCode();
|
|
263 |
}
|
|
264 |
else
|
|
265 |
{
|
|
266 |
keyCodeOrig=*(aEventData.Ptr());
|
|
267 |
}
|
|
268 |
|
|
269 |
TBool latin(EFalse);
|
|
270 |
keyCodePti=keyCodeOrig;
|
|
271 |
if ('a'<=keyCodeOrig&&keyCodeOrig<='z')
|
|
272 |
{
|
|
273 |
TRAP_IGNORE(iPtiEngine.HandleCommandL(
|
|
274 |
EPtiCommandUseLatinCaseLowerOnlyKeyMap,
|
|
275 |
NULL));
|
|
276 |
keyCodePti=keyCodeOrig-'a'+'A';
|
|
277 |
latin=ETrue;
|
|
278 |
}
|
|
279 |
else if ('A'<=keyCodeOrig&&keyCodeOrig<='Z')
|
|
280 |
{
|
|
281 |
TRAP_IGNORE(iPtiEngine.HandleCommandL(
|
|
282 |
EPtiCommandUseLatinCaseUpperOnlyKeyMap,
|
|
283 |
NULL));
|
|
284 |
latin=ETrue;
|
|
285 |
}
|
|
286 |
|
|
287 |
TInt previousLen = iPtiEngine.CurrentWord().Length();
|
|
288 |
|
|
289 |
switch (keyCodePti)
|
|
290 |
{
|
|
291 |
case '\b': // back space
|
|
292 |
if (previousLen)
|
|
293 |
{
|
|
294 |
iPtiEngine.DeleteKeyPress();
|
|
295 |
TPtrC currentWord(iPtiEngine.CurrentWord());
|
|
296 |
SendReplaceText(previousLen,currentWord);
|
|
297 |
ret=ETrue;
|
|
298 |
}
|
|
299 |
break;
|
|
300 |
|
|
301 |
default:
|
|
302 |
{
|
|
303 |
if (latin)
|
|
304 |
{
|
|
305 |
|
|
306 |
TPtrC text = iPtiEngine.AppendKeyPress((TPtiKey)(keyCodePti));
|
|
307 |
|
|
308 |
if(previousLen)
|
|
309 |
{
|
|
310 |
SendReplaceText(previousLen,iPtiEngine.CurrentWord());
|
|
311 |
ret=ETrue;
|
|
312 |
|
|
313 |
if(iPtiEngine.CurrentWord().Length() >= 2)
|
|
314 |
{
|
|
315 |
if (CommitOrNot(text.Right(KSingleCharacter)))
|
|
316 |
{
|
|
317 |
iPtiEngine.DeleteKeyPress();
|
|
318 |
iPtiEngine.CommitCurrentWord();
|
|
319 |
iPtiEngine.AppendKeyPress((TPtiKey)(keyCodePti));
|
|
320 |
// iContext->Sendkey(ESignalKeyEvent,iPtiEngine.CurrentWord());
|
|
321 |
ret=ETrue;
|
|
322 |
}
|
|
323 |
}
|
|
324 |
}
|
|
325 |
else
|
|
326 |
{
|
|
327 |
iContext->Sendkey(ESignalKeyEvent,iPtiEngine.CurrentWord());
|
|
328 |
ret=ETrue;
|
|
329 |
}
|
|
330 |
}
|
|
331 |
else
|
|
332 |
{
|
|
333 |
iPtiEngine.ClearCurrentWord();
|
|
334 |
}
|
|
335 |
}
|
|
336 |
break;
|
|
337 |
}
|
|
338 |
|
|
339 |
return ret;
|
|
340 |
}
|
|
341 |
|
|
342 |
|
|
343 |
void CPeninputVkbKrUiStateStandby::SendReplaceText(
|
|
344 |
const TInt& aLenToReplace,
|
|
345 |
const TDesC& aTextToReplace)
|
|
346 |
{
|
|
347 |
TInt lenTextToReplace(aTextToReplace.Length());
|
|
348 |
LOG2(
|
|
349 |
"Vkb.UiState.Standby.SendReplaceText %d - %d",
|
|
350 |
aLenToReplace,
|
|
351 |
lenTextToReplace);
|
|
352 |
|
|
353 |
if (aLenToReplace)
|
|
354 |
{
|
|
355 |
if (aLenToReplace<=lenTextToReplace)
|
|
356 |
{
|
|
357 |
HBufC* p = HBufC::New(lenTextToReplace+2);
|
|
358 |
if (p)
|
|
359 |
{
|
|
360 |
TPtr eventData(p->Des());
|
|
361 |
eventData.Zero();
|
|
362 |
eventData.Append((TUint16*)&aLenToReplace, 2);
|
|
363 |
eventData.Append(aTextToReplace);
|
|
364 |
iContext->Sendkey(ESignalReplaceText,eventData);
|
|
365 |
delete p;
|
|
366 |
}
|
|
367 |
}
|
|
368 |
else
|
|
369 |
{
|
|
370 |
TBuf<1> backSpace;
|
|
371 |
backSpace.Append(TChar(EKeyBackspace));
|
|
372 |
iContext->Sendkey(ESignalKeyEvent,backSpace);
|
|
373 |
iPtiEngine.ClearCurrentWord();
|
|
374 |
}
|
|
375 |
}
|
|
376 |
else
|
|
377 |
{
|
|
378 |
iContext->Sendkey(ESignalKeyEvent,aTextToReplace);
|
|
379 |
}
|
|
380 |
}
|
|
381 |
TBool CPeninputVkbKrUiStateStandby::CommitOrNot(TPtrC aData)
|
|
382 |
{
|
|
383 |
TBool commit = EFalse;
|
|
384 |
TBuf<KSingleCharacter> mappings;
|
|
385 |
|
|
386 |
TPtiKey key = iPtiEngine.CharacterToKey(*aData.Ptr());
|
|
387 |
|
|
388 |
iPtiEngine.MappingDataForKey(key, mappings, iPtiEngine.Case());
|
|
389 |
TInt len = mappings.Length();
|
|
390 |
|
|
391 |
if(aData.Compare(mappings) == 0)
|
|
392 |
{
|
|
393 |
commit = ETrue;
|
|
394 |
}
|
|
395 |
|
|
396 |
return commit;
|
|
397 |
}
|