Jeff Brown | 6b53e8d | 2010-11-10 16:03:06 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _UI_KEY_LAYOUT_MAP_H |
| 18 | #define _UI_KEY_LAYOUT_MAP_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <utils/Errors.h> |
| 22 | #include <utils/KeyedVector.h> |
| 23 | #include <utils/Tokenizer.h> |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | /** |
| 28 | * Describes a mapping from keyboard scan codes to Android key codes. |
| 29 | */ |
| 30 | class KeyLayoutMap { |
| 31 | public: |
| 32 | ~KeyLayoutMap(); |
| 33 | |
| 34 | static status_t load(const String8& filename, KeyLayoutMap** outMap); |
| 35 | |
| 36 | status_t map(int32_t scanCode, int32_t* keyCode, uint32_t* flags) const; |
| 37 | status_t findScanCodes(int32_t keyCode, Vector<int32_t>* outScanCodes) const; |
| 38 | |
| 39 | private: |
| 40 | struct Key { |
| 41 | int32_t keyCode; |
| 42 | uint32_t flags; |
| 43 | }; |
| 44 | |
| 45 | KeyedVector<int32_t,Key> mKeys; |
| 46 | |
| 47 | KeyLayoutMap(); |
| 48 | |
| 49 | class Parser { |
| 50 | KeyLayoutMap* mMap; |
| 51 | Tokenizer* mTokenizer; |
| 52 | |
| 53 | public: |
| 54 | Parser(KeyLayoutMap* map, Tokenizer* tokenizer); |
| 55 | ~Parser(); |
| 56 | status_t parse(); |
| 57 | |
| 58 | private: |
| 59 | status_t parseKey(); |
| 60 | }; |
| 61 | }; |
| 62 | |
| 63 | } // namespace android |
| 64 | |
| 65 | #endif // _UI_KEY_LAYOUT_MAP_H |