Пример #1
0
uint16_t CALLBACK_USB_GetDescriptor(uint16_t const wValue, uint8_t wIndex, void const **const outDescriptor) {
    uint8_t const type = wValue >> 8;
    uint8_t const index = wValue & 0xff;

    switch (type) {
        case DTYPE_Device:
            return getDeviceDescriptor(outDescriptor);

        case DTYPE_Configuration:
            return getConfigurationDescriptor(outDescriptor);

        case HID_DTYPE_HID:
            return getMouseHIDDescriptor(outDescriptor);

        case HID_DTYPE_Report:
            return getMouseReportDescriptor(outDescriptor);

        case DTYPE_String: {
            switch (index) {
                case kLanguageDescriptorIndex: return getLanguageDescriptor(outDescriptor);
                case kManufacturerDescriptorIndex: return getManufacturerDescriptor(outDescriptor);
                case kProductDescriptorIndex: return getProductDescriptor(outDescriptor);
                default: return NO_DESCRIPTOR;
            }
        }

        default: return NO_DESCRIPTOR;
    }
}
Пример #2
0
std::shared_ptr<LibUSB::Endpoint> LibUSB::DeviceImpl::getControlEndpoint()
{

	if (m_pEndpointZero.get() == nullptr)
	{

		// Initialize Endpoint Zero Dummy Descriptor
		m_EndpointZeroDescriptor.bLength = 0x07;
		m_EndpointZeroDescriptor.bDescriptorType = libusb_descriptor_type::LIBUSB_DT_ENDPOINT;
		m_EndpointZeroDescriptor.bEndpointAddress = 0;
		m_EndpointZeroDescriptor.bmAttributes = 0;
		m_EndpointZeroDescriptor.wMaxPacketSize = getDeviceDescriptor()->bMaxPacketSize0;
		m_EndpointZeroDescriptor.bInterval = 0;

		// All your endpoints are belong to us.
		std::shared_ptr<LibUSB::EndpointImpl> pEPImpl = std::make_shared<LibUSB::EndpointImpl>(&m_EndpointZeroDescriptor, shared_from_this());
		m_pEndpointZero = std::make_shared<LibUSB::Endpoint>(pEPImpl);

	}

	return m_pEndpointZero;
	
}
Пример #3
0
std::vector<EndpointInfo> DeviceInfo::getAllEndpointInfo() {
	return getEndpointInfo(getDeviceDescriptor());
}