Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (C) 2010 The Android Open Source Project |
michael@0 | 3 | * |
michael@0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 5 | * you may not use this file except in compliance with the License. |
michael@0 | 6 | * You may obtain a copy of the License at |
michael@0 | 7 | * |
michael@0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 9 | * |
michael@0 | 10 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 13 | * See the License for the specific language governing permissions and |
michael@0 | 14 | * limitations under the License. |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #ifndef _ANDROIDFW_KEYBOARD_H |
michael@0 | 18 | #define _ANDROIDFW_KEYBOARD_H |
michael@0 | 19 | |
michael@0 | 20 | #include "Input.h" |
michael@0 | 21 | #include "InputDevice.h" |
michael@0 | 22 | #include <utils/Errors.h> |
michael@0 | 23 | #include <utils/String8.h> |
michael@0 | 24 | #include <utils/PropertyMap.h> |
michael@0 | 25 | |
michael@0 | 26 | namespace android { |
michael@0 | 27 | |
michael@0 | 28 | enum { |
michael@0 | 29 | /* Device id of the built in keyboard. */ |
michael@0 | 30 | DEVICE_ID_BUILT_IN_KEYBOARD = 0, |
michael@0 | 31 | |
michael@0 | 32 | /* Device id of a generic virtual keyboard with a full layout that can be used |
michael@0 | 33 | * to synthesize key events. */ |
michael@0 | 34 | DEVICE_ID_VIRTUAL_KEYBOARD = -1, |
michael@0 | 35 | }; |
michael@0 | 36 | |
michael@0 | 37 | class KeyLayoutMap; |
michael@0 | 38 | class KeyCharacterMap; |
michael@0 | 39 | |
michael@0 | 40 | /** |
michael@0 | 41 | * Loads the key layout map and key character map for a keyboard device. |
michael@0 | 42 | */ |
michael@0 | 43 | class KeyMap { |
michael@0 | 44 | public: |
michael@0 | 45 | String8 keyLayoutFile; |
michael@0 | 46 | sp<KeyLayoutMap> keyLayoutMap; |
michael@0 | 47 | |
michael@0 | 48 | String8 keyCharacterMapFile; |
michael@0 | 49 | sp<KeyCharacterMap> keyCharacterMap; |
michael@0 | 50 | |
michael@0 | 51 | KeyMap(); |
michael@0 | 52 | ~KeyMap(); |
michael@0 | 53 | |
michael@0 | 54 | status_t load(const InputDeviceIdentifier& deviceIdenfier, |
michael@0 | 55 | const PropertyMap* deviceConfiguration); |
michael@0 | 56 | |
michael@0 | 57 | inline bool haveKeyLayout() const { |
michael@0 | 58 | return !keyLayoutFile.isEmpty(); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | inline bool haveKeyCharacterMap() const { |
michael@0 | 62 | return !keyCharacterMapFile.isEmpty(); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | inline bool isComplete() const { |
michael@0 | 66 | return haveKeyLayout() && haveKeyCharacterMap(); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | private: |
michael@0 | 70 | bool probeKeyMap(const InputDeviceIdentifier& deviceIdentifier, const String8& name); |
michael@0 | 71 | status_t loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier, const String8& name); |
michael@0 | 72 | status_t loadKeyCharacterMap(const InputDeviceIdentifier& deviceIdentifier, |
michael@0 | 73 | const String8& name); |
michael@0 | 74 | String8 getPath(const InputDeviceIdentifier& deviceIdentifier, |
michael@0 | 75 | const String8& name, InputDeviceConfigurationFileType type); |
michael@0 | 76 | }; |
michael@0 | 77 | |
michael@0 | 78 | /** |
michael@0 | 79 | * Returns true if the keyboard is eligible for use as a built-in keyboard. |
michael@0 | 80 | */ |
michael@0 | 81 | extern bool isEligibleBuiltInKeyboard(const InputDeviceIdentifier& deviceIdentifier, |
michael@0 | 82 | const PropertyMap* deviceConfiguration, const KeyMap* keyMap); |
michael@0 | 83 | |
michael@0 | 84 | /** |
michael@0 | 85 | * Gets a key code by its short form label, eg. "HOME". |
michael@0 | 86 | * Returns 0 if unknown. |
michael@0 | 87 | */ |
michael@0 | 88 | extern int32_t getKeyCodeByLabel(const char* label); |
michael@0 | 89 | |
michael@0 | 90 | /** |
michael@0 | 91 | * Gets a key flag by its short form label, eg. "WAKE". |
michael@0 | 92 | * Returns 0 if unknown. |
michael@0 | 93 | */ |
michael@0 | 94 | extern uint32_t getKeyFlagByLabel(const char* label); |
michael@0 | 95 | |
michael@0 | 96 | /** |
michael@0 | 97 | * Gets a axis by its short form label, eg. "X". |
michael@0 | 98 | * Returns -1 if unknown. |
michael@0 | 99 | */ |
michael@0 | 100 | extern int32_t getAxisByLabel(const char* label); |
michael@0 | 101 | |
michael@0 | 102 | /** |
michael@0 | 103 | * Gets a axis label by its id. |
michael@0 | 104 | * Returns NULL if unknown. |
michael@0 | 105 | */ |
michael@0 | 106 | extern const char* getAxisLabel(int32_t axisId); |
michael@0 | 107 | |
michael@0 | 108 | /** |
michael@0 | 109 | * Updates a meta state field when a key is pressed or released. |
michael@0 | 110 | */ |
michael@0 | 111 | extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState); |
michael@0 | 112 | |
michael@0 | 113 | /** |
michael@0 | 114 | * Returns true if a key is a meta key like ALT or CAPS_LOCK. |
michael@0 | 115 | */ |
michael@0 | 116 | extern bool isMetaKey(int32_t keyCode); |
michael@0 | 117 | |
michael@0 | 118 | } // namespace android |
michael@0 | 119 | |
michael@0 | 120 | #endif // _ANDROIDFW_KEYBOARD_H |