blob: 3b477c7b5a6fcaf51fdcdd579ebcba954ea19f4e [file] [log] [blame]
Jeff Browna3477c82010-11-10 16:03:06 -08001/*
2 * Copyright (C) 2010 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_KEYBOARD_H
18#define _UI_KEYBOARD_H
19
20#include <ui/Input.h>
21#include <utils/Errors.h>
22#include <utils/String8.h>
23
24namespace android {
25
26enum {
27 /* Device id of the built in keyboard. */
28 DEVICE_ID_BUILT_IN_KEYBOARD = 0,
29
30 /* Device id of a generic virtual keyboard with a full layout that can be used
31 * to synthesize key events. */
32 DEVICE_ID_VIRTUAL_KEYBOARD = -1,
33};
34
35struct KeyMapInfo {
36 String8 keyMapName;
37 String8 keyLayoutFile;
38 String8 keyCharacterMapFile;
39 bool isDefaultKeyMap;
40
41 KeyMapInfo() : isDefaultKeyMap(false) {
42 }
43};
44
45/**
46 * Resolves the key map to use for a particular keyboard device.
47 */
48extern status_t resolveKeyMap(const String8& deviceName, KeyMapInfo& outKeyMapInfo);
49
50/**
51 * Sets keyboard system properties.
52 */
53extern void setKeyboardProperties(int32_t deviceId, const String8& deviceName,
54 const KeyMapInfo& keyMapInfo);
55
56/**
57 * Clears keyboard system properties.
58 */
59extern void clearKeyboardProperties(int32_t deviceId);
60
61/**
62 * Gets the key character map filename for a device using inspecting system properties
63 * and then falling back on a default key character map if necessary.
64 * Returns a NAME_NOT_FOUND if none found.
65 */
66extern status_t getKeyCharacterMapFile(int32_t deviceId, String8& outKeyCharacterMapFile);
67
68/**
69 * Gets a key code by its short form label, eg. "HOME".
70 * Returns 0 if unknown.
71 */
72extern int32_t getKeyCodeByLabel(const char* label);
73
74/**
75 * Gets a key flag by its short form label, eg. "WAKE".
76 * Returns 0 if unknown.
77 */
78extern uint32_t getKeyFlagByLabel(const char* label);
79
80/**
81 * Updates a meta state field when a key is pressed or released.
82 */
83extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState);
84
85} // namespace android
86
87#endif // _UI_KEYBOARD_H