blob: 1e8834a6f7895a6440fa97d8bb852aa938fa4a3e [file] [log] [blame]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FUCHSIA_SDK_EXAMPLES_INPUT_SAMPLE_INPUT_SAMPLE_H_
#define FUCHSIA_SDK_EXAMPLES_INPUT_SAMPLE_INPUT_SAMPLE_H_
#include <lib/driver/compat/cpp/compat.h>
#include <lib/driver/compat/cpp/context.h>
#include <lib/driver/component/cpp/driver_cpp.h>
#include "input_server.h"
namespace input_sample {
// Sample driver for a virtual input device that generates input reports.
class InputSampleDriver : public driver::DriverBase {
public:
InputSampleDriver(driver::DriverStartArgs start_args, fdf::UnownedDispatcher driver_dispatcher)
: driver::DriverBase("input-sample", std::move(start_args), std::move(driver_dispatcher)) {}
virtual ~InputSampleDriver() = default;
zx::result<> Start() override;
private:
void SendFakeReport();
void InitializeCompatService(zx::result<std::shared_ptr<compat::Context>> result);
std::optional<compat::DeviceServer> child_;
std::shared_ptr<compat::Context> compat_context_;
std::shared_ptr<input_report_reader::InputReportReaderManager<SampleInputReport>>
input_report_readers_;
SampleInputReport report_;
};
} // namespace input_sample
#endif // FUCHSIA_SDK_EXAMPLES_INPUT_SAMPLE_INPUT_SAMPLE_H_