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_CHARACTER_MAP_H 18 #define _UI_KEY_CHARACTER_MAP_H 19 20 #include <stdint.h> 21 #include <utils/Vector.h> 22 23 using namespace android; 24 25 class KeyCharacterMap 26 { 27 public: 28 ~KeyCharacterMap(); 29 30 // see the javadoc for android.text.method.KeyCharacterMap for what 31 // these do 32 unsigned short get(int keycode, int meta); 33 unsigned short getNumber(int keycode); 34 unsigned short getMatch(int keycode, const unsigned short* chars, 35 int charsize, uint32_t modifiers); 36 unsigned short getDisplayLabel(int keycode); 37 bool getKeyData(int keycode, unsigned short *displayLabel, 38 unsigned short *number, unsigned short* results); getKeyboardType()39 inline unsigned int getKeyboardType() { return m_type; } 40 bool getEvents(uint16_t* chars, size_t len, 41 Vector<int32_t>* keys, Vector<uint32_t>* modifiers); 42 43 static KeyCharacterMap* load(int id); 44 45 enum { 46 NUMERIC = 1, 47 Q14 = 2, 48 QWERTY = 3 // or AZERTY or whatever 49 }; 50 51 #define META_MASK 3 52 53 private: 54 struct Key 55 { 56 int32_t keycode; 57 uint16_t display_label; 58 uint16_t number; 59 uint16_t data[META_MASK + 1]; 60 }; 61 62 KeyCharacterMap(); 63 static KeyCharacterMap* try_file(const char* filename); 64 Key* find_key(int keycode); 65 bool find_char(uint16_t c, uint32_t* key, uint32_t* mods); 66 67 unsigned int m_type; 68 unsigned int m_keyCount; 69 Key* m_keys; 70 }; 71 72 #endif // _UI_KEY_CHARACTER_MAP_H 73