2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef _LIBINPUT_KEYBOARD_H
18 #define _LIBINPUT_KEYBOARD_H
20 #include <input/Input.h>
21 #include <input/InputDevice.h>
22 #include <input/InputEventLabels.h>
23 #include <utils/Errors.h>
24 #include <utils/String8.h>
25 #include <utils/PropertyMap.h>
30 /* Device id of the built in keyboard. */
31 DEVICE_ID_BUILT_IN_KEYBOARD = 0,
33 /* Device id of a generic virtual keyboard with a full layout that can be used
34 * to synthesize key events. */
35 DEVICE_ID_VIRTUAL_KEYBOARD = -1,
39 class KeyCharacterMap;
42 * Loads the key layout map and key character map for a keyboard device.
46 String8 keyLayoutFile;
47 sp<KeyLayoutMap> keyLayoutMap;
49 String8 keyCharacterMapFile;
50 sp<KeyCharacterMap> keyCharacterMap;
55 status_t load(const InputDeviceIdentifier& deviceIdenfier,
56 const PropertyMap* deviceConfiguration);
58 inline bool haveKeyLayout() const {
59 return !keyLayoutFile.isEmpty();
62 inline bool haveKeyCharacterMap() const {
63 return !keyCharacterMapFile.isEmpty();
66 inline bool isComplete() const {
67 return haveKeyLayout() && haveKeyCharacterMap();
71 bool probeKeyMap(const InputDeviceIdentifier& deviceIdentifier, const String8& name);
72 status_t loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier, const String8& name);
73 status_t loadKeyCharacterMap(const InputDeviceIdentifier& deviceIdentifier,
75 String8 getPath(const InputDeviceIdentifier& deviceIdentifier,
76 const String8& name, InputDeviceConfigurationFileType type);
80 * Returns true if the keyboard is eligible for use as a built-in keyboard.
82 extern bool isEligibleBuiltInKeyboard(const InputDeviceIdentifier& deviceIdentifier,
83 const PropertyMap* deviceConfiguration, const KeyMap* keyMap);
86 * Updates a meta state field when a key is pressed or released.
88 extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState);
91 * Normalizes the meta state such that if either the left or right modifier
92 * meta state bits are set then the result will also include the universal
93 * bit for that modifier.
95 extern int32_t normalizeMetaState(int32_t oldMetaState);
98 * Returns true if a key is a meta key like ALT or CAPS_LOCK.
100 extern bool isMetaKey(int32_t keyCode);
102 } // namespace android
104 #endif // _LIBINPUT_KEYBOARD_H