UWP CreateOutputReport failed to create report ID

yu chen 20 Reputation points
2023-01-13T03:54:22.5666667+00:00

The following code has an error, System. Exception: "The data is invalid. The specified report type is not present. What is the reason?

Error statement:

var outputReport = hiddevice.CreateOutputReport(0); 

The handle was opened, but the output report could not be created. My handle report descriptor did not output the report. Is that why? If this is the reason, how can I write data on the game handle?

//HIDConfigura.cs
namespace HIDGamepade
{
    class HIDConfigura
    {
        public class Xbox360//360xbox
        {
            public class Device
            {
                public const UInt16 Vid = 0x045E;
                public const UInt16 Pid = 0x028E;
                public const UInt16 UsagePage = 0x01;
                public const UInt16 UsageId = 0x05;
            }
}

//Package.appxmanifest
<Capabilities>
	  <DeviceCapability Name="humaninterfacedevice">
		  <!--xbox one device-->
		  <Device Id="vidpid:045E 028E">
			  <Function Type="usage:0001 0005" />
		  </Device>
		  <Device Id="vidpid:054C 0268">
			  <Function Type="usage:0001 0004" />
		  </Device>
	  </DeviceCapability>
  </Capabilities>

//HIDDevice.cs
public async Task<Boolean> OpenDevice()
{
            Boolean connectdevice = await ConnectDevice();
            //打开手柄设备是否成功
            Boolean OpenSuccess = false;

            if (connectdevice)
            {
                //打开 deviceId 参数标识的设备句柄。 访问类型由 accessMode 参数指定
                hiddevice = await HidDevice.FromIdAsync(device.Id, Windows.Storage.FileAccessMode.ReadWrite);

                //var controlDataList = hiddevice.GetNumericControlDescriptions(HidReportType.Feature,0,usageId)
                if (hiddevice != null)
                {
                    OpenSuccess = true;
                    //打开手柄设备成功
                    return OpenSuccess;
                }
                
            }
            //没有找到设备
            return OpenSuccess;
}
public async Task WriteByte(Byte[] buffers)        
{            if (hiddevice != null)            
             {                
                //创建主机发送到设备的唯一输出报表                 
                var outputReport = hiddevice.CreateOutputReport(0);                                                           //以多少bit发送一次   
//Byte dataByte = (byte)(buffer << 64);   //实例化写入设备               
            var dataWrite = new DataWriter();   //第一个字节始终是报告id                          dataWrite.WriteByte((Byte)outputReport.Id);               
            for (int i = 0; i < 1024; i++)                
            {                    
              dataWrite.WriteByte(buffers[i]);                
            }                
          //分离与数据编译器关联的缓冲区,返回分离的缓冲区                
          outputReport.Data = dataWrite.DetachBuffer();               
          //主机向设备异步发送一个输出报告                
          uint bytesWritten = await hiddevice.SendOutputReportAsync(outputReport);            
         }        
}
Universal Windows Platform (UWP)
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,221 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Roy Li - MSFT 31,681 Reputation points Microsoft Vendor
    2023-02-24T06:50:03.1633333+00:00

    Hello,

    Welcome to Microsoft Q&A!

    I've got the response from the Xbox Team about this.

    How to use the UWP api to upgrade the firmware of the game handle?

    This is not possible in UWP app. First of all, Windows.Devices.HumanInterfaceDevices API of UWP are not supported on Xbox devices - UWP features not supported on Xbox. These APIs are only supported on PC.

    Second, the correct way to communicate with devices supported on Xbox is using the Game Input Protocol. To use the Game Input Protocol, you will need to join the Xbox Partner Hardware / Designed for Xbox program. Then you could be a licensed partners who sign Xbox PDK/NDA agreements. Here is the link for Designed for Xbox program: https://www.xbox.com/en-US/designed-for-xbox?xr=shellnav

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments