最終更新:2014-12-18 (木) 14:07:26 (1618d)  

Featureレポート はてなブックマークを見る
Top / Featureレポート

A feature report specifies configuration information for a device.

Data blobs that can be manually read and/or written, and are typically related to configuration information.

デバイスのコンフィギュレーション情報を指定するレポート。常にエンドポイント0を使用する。

概要

  • Feature reports are used for specific static device features and never reported spontaneously.
  • A host can read and/or write them to access data like battery-state or device-settings.
  • Feature reports are never sent without requests. A host must explicitly set or retrieve a feature report.
  • This also means, feature reports are never sent on the intr channel as this channel is asynchronous.

USB/クラスリクエスト

GET_REPORT

SET_REPORT

hid.dllの関数

Elotouch Driver

  • IOCTL_HID_GET_FEATURE
    NTSTATUS INTERNAL
    NInputGetFeatureReport(
        __in WDFDEVICE Device,
        __in WDFREQUEST Request
        )
    /*++
    
    Routine Description:
    
       Gets feature report
    
    Arguments:
    
       Device - WDF device
    
       Request - WDF request
    
    Return Value:
      SUCCESS - Returns STATUS_SUCCESS.
      FAILURE - Returns NT status code.
    
    --*/
    {
        NTSTATUS                 status = STATUS_SUCCESS;
        PHID_XFER_PACKET         FeaturePacket  = NULL;
        PDEVICE_EXTENSION        deviceInfo = NULL;
        WDF_REQUEST_PARAMETERS   params = {0};
    
    
        UNREFERENCED_PARAMETER(Device);
    
        WDF_REQUEST_PARAMETERS_INIT(&params);
        WdfRequestGetParameters(Request, &params);
    
        KdPrint(("Retrieving config mode\n"));
        deviceInfo = GetDeviceContext(WdfIoQueueGetDevice(WdfRequestGetIoQueue(Request)));
    
        //
        // IOCTL_HID_SET_FEATURE & IOCTL_HID_GET_FEATURE are not METHOD_NIEHTER
        // IOCTLs. So you cannot retreive UserBuffer from the IRP using Wdf
        // function. As a result we have to escape out to WDM to get the UserBuffer
        // directly from the IRP. 
        //
    
        if (params.Parameters.DeviceIoControl.OutputBufferLength < sizeof(HID_XFER_PACKET)) {
            status = STATUS_BUFFER_TOO_SMALL;
            KdPrint(("Output Buffer:%d is too smalll!\n", params.Parameters.DeviceIoControl.OutputBufferLength));
    
        }
        else {
    
            FeaturePacket = (PHID_XFER_PACKET) WdfRequestWdmGetIrp(Request)->UserBuffer;
            if (FeaturePacket == NULL) {
                status = STATUS_INVALID_DEVICE_REQUEST;
                KdPrint(("FeaturePacket == NULL!\n"));            
            }
            else
            {        
                UCHAR ReportId = *(PUCHAR)FeaturePacket->reportBuffer;
                if(REPORTID_FEATURE == ReportId &&
                    FeaturePacket->reportBufferLen >= sizeof(HID_FEATURE_REPORT))
                {  
                   PHID_FEATURE_REPORT InputModeReport = (PHID_FEATURE_REPORT)FeaturePacket->reportBuffer; 
                   InputModeReport->InputMode = deviceInfo->InputMode;
    
                }
                else if(REPORTID_MAX_COUNT == ReportId && 
                    FeaturePacket->reportBufferLen >= sizeof(HID_MAX_COUNT_REPORT))
                {                
                   PHID_MAX_COUNT_REPORT MaxCountReport = (PHID_MAX_COUNT_REPORT)FeaturePacket->reportBuffer;
                   MaxCountReport->MaxCount = ELO_MT_MAX_COUNT;
                }
                else
                {
                    status = STATUS_INVALID_PARAMETER;
                    KdPrint(("Wrong feature report id or length expected ids: Feauture:%d,  MaxCount:%d actual:%d  expected length: Feature:%d, or MaxCount:%d actual:%d!\n", 
                        REPORTID_FEATURE, REPORTID_MAX_COUNT, ReportId, sizeof(HID_FEATURE_REPORT), sizeof(HID_MAX_COUNT_REPORT), FeaturePacket->reportBufferLen));
                }
            } 
    
        }   
        TExit(Func, ("=%x", status));
        return status;
    }

メモ

関連