采用微软DirectX的DirectInput编程,控制游戏手柄,游戏摇杆
项目想要用游戏摇杆控制无人车,用莱仕达的雷霆PRO做实验。
源码用VS2015写的,winform程序。
摇杆实物图:
软件界面:
部分代码:
查找设备
public string FindJoysticks()
{
systemJoysticks = null;
try
{
// Find all the GameControl devices that are attached.
DeviceList gameControllerList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly);
// check that we have at least one device.
if (gameControllerList.Count > 0)
{
foreach (DeviceInstance deviceInstance in gameControllerList)
{
// create a device from this controller so we can retrieve info.
joystickDevice = new Device(deviceInstance.InstanceGuid)</