widget/gonk/libui/VirtualKeyMap.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/gonk/libui/VirtualKeyMap.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     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_VIRTUAL_KEY_MAP_H
    1.21 +#define _ANDROIDFW_VIRTUAL_KEY_MAP_H
    1.22 +
    1.23 +#include <stdint.h>
    1.24 +
    1.25 +#include "Input.h"
    1.26 +#include <utils/Errors.h>
    1.27 +#include <utils/KeyedVector.h>
    1.28 +#include "Tokenizer.h"
    1.29 +#include <utils/String8.h>
    1.30 +#include <utils/Unicode.h>
    1.31 +
    1.32 +namespace android {
    1.33 +
    1.34 +/* Describes a virtual key. */
    1.35 +struct VirtualKeyDefinition {
    1.36 +    int32_t scanCode;
    1.37 +
    1.38 +    // configured position data, specified in display coords
    1.39 +    int32_t centerX;
    1.40 +    int32_t centerY;
    1.41 +    int32_t width;
    1.42 +    int32_t height;
    1.43 +};
    1.44 +
    1.45 +
    1.46 +/**
    1.47 + * Describes a collection of virtual keys on a touch screen in terms of
    1.48 + * virtual scan codes and hit rectangles.
    1.49 + *
    1.50 + * This object is immutable after it has been loaded.
    1.51 + */
    1.52 +class VirtualKeyMap {
    1.53 +public:
    1.54 +    ~VirtualKeyMap();
    1.55 +
    1.56 +    static status_t load(const String8& filename, VirtualKeyMap** outMap);
    1.57 +
    1.58 +    inline const Vector<VirtualKeyDefinition>& getVirtualKeys() const {
    1.59 +        return mVirtualKeys;
    1.60 +    }
    1.61 +
    1.62 +private:
    1.63 +    class Parser {
    1.64 +        VirtualKeyMap* mMap;
    1.65 +        Tokenizer* mTokenizer;
    1.66 +
    1.67 +    public:
    1.68 +        Parser(VirtualKeyMap* map, Tokenizer* tokenizer);
    1.69 +        ~Parser();
    1.70 +        status_t parse();
    1.71 +
    1.72 +    private:
    1.73 +        bool consumeFieldDelimiterAndSkipWhitespace();
    1.74 +        bool parseNextIntField(int32_t* outValue);
    1.75 +    };
    1.76 +
    1.77 +    Vector<VirtualKeyDefinition> mVirtualKeys;
    1.78 +
    1.79 +    VirtualKeyMap();
    1.80 +};
    1.81 +
    1.82 +} // namespace android
    1.83 +
    1.84 +#endif // _ANDROIDFW_KEY_CHARACTER_MAP_H

mercurial