ISoftUSBEndpointEvents::OnDeviceRequestComplete Method
The OnDeviceRequestComplete event enables the device simulator to determine the final status of a request. This event is fired for control endpoints when the status phase transaction is received for a device request.
Syntax
HRESULT OnDeviceRequestComplete(
[in] ULONG RequestHandle,
[out] BYTE *pbFinalRequestStatus
);
Parameters
RequestHandle [in]
A handle that defines the request.pbFinalRequestStatus [out]
The status of the request, which is returned to the host controller.
Return Value
OnDeviceRequestComplete returns an HRESULT value.
Remarks
The OnDeviceRequestComplete event is fired to complete the transaction that is associated with a SETUP transfer from the OnDeviceRequest event. This event gives the device the opportunity to update the final status of the transfer.
The following C++ code example shows how to handle the completion of a device request.
STDMETHODIMP CSoftUSBEndpointEvent::OnDeviceRequestComplete(
__in ULONG_PTR RequestHandle,
__out BYTE *pbFinalRequestStatus)
{
// Set the return error code in case the device is not handling requests
HRESULT hr = E_NOINTERFACE;
// Verify the incoming variables and initialize them
if (NULL == pbFinalRequestStatus)
{
hr = E_POINTER;
goto Exit;
}
*pbFinalRequestStatus = USB_STALL;
if (g_fHandleDeviceRequests)
{
hr = S_OK;
// If this request is the request that the device just handled, ACK the return
// Otherwise NAK the return so the host will retry
if (RequestHandle != m_ulDescriptorHandle)
{
*pbFinalRequestStatus = USB_NAK;
}
else
{
*pbFinalRequestStatus = USB_ACK;
m_ulDescriptorHandle = 0;
}
}
Exit:
return hr;
}
Requirements
Header |
SoftUSBif.h |
See Also
ISoftUSBEndpointEvents::OnDeviceRequest
Send comments about this topic to Microsoft
Build date: 9/21/2010