• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2024 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 #pragma once
18 
19 #include <android-base/result.h>
20 #include <input/Input.h>
21 #include <input/InputDevice.h>
22 
23 #include "rust/cxx.h"
24 
25 namespace android {
26 
27 namespace input {
28 namespace keyboardClassifier {
29 struct KeyboardClassifier;
30 }
31 } // namespace input
32 
33 /*
34  * Keyboard classifier to classify keyboard into alphabetic and non-alphabetic keyboards
35  */
36 class KeyboardClassifier {
37 public:
38     KeyboardClassifier();
39     /**
40      * Get the type of keyboard that the classifier currently believes the device to be.
41      */
42     KeyboardType getKeyboardType(DeviceId deviceId);
43     void notifyKeyboardChanged(DeviceId deviceId, const InputDeviceIdentifier& identifier,
44                                uint32_t deviceClasses);
45     void processKey(DeviceId deviceId, int32_t evdevCode, uint32_t metaState);
46 
47 private:
48     std::optional<rust::Box<android::input::keyboardClassifier::KeyboardClassifier>>
49             mRustClassifier;
50     std::unordered_map<DeviceId, KeyboardType> mKeyboardTypeMap;
51 };
52 
53 } // namespace android
54