| // Copyright 2018 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. |
| library fuchsia.hardware.input; |
| |
| using zx; |
| using fuchsia.hardware.hidbus; |
| |
| const MAX_REPORTS_COUNT uint32 = 50; |
| |
| /// Each `DeviceReportsReader` has its own FIFO of reports in the driver. |
| /// Calling `ReadReports` drains the Report FIFO. If the Report FIFO fills up |
| /// between calls to `ReadReports` the channel will be closed. |
| closed protocol DeviceReportsReader { |
| /// This is a Hanging-Get function to read the reports in the Report FIFO. |
| /// This will block until there is at least one report available. |
| /// If there is already one outstanding Hanging-Get, calling this again will |
| /// return ZX_ERR_ALREADY_BOUND. |
| strict ReadReports() -> (struct { |
| reports vector<fuchsia.hardware.hidbus.Report>:MAX_REPORTS_COUNT; |
| }) error zx.Status; |
| }; |
| |
| // TODO(https://fxbug.dev/42126285): This API doesn't follow best practices and needs to be |
| // cleaned up. |
| closed protocol Device { |
| /// Obtain information about the hidbus device and supported features. |
| strict Query() -> (struct { |
| info fuchsia.hardware.hidbus.HidInfo; |
| }) error zx.Status; |
| |
| /// Get the report descriptor |
| strict GetReportDesc() -> (struct { |
| desc vector<uint8>:fuchsia.hardware.hidbus.MAX_DESC_LEN; |
| }); |
| |
| /// Open a new DeviceReportsReader on this device. Opening a DeviceReportsReader |
| /// allocates a new FIFO for receiving input reports. |
| strict GetDeviceReportsReader(resource struct { |
| reader server_end:DeviceReportsReader; |
| }) -> () error zx.Status; |
| |
| /// Read one report out of the report FIFO. Only a single report will be |
| /// returned in this API. `time` is the time the report was created, from |
| /// the view of the monotonic clock. |
| /// If status is ZX_ERR_SHOULD_WAIT the client can wait on the event |
| /// from `GetReportsEvent`. |
| strict ReadReport() -> (struct { |
| report fuchsia.hardware.hidbus.Report; |
| }) error zx.Status; |
| |
| /// Read up to MAX_REPORT_DATA bytes of reports that have been sent from a device. |
| /// This is the interface that is supposed to be used for continuous polling. |
| /// Multiple reports can be returned from this API at a time, it is up to the client |
| /// to do the parsing of the reports with the correct sizes and offset. |
| /// It is guaranteed that only whole reports will be sent. |
| /// If there are no reports, this will return ZX_ERR_SHOULD_WAIT, and the client can |
| /// wait on the event from `GetReportsEvent`. |
| strict ReadReports() -> (struct { |
| data vector<uint8>:fuchsia.hardware.hidbus.MAX_REPORT_DATA; |
| }) error zx.Status; |
| |
| /// Receive an event that will signal on `ZX_USER_SIGNAL_0` when there are reports in the |
| /// Device's report FIFO. This signal will be de-asserted when there are no |
| /// reports in the Device's report FIFO. This event can be re-used each time |
| /// the client wishes to know if there are reports in the FIFO. |
| strict GetReportsEvent() -> (resource struct { |
| event zx.Handle:EVENT; |
| }) error zx.Status; |
| |
| /// Send a request to the hardware for a given report described by type and id. |
| /// Returns the hardware's response. This interface is not intended |
| /// to be used for continuous polling of the reports. |
| strict GetReport(struct { |
| type fuchsia.hardware.hidbus.ReportType; |
| id fuchsia.hardware.hidbus.ReportId; |
| }) -> (struct { |
| report vector<uint8>:fuchsia.hardware.hidbus.MAX_REPORT_LEN; |
| }) error zx.Status; |
| |
| /// Set a single report of the given (type, id) pair. |
| strict SetReport(struct { |
| type fuchsia.hardware.hidbus.ReportType; |
| id fuchsia.hardware.hidbus.ReportId; |
| report vector<uint8>:fuchsia.hardware.hidbus.MAX_REPORT_LEN; |
| }) -> () error zx.Status; |
| |
| /// Set the trace ID that is used for HID report flow events. |
| strict SetTraceId(struct { |
| id uint32; |
| }); |
| }; |
| |
| closed protocol Controller { |
| /// Opens a new session on the device. |
| strict OpenSession(resource struct { |
| session server_end:Device; |
| }); |
| }; |
| |
| service Service { |
| controller client_end:Controller; |
| }; |