Пример #1
0
        /// <summary>
        /// Does the work of scanning the devices and updating the DoWorkEventArgs.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void deviceScanDoWork(object sender, DoWorkEventArgs e)
        {
            // enumerate available devices
            List <Joystick.DeviceInfo> devices = Joystick.GetAvailableDevices();

            string result = "Found " + devices.Count() + " devices";

            foreach (Joystick.DeviceInfo di in devices)
            {
                string deviceInfo = string.Format("{0} : {1} ({2} axes, {3} buttons)",
                                                  di.ID,
                                                  di.Name,
                                                  di.Axes,
                                                  di.Buttons);
                System.Diagnostics.Debug.WriteLine(deviceInfo);
                result += deviceInfo;
            }

            /*
             * // create new joystick and initialize it
             * Joystick joystick = new Joystick(0);
             * // get its current status
             * Joystick.Status status = joystick.GetCurrentStatus();
             * // check if 1st button is pressed
             * if (status.IsButtonPressed(Joystick.Buttons.Button1))
             * {
             *  // 1st button is pressed
             * }
             */

            //Set the result to our device information that we found
            e.Result = result;
        }
Пример #2
0
        public MainForm( )
        {
            InitializeComponent( );

            videoModeCombo.SelectedIndex = 0;
            EnableConnectionControls(false);

            ipAddressBox.Text = "192.168.0.12";
            //ipAddressBox.Text = "127.0.0.1";

            // register for HTTP request completion events
            commandsThread.HttpCommandCompletion += commandsThread_HttpCommandCompletion;

            // events used for signalling about completed requests
            freeEventsQueue.Enqueue(new AutoResetEvent(false));
            freeEventsQueue.Enqueue(new AutoResetEvent(false));
            freeEventsQueue.Enqueue(new AutoResetEvent(false));

            //  event used for signalling distance measurement thread to stop
            stopDistanceMeasurementEvent = new ManualResetEvent(false);

            // check for available game pads in the system
            List <Joystick.DeviceInfo> gamepadDevices = Joystick.GetAvailableDevices( );

            if (gamepadDevices.Count == 0)
            {
                gamePadsCombo.Items.Add("Not available");
                gamePadsCombo.Enabled    = false;
                useGamepadButton.Enabled = false;
            }
            else
            {
                foreach (Joystick.DeviceInfo pad in gamepadDevices)
                {
                    gamePadsCombo.Items.Add(pad.Name);
                }
            }

            gamePadsCombo.SelectedIndex = 0;
        }