Ejemplo n.º 1
0
        /// <summary>
        /// Set up the inputs for running in arcade board mode
        /// </summary>
        private void SetupArcadeInputs()
        {
            this.Buzzers = new List <Buzzer>();

            this.arcadeJoystick = null;

            // Initialize DirectInput
            var directInput = new DirectInput();

            // Find a Joystick Guid
            var joystickGuid = Guid.Empty;

            foreach (var deviceInstance in directInput.GetDevices(DeviceType.Joystick, DeviceEnumerationFlags.AllDevices))
            {
                joystickGuid = deviceInstance.InstanceGuid;
            }

            if (joystickGuid != Guid.Empty)
            {
                this.arcadeJoystick = new Joystick(directInput, joystickGuid);
                this.arcadeJoystick.Properties.BufferSize = 128;
                this.arcadeJoystick.Acquire();

                int buzzerCount = 0;

                var buzzer = new Buzzer();

                // Figure out how many players there are
                foreach (var joystickObject in this.arcadeJoystick.GetObjects())
                {
                    if (joystickObject.Name != null && joystickObject.Name.Contains("Button"))
                    {
                        buzzerCount++;
                    }
                }

                this.lblBuzzersDetected.Text = buzzerCount.ToString();
                buzzer.BuzzerIndex           = 0;
                buzzer.AddPlayers(buzzerCount);
                this.Buzzers.Add(buzzer);
            }

            if (this.arcadeBuzzTimer != null)
            {
                this.arcadeBuzzTimer.Stop();
                this.arcadeBuzzTimer.Dispose();
            }

            this.arcadeBuzzTimer          = new System.Timers.Timer();
            this.arcadeBuzzTimer.Elapsed += new ElapsedEventHandler(this.HandleArcadeBuzzes);
            this.arcadeBuzzTimer.Interval = 1;
            this.arcadeBuzzTimer.Start();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds all buzz handsets.
        /// </summary>
        /// <returns>A list of all new buzz handsets.</returns>
        public static List <Buzzer> FindBuzzHandsets()
        {
            // VID and PID for Buzz device are 0x054c and 0x1000 respectively
            List <HIDDevice> devices = FindDevices(0x054c, 0x1000, typeof(Buzzer));
            List <Buzzer>    buzzers = new List <Buzzer>();
            int index = 0;

            foreach (HIDDevice device in devices)
            {
                Buzzer buzzer = (Buzzer)device;
                buzzer.BuzzerIndex = index;
                buzzer.AddPlayers();
                buzzers.Add(buzzer);
                index++;
            }

            return(buzzers);
        }