我试图创建一个程序,它的输入从USB PS2的手控制器,翻译和传递信息到RS232设备。我已经拥有了一切努力为RS232设备。问题是接口与USB控制器。目前似乎没有任何良好的文档存在,并且在该.NET3.0的顶部/ 3.5没有任何库,为您排忧解难。如何将一个甚至可以开始了吗?
I'm attempting to create a program that takes input from a usb ps2 hand controller, translate and passes the info to a rs232 device. I already have everything working for the rs232 device. The problem is interfacing with a usb controller. There doesn't seem to be any good documentation out there and on top of that .NET3.0/3.5 doesn't have any libs to help you out. How would one even get started?
这可能是几年的旧线...... anywho ....我知道SlimDX是C#.net / VB一个pretty的良好库。而且,使用USB控制器,这是非常简单的,所有你需要做的就是这样的事情。请注意,这code我在飞行,我没有摇杆进行测试,这...
it may be a few years old thread...anywho.... I know SlimDX is a pretty good library for C#.Net/VB. And, to use a USB controller, it is very simple, all you need to do is something like this. Note, this code I made on the fly and I don't have joystick to test it, and this...
static Joystick[] joystick = new Joystick[1];
const int minimum_value = -1000;//your values goes here
const int maximum_value = 1000;//your values goes here
public test()
{
DirectInput USBJoystick = new DirectInput();
IList<DeviceInstance> device = null;//to get the joysticks
device = USBJoystick.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly);
if (device.Count == 1)
joystick[0] = new Joystick(USBJoystick, device[0].InstanceGuid);
foreach (DeviceObjectInstance deviceObject in joystick[0].GetObjects())
{
if ((deviceObject.ObjectType & ObjectDeviceType.Axis) != 0)
joystick[0].GetObjectPropertiesById((int)deviceObject.ObjectType).SetRange(minimum_value, maximum_value);
}
}