Documentation
¶
Overview ¶
Package hid is a generated GoMock package.
Index ¶
- Constants
- Variables
- type ClassDescriptorType
- type Device
- type DeviceConfig
- type DeviceInfo
- func (d *DeviceInfo) FromDeviceDesc(desc *gousb.DeviceDesc, confNumber, infNumber, altNumber int) error
- func (d *DeviceInfo) GetAltSettingNumber() int
- func (d *DeviceInfo) GetConfigNumber() int
- func (d *DeviceInfo) GetEndpoints() map[gousb.EndpointAddress]gousb.EndpointDesc
- func (d *DeviceInfo) GetInterfaceNumber() int
- func (d DeviceInfo) String() string
- type DeviceInfos
- type EndpointTransferType
- type HIDProtocol
- type MockDevice
- func (m *MockDevice) Close() error
- func (m *MockDevice) EXPECT() *MockDeviceMockRecorder
- func (m *MockDevice) GetDeviceInfo() DeviceInfo
- func (m *MockDevice) GetFeatureReport(data []byte) (int, error)
- func (m *MockDevice) GetHIDDescriptor() (hid.HIDDescriptor, error)
- func (m *MockDevice) GetInputReport(data []byte) (int, error)
- func (m *MockDevice) GetManufacturer() (string, error)
- func (m *MockDevice) GetProduct() (string, error)
- func (m *MockDevice) GetReportDescriptor() (report.HIDReportDescriptor, error)
- func (m *MockDevice) GetSerialNumber() (string, error)
- func (m *MockDevice) GetStringDescriptor(index int) (string, error)
- func (m *MockDevice) ReadInput(ctx context.Context, data []byte) (int, error)
- func (m *MockDevice) SendFeatureReport(data []byte) (int, error)
- func (m *MockDevice) SendOutputReport(data []byte) (int, error)
- func (m *MockDevice) SetAutoDetach(autoDetach bool) error
- func (m *MockDevice) SetTarget(confNumber, infNumber, altNumber int) error
- func (m *MockDevice) WriteOutput(ctx context.Context, data []byte) (int, error)
- type MockDeviceMockRecorder
- func (mr *MockDeviceMockRecorder) Close() *gomock.Call
- func (mr *MockDeviceMockRecorder) GetDeviceInfo() *gomock.Call
- func (mr *MockDeviceMockRecorder) GetFeatureReport(data any) *gomock.Call
- func (mr *MockDeviceMockRecorder) GetHIDDescriptor() *gomock.Call
- func (mr *MockDeviceMockRecorder) GetInputReport(data any) *gomock.Call
- func (mr *MockDeviceMockRecorder) GetManufacturer() *gomock.Call
- func (mr *MockDeviceMockRecorder) GetProduct() *gomock.Call
- func (mr *MockDeviceMockRecorder) GetReportDescriptor() *gomock.Call
- func (mr *MockDeviceMockRecorder) GetSerialNumber() *gomock.Call
- func (mr *MockDeviceMockRecorder) GetStringDescriptor(index any) *gomock.Call
- func (mr *MockDeviceMockRecorder) ReadInput(ctx, data any) *gomock.Call
- func (mr *MockDeviceMockRecorder) SendFeatureReport(data any) *gomock.Call
- func (mr *MockDeviceMockRecorder) SendOutputReport(data any) *gomock.Call
- func (mr *MockDeviceMockRecorder) SetAutoDetach(autoDetach any) *gomock.Call
- func (mr *MockDeviceMockRecorder) SetTarget(confNumber, infNumber, altNumber any) *gomock.Call
- func (mr *MockDeviceMockRecorder) WriteOutput(ctx, data any) *gomock.Call
- type ReportType
- type SetupEndpointDirection
- type SetupRequest
- type SetupRequestRecipient
- type SetupRequestType
- type SubClass
Constants ¶
const ( HID_CLASS_ID uint8 = 3 HID_MAX_REPORT_SIZE uint16 = 4096 )
const (
DEFAULT_ENDPOINT_STREAM_COUNT = 16
)
Variables ¶
var ( ErrEmptyData = errors.New("empty data") ErrUninitializedDevice = errors.New("uninitialized device") ErrUninitializedEndpoint = errors.New("uninitialized endpoint") ErrDeviceIsNil = errors.New("device is nil") ErrEndpointInNotFound = errors.New("endpoint IN not found") )
var ( ErrDeviceProfileNotFound = errors.New("device profile not found") ErrDeviceDescNotFound = errors.New("device descriptor not found") )
Functions ¶
This section is empty.
Types ¶
type ClassDescriptorType ¶
type ClassDescriptorType uint8
const ( DESCRIPTOR_TYPE_HID ClassDescriptorType = 0x21 DESCRIPTOR_TYPE_REPORT ClassDescriptorType = 0x22 DESCRIPTOR_TYPE_PHYSICAL ClassDescriptorType = 0x23 )
type Device ¶
type Device interface {
// Set profile to the device on which configuration/interface/alternateSetting to be used
SetTarget(confNumber, infNumber, altNumber int) error
// Close device connection
Close() error
// Set an HID device to automatically detached from kernel when claim its interfaces
SetAutoDetach(autoDetach bool) error
// Write an Output report to HID device, via interrupt OUT endpoint
WriteOutput(ctx context.Context, data []byte) (int, error)
// Read an Input report from a HID device, via interrupt IN endpoint
ReadInput(ctx context.Context, data []byte) (int, error)
// Send a Feature Report using Set_Report transfer, via control endpoint
// The first byte of data must contain the Report ID. For device that support single report type, set it to 0x00
SendFeatureReport(data []byte) (int, error)
// Get a Feature report from a HID device using Get_Report transfer, via control endpoint
GetFeatureReport(data []byte) (int, error)
// Send Output Report to HID device using Set_Report transfer, via control endpoint
SendOutputReport(data []byte) (int, error)
// Get Input report from HID device using Get_Report transfer, via control endpoint
GetInputReport(data []byte) (int, error)
// Get device serial number using Get_Descriptor transfer (indexed string), via control endpoint
GetSerialNumber() (string, error)
// Get device product name using Get_Descriptor transfer (indexed string), via control endpoint
GetProduct() (string, error)
// Get device manufacturer using Get_Descriptor transfer (indexed string), via control endpoint
GetManufacturer() (string, error)
// Get report descriptor using Get_Descriptor transfer, via control endpoint
GetReportDescriptor() (hidreport.HIDReportDescriptor, error)
// Get HID descriptor using Get_Descriptor transfer, via control endpoint
GetHIDDescriptor() (hid.HIDDescriptor, error)
// Get string descriptor
GetStringDescriptor(index int) (string, error)
// Get device info
GetDeviceInfo() DeviceInfo
}
type DeviceConfig ¶
type DeviceConfig struct {
// Number of stream lanes used for streaming data on interrupt endpoints
StreamLaneCount int
}
type DeviceInfo ¶
type DeviceInfo struct {
DeviceDesc *gousb.DeviceDesc
// contains filtered or unexported fields
}
func (*DeviceInfo) FromDeviceDesc ¶
func (d *DeviceInfo) FromDeviceDesc(desc *gousb.DeviceDesc, confNumber, infNumber, altNumber int) error
func (*DeviceInfo) GetAltSettingNumber ¶
func (d *DeviceInfo) GetAltSettingNumber() int
func (*DeviceInfo) GetConfigNumber ¶
func (d *DeviceInfo) GetConfigNumber() int
func (*DeviceInfo) GetEndpoints ¶
func (d *DeviceInfo) GetEndpoints() map[gousb.EndpointAddress]gousb.EndpointDesc
func (*DeviceInfo) GetInterfaceNumber ¶
func (d *DeviceInfo) GetInterfaceNumber() int
func (DeviceInfo) String ¶
func (d DeviceInfo) String() string
type DeviceInfos ¶
type DeviceInfos []DeviceInfo
func (DeviceInfos) String ¶
func (d DeviceInfos) String() string
type EndpointTransferType ¶
type EndpointTransferType uint8
const ( ENDPOINT_TRANSFER_TYPE_CONTROL EndpointTransferType = 0 ENDPOINT_TRANSFER_TYPE_INTERRUPT EndpointTransferType = 3 )
Only two of these transfer types are used for HID class devices
type HIDProtocol ¶
type HIDProtocol uint8
const ( HID_PROTOCOL_NONE HIDProtocol = 0 HID_PROTOCOL_KEYBOARD HIDProtocol = 1 HID_PROTOCOL_MOUSE HIDProtocol = 2 )
type MockDevice ¶
type MockDevice struct {
// contains filtered or unexported fields
}
MockDevice is a mock of Device interface.
func NewMockDevice ¶
func NewMockDevice(ctrl *gomock.Controller) *MockDevice
NewMockDevice creates a new mock instance.
func (*MockDevice) EXPECT ¶
func (m *MockDevice) EXPECT() *MockDeviceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockDevice) GetDeviceInfo ¶
func (m *MockDevice) GetDeviceInfo() DeviceInfo
GetDeviceInfo mocks base method.
func (*MockDevice) GetFeatureReport ¶
func (m *MockDevice) GetFeatureReport(data []byte) (int, error)
GetFeatureReport mocks base method.
func (*MockDevice) GetHIDDescriptor ¶
func (m *MockDevice) GetHIDDescriptor() (hid.HIDDescriptor, error)
GetHIDDescriptor mocks base method.
func (*MockDevice) GetInputReport ¶
func (m *MockDevice) GetInputReport(data []byte) (int, error)
GetInputReport mocks base method.
func (*MockDevice) GetManufacturer ¶
func (m *MockDevice) GetManufacturer() (string, error)
GetManufacturer mocks base method.
func (*MockDevice) GetProduct ¶
func (m *MockDevice) GetProduct() (string, error)
GetProduct mocks base method.
func (*MockDevice) GetReportDescriptor ¶
func (m *MockDevice) GetReportDescriptor() (report.HIDReportDescriptor, error)
GetReportDescriptor mocks base method.
func (*MockDevice) GetSerialNumber ¶
func (m *MockDevice) GetSerialNumber() (string, error)
GetSerialNumber mocks base method.
func (*MockDevice) GetStringDescriptor ¶
func (m *MockDevice) GetStringDescriptor(index int) (string, error)
GetStringDescriptor mocks base method.
func (*MockDevice) SendFeatureReport ¶
func (m *MockDevice) SendFeatureReport(data []byte) (int, error)
SendFeatureReport mocks base method.
func (*MockDevice) SendOutputReport ¶
func (m *MockDevice) SendOutputReport(data []byte) (int, error)
SendOutputReport mocks base method.
func (*MockDevice) SetAutoDetach ¶
func (m *MockDevice) SetAutoDetach(autoDetach bool) error
SetAutoDetach mocks base method.
func (*MockDevice) SetTarget ¶
func (m *MockDevice) SetTarget(confNumber, infNumber, altNumber int) error
SetTarget mocks base method.
func (*MockDevice) WriteOutput ¶
WriteOutput mocks base method.
type MockDeviceMockRecorder ¶
type MockDeviceMockRecorder struct {
// contains filtered or unexported fields
}
MockDeviceMockRecorder is the mock recorder for MockDevice.
func (*MockDeviceMockRecorder) Close ¶
func (mr *MockDeviceMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockDeviceMockRecorder) GetDeviceInfo ¶
func (mr *MockDeviceMockRecorder) GetDeviceInfo() *gomock.Call
GetDeviceInfo indicates an expected call of GetDeviceInfo.
func (*MockDeviceMockRecorder) GetFeatureReport ¶
func (mr *MockDeviceMockRecorder) GetFeatureReport(data any) *gomock.Call
GetFeatureReport indicates an expected call of GetFeatureReport.
func (*MockDeviceMockRecorder) GetHIDDescriptor ¶
func (mr *MockDeviceMockRecorder) GetHIDDescriptor() *gomock.Call
GetHIDDescriptor indicates an expected call of GetHIDDescriptor.
func (*MockDeviceMockRecorder) GetInputReport ¶
func (mr *MockDeviceMockRecorder) GetInputReport(data any) *gomock.Call
GetInputReport indicates an expected call of GetInputReport.
func (*MockDeviceMockRecorder) GetManufacturer ¶
func (mr *MockDeviceMockRecorder) GetManufacturer() *gomock.Call
GetManufacturer indicates an expected call of GetManufacturer.
func (*MockDeviceMockRecorder) GetProduct ¶
func (mr *MockDeviceMockRecorder) GetProduct() *gomock.Call
GetProduct indicates an expected call of GetProduct.
func (*MockDeviceMockRecorder) GetReportDescriptor ¶
func (mr *MockDeviceMockRecorder) GetReportDescriptor() *gomock.Call
GetReportDescriptor indicates an expected call of GetReportDescriptor.
func (*MockDeviceMockRecorder) GetSerialNumber ¶
func (mr *MockDeviceMockRecorder) GetSerialNumber() *gomock.Call
GetSerialNumber indicates an expected call of GetSerialNumber.
func (*MockDeviceMockRecorder) GetStringDescriptor ¶
func (mr *MockDeviceMockRecorder) GetStringDescriptor(index any) *gomock.Call
GetStringDescriptor indicates an expected call of GetStringDescriptor.
func (*MockDeviceMockRecorder) ReadInput ¶
func (mr *MockDeviceMockRecorder) ReadInput(ctx, data any) *gomock.Call
ReadInput indicates an expected call of ReadInput.
func (*MockDeviceMockRecorder) SendFeatureReport ¶
func (mr *MockDeviceMockRecorder) SendFeatureReport(data any) *gomock.Call
SendFeatureReport indicates an expected call of SendFeatureReport.
func (*MockDeviceMockRecorder) SendOutputReport ¶
func (mr *MockDeviceMockRecorder) SendOutputReport(data any) *gomock.Call
SendOutputReport indicates an expected call of SendOutputReport.
func (*MockDeviceMockRecorder) SetAutoDetach ¶
func (mr *MockDeviceMockRecorder) SetAutoDetach(autoDetach any) *gomock.Call
SetAutoDetach indicates an expected call of SetAutoDetach.
func (*MockDeviceMockRecorder) SetTarget ¶
func (mr *MockDeviceMockRecorder) SetTarget(confNumber, infNumber, altNumber any) *gomock.Call
SetTarget indicates an expected call of SetTarget.
func (*MockDeviceMockRecorder) WriteOutput ¶
func (mr *MockDeviceMockRecorder) WriteOutput(ctx, data any) *gomock.Call
WriteOutput indicates an expected call of WriteOutput.
type ReportType ¶
type ReportType uint8
const ( REPORT_TYPE_INPUT ReportType = 0x01 REPORT_TYPE_OUTPUT ReportType = 0x02 REPORT_TYPE_FEATURE ReportType = 0x03 )
type SetupEndpointDirection ¶
type SetupEndpointDirection uint8
const ( SETUP_EP_DIR_OUT SetupEndpointDirection = 0x00 SETUP_EP_DIR_IN SetupEndpointDirection = 0x80 )
type SetupRequest ¶
type SetupRequest uint8
const ( SETUP_REQUEST_GET_DESCRIPTOR SetupRequest = 0x06 SETUP_REQUEST_HID_GET_REPORT SetupRequest = 0x01 SETUP_REQUEST_HID_GET_IDLE SetupRequest = 0x02 SETUP_REQUEST_HID_GET_PROTOCOL SetupRequest = 0x03 SETUP_REQUEST_HID_SET_REPORT SetupRequest = 0x09 SETUP_REQUEST_HID_SET_IDLE SetupRequest = 0x0A SETUP_REQUEST_HID_SET_PROTOCOL SetupRequest = 0x0B )
type SetupRequestRecipient ¶
type SetupRequestRecipient uint8
const ( SETUP_RECIPIENT_DEVICE SetupRequestRecipient = 0x00 SETUP_RECIPIENT_INTERFACE SetupRequestRecipient = 0x01 SETUP_RECIPIENT_ENDPOINT SetupRequestRecipient = 0x02 SETUP_RECIPIENT_OTHER SetupRequestRecipient = 0x03 )
type SetupRequestType ¶
type SetupRequestType uint8
const ( SETUP_REQUEST_TYPE_STANDARD SetupRequestType = 0x00 << 5 SETUP_REQUEST_TYPE_CLASS SetupRequestType = 0x01 << 5 SETUP_REQUEST_TYPE_VENDOR SetupRequestType = 0x02 << 5 SETUP_REQUEST_TYPE_RESERVED SetupRequestType = 0x03 << 5 )