2
* Copyright (C) 2008 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 _ANDROIDFW_KEY_LAYOUT_MAP_H
18
#define _ANDROIDFW_KEY_LAYOUT_MAP_H
21
#include <utils/Errors.h>
22
#include <utils/KeyedVector.h>
23
#include <utils/Tokenizer.h>
24
#include <utils/RefBase.h>
30
// Axis value is reported directly.
32
// Axis value should be inverted before reporting.
34
// Axis value should be split into two axes
42
// When split, this is the axis used for values smaller than the split position.
45
// When split, this is the axis used for values after higher than the split position.
48
// The split value, or 0 if not split.
51
// The flat value, or -1 if none.
54
AxisInfo() : mode(MODE_NORMAL), axis(-1), highAxis(-1), splitValue(0), flatOverride(-1) {
59
* Describes a mapping from keyboard scan codes and joystick axes to Android key codes and axes.
61
* This object is immutable after it has been loaded.
63
class KeyLayoutMap : public RefBase {
65
static status_t load(const String8& filename, sp<KeyLayoutMap>* outMap);
67
status_t mapKey(int32_t scanCode, int32_t usageCode,
68
int32_t* outKeyCode, uint32_t* outFlags) const;
69
status_t findScanCodesForKey(int32_t keyCode, Vector<int32_t>* outScanCodes) const;
71
status_t mapAxis(int32_t scanCode, AxisInfo* outAxisInfo) const;
74
virtual ~KeyLayoutMap();
82
KeyedVector<int32_t, Key> mKeysByScanCode;
83
KeyedVector<int32_t, Key> mKeysByUsageCode;
84
KeyedVector<int32_t, AxisInfo> mAxes;
88
const Key* getKey(int32_t scanCode, int32_t usageCode) const;
92
Tokenizer* mTokenizer;
95
Parser(KeyLayoutMap* map, Tokenizer* tokenizer);
101
status_t parseAxis();
105
} // namespace android
107
#endif // _ANDROIDFW_KEY_LAYOUT_MAP_H