widget/gonk/libui/Keyboard.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/gonk/libui/Keyboard.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,120 @@
     1.4 +/*
     1.5 + * Copyright (C) 2010 The Android Open Source Project
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *      http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +#ifndef _ANDROIDFW_KEYBOARD_H
    1.21 +#define _ANDROIDFW_KEYBOARD_H
    1.22 +
    1.23 +#include "Input.h"
    1.24 +#include "InputDevice.h"
    1.25 +#include <utils/Errors.h>
    1.26 +#include <utils/String8.h>
    1.27 +#include <utils/PropertyMap.h>
    1.28 +
    1.29 +namespace android {
    1.30 +
    1.31 +enum {
    1.32 +    /* Device id of the built in keyboard. */
    1.33 +    DEVICE_ID_BUILT_IN_KEYBOARD = 0,
    1.34 +
    1.35 +    /* Device id of a generic virtual keyboard with a full layout that can be used
    1.36 +     * to synthesize key events. */
    1.37 +    DEVICE_ID_VIRTUAL_KEYBOARD = -1,
    1.38 +};
    1.39 +
    1.40 +class KeyLayoutMap;
    1.41 +class KeyCharacterMap;
    1.42 +
    1.43 +/**
    1.44 + * Loads the key layout map and key character map for a keyboard device.
    1.45 + */
    1.46 +class KeyMap {
    1.47 +public:
    1.48 +    String8 keyLayoutFile;
    1.49 +    sp<KeyLayoutMap> keyLayoutMap;
    1.50 +
    1.51 +    String8 keyCharacterMapFile;
    1.52 +    sp<KeyCharacterMap> keyCharacterMap;
    1.53 +
    1.54 +    KeyMap();
    1.55 +    ~KeyMap();
    1.56 +
    1.57 +    status_t load(const InputDeviceIdentifier& deviceIdenfier,
    1.58 +            const PropertyMap* deviceConfiguration);
    1.59 +
    1.60 +    inline bool haveKeyLayout() const {
    1.61 +        return !keyLayoutFile.isEmpty();
    1.62 +    }
    1.63 +
    1.64 +    inline bool haveKeyCharacterMap() const {
    1.65 +        return !keyCharacterMapFile.isEmpty();
    1.66 +    }
    1.67 +
    1.68 +    inline bool isComplete() const {
    1.69 +        return haveKeyLayout() && haveKeyCharacterMap();
    1.70 +    }
    1.71 +
    1.72 +private:
    1.73 +    bool probeKeyMap(const InputDeviceIdentifier& deviceIdentifier, const String8& name);
    1.74 +    status_t loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier, const String8& name);
    1.75 +    status_t loadKeyCharacterMap(const InputDeviceIdentifier& deviceIdentifier,
    1.76 +            const String8& name);
    1.77 +    String8 getPath(const InputDeviceIdentifier& deviceIdentifier,
    1.78 +            const String8& name, InputDeviceConfigurationFileType type);
    1.79 +};
    1.80 +
    1.81 +/**
    1.82 + * Returns true if the keyboard is eligible for use as a built-in keyboard.
    1.83 + */
    1.84 +extern bool isEligibleBuiltInKeyboard(const InputDeviceIdentifier& deviceIdentifier,
    1.85 +        const PropertyMap* deviceConfiguration, const KeyMap* keyMap);
    1.86 +
    1.87 +/**
    1.88 + * Gets a key code by its short form label, eg. "HOME".
    1.89 + * Returns 0 if unknown.
    1.90 + */
    1.91 +extern int32_t getKeyCodeByLabel(const char* label);
    1.92 +
    1.93 +/**
    1.94 + * Gets a key flag by its short form label, eg. "WAKE".
    1.95 + * Returns 0 if unknown.
    1.96 + */
    1.97 +extern uint32_t getKeyFlagByLabel(const char* label);
    1.98 +
    1.99 +/**
   1.100 + * Gets a axis by its short form label, eg. "X".
   1.101 + * Returns -1 if unknown.
   1.102 + */
   1.103 +extern int32_t getAxisByLabel(const char* label);
   1.104 +
   1.105 +/**
   1.106 + * Gets a axis label by its id.
   1.107 + * Returns NULL if unknown.
   1.108 + */
   1.109 +extern const char* getAxisLabel(int32_t axisId);
   1.110 +
   1.111 +/**
   1.112 + * Updates a meta state field when a key is pressed or released.
   1.113 + */
   1.114 +extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState);
   1.115 +
   1.116 +/**
   1.117 + * Returns true if a key is a meta key like ALT or CAPS_LOCK.
   1.118 + */
   1.119 +extern bool isMetaKey(int32_t keyCode);
   1.120 +
   1.121 +} // namespace android
   1.122 +
   1.123 +#endif // _ANDROIDFW_KEYBOARD_H

mercurial