Created
June 27, 2014 14:04
-
-
Save elbruno/5d980a62502bb8ba910b to your computer and use it in GitHub Desktop.
Sample code to get the DeviceInfo for a XBoxOne Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using DeviceManagement; | |
namespace ConsoleApplication2 | |
{ | |
class DeviceInspection | |
{ | |
public DeviceInfo GetXBoxController() | |
{ | |
// you need nuget pkg https://devicemgr.codeplex.com/ | |
// ClassName: "XB1UsbClass" | |
// Desc: "Microsoft Xbox One Controller" | |
var allClasses = DeviceInfoSet.GetAllClassesPresent(); | |
var devices = allClasses.GetDevices(); | |
return (from device in devices | |
where device.ClassName == "XB1UsbClass" | |
select device).FirstOrDefault(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This might be a completely dumb question, but is DeviceManagement defined somewhere? I want to experiment with the Xbox One controller as input to some of my windows forms applications.