Wednesday, 7 September 2016

Using RacingWheels and other kind of devices in Windows.Gaming.Input

Now that UWP (Universal Windows Platform) is out (and apparently the way to go for video games), a decent Input API was more than needed, to be able to use controllers like racing wheels. And that API is Windows.Gaming.Input.

I already talked about this topic last month, but no matter how hard I tried to make my Logitech G27 be recognized by the API, it simply didn't work. And it was hard to do something wrong in the code, as reading the controller is as simple and straightforward as checking the contents of a collection.

I simply assumed that the API, or the Logitech Driver, or Windows, had problems with certain controllers somehow. And provided that the G27 is a bit old, and that Logitech hasn't updated the drivers since last March, that sounded realistic.

But yesterday, Forza 6 Apex was updated (and taken out of BETA), and finally announced steering wheel support, so I quickly updated it, just to check (to my surprise) that my G27 worked perfectly.

And it's a UWP too, so it was clearly not due to a bug in the API or the driver, but a problem in my application. Provided that the code is so simple, it had to be some configuration issue, and yes, it was...

I checked a thousand times the Capabilities section of the AppxManifest, but I never saw anything that seemed related. But thanks to Mark Thompson (and to the XBox Developer Forums), now I found out what should be added to the AppxManifest in order to make it work.

Simply add the following to the Capabilities section:

 <DeviceCapability Name="humaninterfacedevice">  
     <Device Id="any">  
      <Function Type="usage:0001 0004"/>  
      <Function Type="usage:0001 0005"/>  
     </Device>  
  </DeviceCapability>  

Et voilá. Now the G27 is properly recognized by the app. I still don't understand why this is needed for racing wheel, but not for gamepads.

However, you can find more info here:

Microsoft guys told us that this will be added to the docs soon, but for now, it's not there.

Hope it helps!

No comments: