84 lines
2.6 KiB
C#
84 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using System.Threading;
|
|
using EonaCat.HID.EventArguments;
|
|
using EonaCat.HID.Models;
|
|
|
|
namespace EonaCat.HID
|
|
{
|
|
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
|
// See the LICENSE file or go to https://EonaCat.com/license for full license details.
|
|
|
|
/// <summary>
|
|
/// Interface abstraction for a HID device.
|
|
/// </summary>
|
|
public interface IHid : IDisposable
|
|
{
|
|
string DevicePath { get; }
|
|
ushort VendorId { get; }
|
|
ushort ProductId { get; }
|
|
string SerialNumber { get; }
|
|
string Manufacturer { get; }
|
|
string ProductName { get; }
|
|
int InputReportByteLength { get; }
|
|
int OutputReportByteLength { get; }
|
|
int FeatureReportByteLength { get; }
|
|
bool IsConnected { get;}
|
|
|
|
bool IsReadingSupport { get; }
|
|
bool IsWritingSupport { get; }
|
|
|
|
IDictionary<string, object> Capabilities { get; }
|
|
|
|
/// <summary>
|
|
/// Opens the device for communication
|
|
/// </summary>
|
|
void Open();
|
|
|
|
/// <summary>
|
|
/// Closes the device
|
|
/// </summary>
|
|
void Close();
|
|
|
|
/// <summary>
|
|
/// Writes an output report to the device
|
|
/// </summary>
|
|
/// <param name="data">Complete report data including ReportID</param>
|
|
Task WriteOutputReportAsync(HidReport report);
|
|
|
|
/// <summary>
|
|
/// Reads an input report
|
|
/// </summary>
|
|
/// <returns>Input report data</returns>
|
|
Task<HidReport> ReadInputReportAsync();
|
|
|
|
/// <summary>
|
|
/// Sends a feature report
|
|
/// </summary>
|
|
/// <param name="data">Complete feature report data including ReportID</param>
|
|
Task SendFeatureReportAsync(HidReport report);
|
|
|
|
/// <summary>
|
|
/// Gets a feature report
|
|
/// </summary>
|
|
/// <returns>Feature report data</returns>
|
|
Task<HidReport> GetFeatureReportAsync(byte reportId);
|
|
|
|
/// <summary>
|
|
/// Asynchronously read input reports and raise OnDataReceived event
|
|
/// </summary>
|
|
/// <param name="cancellationToken"></param>
|
|
Task StartListeningAsync(CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Occurs when data is received from the device asynchronously
|
|
/// </summary>
|
|
event EventHandler<HidDataReceivedEventArgs> OnDataReceived;
|
|
|
|
/// <summary>
|
|
/// Errors occurring on device operations
|
|
/// </summary>
|
|
event EventHandler<HidErrorEventArgs> OnError;
|
|
}
|
|
} |