Share via


ISoftHIDProtocolXlator::WriteInputReport Method

The WriteInputReport method sends a HID report to the host.

Syntax

HRESULT WriteInputReport(
  [in]  SAFEARRAY psaInputReport
);

Parameters

  • psaInputReport [in]
    A pointer to SAFEARRAY of unsigned char values that contain the raw bytes of the HID report. The caller can free this array after WriteInputReport returns.

Return Value

WriteInputReport returns S_OK if the operation succeeds. This method can return other standard COM return values.

Remarks

The WriteInputReport method adds the HID report to the device's interrupt-IN endpoint data queue and returns. A successful return from this method does not indicate that the host has successfully retrieved the HID report from the controller. The only way for a device simulator to check whether the host has received the report is to use Microsoft Win32 or other API functions to retrieve the input to the system. For example, after a keyboard simulator calls WriteInputReport to send a keystroke to the host, it could check for a WM_CHAR message that is addressed to the window that currently has input focus.

The following C++ code example shows you how to call WriteInputReport.

 HRESULT WriteInputReport
(
 ISoftHIDProtocolXlator *piSoftHIDProtocolXlator,
    BYTE                   *pbReport,
    unsigned int cbReport
)
{
    HRESULT     hr          = S_OK;
    SAFEARRAY  *psaReport   = NULL;
    BYTE HUGEP *pbArrayData = NULL;

 psaReport = ::SafeArrayCreateVector(VT_UI1, 0, cbReport);
    if (SUCCEEDED(hr))
    {
        hr = ::SafeArrayAccessData(psaReport, &pbArrayData);
        if (SUCCEEDED(hr))
        {
            ::memcpy(pbArrayData, pbReport, cbReport);
            hr = ::SafeArrayUnaccessData(psaReport);
            if (SUCCEEDED(hr))
            {
                hr = piSoftHIDProtocolXlator->WriteInputReport(psaReport);
            }
        }
        (void)::SafeArrayDestroy(psaReport);
    }
}

Requirements

Header

SoftHIDUSBif.h

See Also

ISoftHIDProtocolXlator

 

 

Send comments about this topic to Microsoft

Build date: 9/21/2010