|
1 /* |
|
2 * Copyright (c) 2008 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: This is the implementation of application class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <e32keys.h> |
|
21 |
|
22 #include "codestore.h" |
|
23 #include "debug.h" |
|
24 |
|
25 // ---------------------------------------------------------------------- |
|
26 |
|
27 CScanCodeStore::CScanCodeStore() |
|
28 { |
|
29 // nothing else to do |
|
30 } |
|
31 |
|
32 CScanCodeStore* CScanCodeStore::NewL() |
|
33 { |
|
34 // no second phase construction necessary: |
|
35 return new (ELeave) CScanCodeStore; |
|
36 } |
|
37 |
|
38 CScanCodeStore::~CScanCodeStore() |
|
39 { |
|
40 iKeys.Reset(); |
|
41 } |
|
42 |
|
43 // ---------------------------------------------------------------------- |
|
44 |
|
45 TInt CScanCodeStore::Store(TInt aHidKey, TInt aUsagePage, TInt aScanCode) |
|
46 { |
|
47 TRACE_INFO( (_L("CScanCodeStore::Store(%d, %d, %d)"), |
|
48 aHidKey, aUsagePage, aScanCode)); |
|
49 |
|
50 return iKeys.Append(TKeyDownInfo(aHidKey, aUsagePage, aScanCode)); |
|
51 } |
|
52 |
|
53 TInt CScanCodeStore::Retrieve(TInt aHidKey, TInt aUsagePage) |
|
54 { |
|
55 |
|
56 TInt result = EStdKeyNull; |
|
57 |
|
58 for (TInt i=0; (result == EStdKeyNull) && (i < iKeys.Count()); ++i) |
|
59 { |
|
60 if ((iKeys[i].iHidKey == aHidKey) && |
|
61 (iKeys[i].iUsagePage == aUsagePage)) |
|
62 { |
|
63 result = iKeys[i].iScanCode; |
|
64 iKeys.Remove(i); |
|
65 } |
|
66 } |
|
67 |
|
68 TRACE_INFO( (_L("CScanCodeStore::Retrieve(%d, %d) = %d"), |
|
69 aHidKey, aUsagePage, result)); |
|
70 |
|
71 return result; |
|
72 } |
|
73 |
|
74 // ---------------------------------------------------------------------- |