1// Copyright 2020 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
45use crate::config::default_settings::DefaultSetting;
6use crate::input::types::{DeviceStateSource, InputDeviceType};
7use crate::inspect::config_logger::InspectConfigLogger;
8use serde::Deserialize;
9use std::rc::Rc;
10use std::sync::Mutex;
1112#[derive(PartialEq, Debug, Default, Clone, Deserialize)]
13pub struct InputConfiguration {
14/// List of input devices that are present on this product.
15pub devices: Vec<InputDeviceConfiguration>,
16}
1718#[derive(PartialEq, Debug, Clone, Deserialize)]
19pub struct InputDeviceConfiguration {
20/// Name of the device.
21 ///
22 /// Must be unique per device type. Can be empty if there is only one
23 /// input device of this type.
24pub device_name: String,
2526/// The type of input device, e.g. MICROPHONE.
27pub device_type: InputDeviceType,
2829/// The sources (e.g. HARDWARE) with their corresponding states.
30pub source_states: Vec<SourceState>,
3132/// The number representing the states that are toggleable by a client.
33 /// This is the sum of the bitflags that are set.
34pub mutable_toggle_state: u64,
35}
3637#[derive(PartialEq, Debug, Clone, Deserialize)]
38pub struct SourceState {
39/// The source, e.g. HARDWARE.
40pub source: DeviceStateSource,
4142/// The number representing the state for the source. This is the sum of
43 /// the bitflags that are set.
44pub state: u64,
45}
46pub fn build_input_default_settings(
47 config_logger: Rc<Mutex<InspectConfigLogger>>,
48) -> DefaultSetting<InputConfiguration, &'static str> {
49 DefaultSetting::new(
50Some(InputConfiguration::default()),
51"/config/data/input_device_config.json",
52 config_logger,
53 )
54}