blob: bd3a51cb519226e10531fd8dfa9e7917e340ea28 [file] [log] [blame]
Vaibhav Devmurarie58ffb92024-05-22 17:38:25 +00001/*
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//! Contains the KeyboardClassifier, that tries to identify whether an Input device is an
18//! alphabetic or non-alphabetic keyboard. It also tracks the KeyEvents produced by the device
19//! in order to verify/change the inferred keyboard type.
20
21use crate::input::{DeviceId, InputDevice, KeyboardType};
22use crate::ModifierState;
23
24/// The KeyboardClassifier is used to classify a keyboard device into non-keyboard, alphabetic
25/// keyboard or non-alphabetic keyboard
26#[derive(Default)]
27pub struct KeyboardClassifier {}
28
29impl KeyboardClassifier {
30 /// Create a new KeyboardClassifier
31 pub fn new() -> Self {
32 Default::default()
33 }
34
35 /// Adds keyboard to KeyboardClassifier
36 pub fn notify_keyboard_changed(&mut self, _device: InputDevice) {
37 // TODO(b/263559234): Implement method
38 }
39
40 /// Get keyboard type for a tracked keyboard in KeyboardClassifier
41 pub fn get_keyboard_type(&self, _device_id: DeviceId) -> KeyboardType {
42 // TODO(b/263559234): Implement method
43 KeyboardType::None
44 }
45
46 /// Tells if keyboard type classification is finalized. Once finalized the classification can't
47 /// change until device is reconnected again.
48 pub fn is_finalized(&self, _device_id: DeviceId) -> bool {
49 // TODO(b/263559234): Implement method
50 false
51 }
52
53 /// Process a key event and change keyboard type if required.
54 pub fn process_key(
55 &mut self,
56 _device_id: DeviceId,
57 _evdev_code: i32,
58 _modifier_state: ModifierState,
59 ) {
60 // TODO(b/263559234): Implement method
61 }
62}