1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- // Copyright 2022 The Chromium Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
- #include "ash/components/hid_detection/hid_detection_manager.h"
- #include "ash/constants/ash_features.h"
- namespace ash::hid_detection {
- HidDetectionManager::HidDetectionStatus::HidDetectionStatus(
- InputMetadata pointer_metadata,
- InputMetadata keyboard_metadata,
- bool touchscreen_detected,
- absl::optional<BluetoothHidPairingState> pairing_state)
- : pointer_metadata(pointer_metadata),
- keyboard_metadata(keyboard_metadata),
- touchscreen_detected(touchscreen_detected),
- pairing_state(std::move(pairing_state)) {}
- HidDetectionManager::HidDetectionStatus::HidDetectionStatus(
- HidDetectionStatus&& other) {
- pointer_metadata = other.pointer_metadata;
- keyboard_metadata = other.keyboard_metadata;
- touchscreen_detected = other.touchscreen_detected;
- pairing_state = std::move(other.pairing_state);
- }
- HidDetectionManager::HidDetectionStatus&
- HidDetectionManager::HidDetectionStatus::operator=(HidDetectionStatus&& other) {
- pointer_metadata = other.pointer_metadata;
- keyboard_metadata = other.keyboard_metadata;
- touchscreen_detected = other.touchscreen_detected;
- pairing_state = std::move(other.pairing_state);
- return *this;
- }
- HidDetectionManager::HidDetectionStatus::~HidDetectionStatus() = default;
- HidDetectionManager::HidDetectionManager() {
- DCHECK(ash::features::IsOobeHidDetectionRevampEnabled());
- }
- HidDetectionManager::~HidDetectionManager() {
- DCHECK(!delegate_) << " HID detection must be stopped before "
- << "HidDetectionManager is destroyed";
- }
- void HidDetectionManager::StartHidDetection(Delegate* delegate) {
- DCHECK(!delegate_);
- delegate_ = delegate;
- PerformStartHidDetection();
- }
- void HidDetectionManager::StopHidDetection() {
- DCHECK(delegate_);
- PerformStopHidDetection();
- delegate_ = nullptr;
- }
- void HidDetectionManager::NotifyHidDetectionStatusChanged() {
- delegate_->OnHidDetectionStatusChanged(ComputeHidDetectionStatus());
- }
- } // namespace ash::hid_detection
|