當用戶端嘗試連線至驅動程式時,裝置可實作 ddk::Messagable
混音,以便 devfs 傳送訊息。驅動程式必須實作 ddk::Messagable
並使用想要呼叫的特定 FIDL 介面。
例如,實作 fuchsia_input_report::InputDevice
介面的驅動程式,其類別定義可能如下所示:
class InputReportDriver;
using DriverDeviceType = ddk::Device<InputReportDriver, ddk::Unbindable,
ddk::Messageable<fuchsia_input_report::InputDevice>::Mixin>;
class InputReportDriver : public DriverDeviceType{
// Implement the class methods here.
};
想要與這部裝置通訊的用戶端會在 /dev/class/input-report/
中開啟相關裝置檔案,並開始傳送 FIDL 訊息。