Esempio n. 1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            #if QuickTest
            DirectInput di = new DirectInput();
            di.Setup();
            DeviceInstance[] connected = di.ListDevices(DeviceClass.GameController, DeviceFlag.AttachedOnly);
            if (connected.Length > 0)
            {
                if (connected.Length > 0)
                {
                    DirectInput8Device device = di.CreateDevice(connected[0].guidInstance);
                    device.SetDataFormat(DataFormat.Joystick2);
                    device.Acquire();

                    if (device.Update())
                    {
                        JoyState2 state = (JoyState2)device.State;
                    }
                    else
                    {
                        System.Diagnostics.Debugger.Break();
                    }
                }
            }
            #endif
            Application.Run(new MainForm());
        }
        public void Test_DI_GetDevices()
        {
            DirectInput di = new DirectInput();

            di.Setup();
            DeviceInstance[] devices = di.ListDevices(DeviceClass.GameController, DeviceFlag.AttachedOnly);
            if (devices.Length > 0)
            {
                DirectInput8Device device = di.CreateDevice(devices[0].guidInstance);
            }
        }
Esempio n. 3
0
 private void MainForm_Shown(object sender, EventArgs e)
 {
     di.Setup();
     foreach (DeviceInstance instance in di.ListDevices(DeviceClass.GameController, DeviceFlag.AttachedOnly))
     {
         DirectInput8Device device = di.CreateDevice(instance.guidInstance);
         device.SetDataFormat(DataFormat.Joystick2);
         AddDevice(device);
     }
     timer1.Enabled = true;
 }