public static void UpdateAvailableDecives(GamepadInputCollection inputManager)
        {
            const int MinDeviceCheckCount = 8;
            const int MaxDeviceCheckCount = 32;

            // Determine which devices are currently active already, so we can skip their indices
            List <int> skipIndices = null;

            foreach (GamepadInput input in inputManager)
            {
                GlobalGamepadInputSource existingDevice = input.Source as GlobalGamepadInputSource;
                if (existingDevice != null)
                {
                    if (skipIndices == null)
                    {
                        skipIndices = new List <int>();
                    }
                    skipIndices.Add(existingDevice.deviceIndex);
                }
            }

            // Iterate over device indices and see what responds
            int deviceIndex = -1;

            while (deviceIndex < MaxDeviceCheckCount)
            {
                deviceIndex++;

                if (skipIndices != null && skipIndices.Contains(deviceIndex))
                {
                    continue;
                }

                while (deviceIndex >= cachedDevices.Count)
                {
                    cachedDevices.Add(new GlobalGamepadInputSource(cachedDevices.Count));
                }
                GlobalGamepadInputSource gamepad = cachedDevices[deviceIndex];
                gamepad.UpdateState();

                if (gamepad.IsAvailable)
                {
                    inputManager.AddSource(gamepad);
                    App.Log(
                        "Detected new Gamepad Input: \"{0}\" ({1} | {2}) at index {3}",
                        gamepad.Id,
                        gamepad.ProductId,
                        gamepad.ProductName,
                        deviceIndex);
                }
                else if (deviceIndex >= MinDeviceCheckCount)
                {
                    break;
                }
            }
        }
示例#2
0
        public static void UpdateAvailableDecives(GamepadInputCollection inputManager)
        {
            const int MinDeviceCheckCount = 8;

            // Determine which devices are currently active already, so we can skip their indices
            List <int> skipIndices = null;

            foreach (GamepadInput input in inputManager)
            {
                GlobalGamepadInputSource existingDevice = input.Source as GlobalGamepadInputSource;
                if (existingDevice != null)
                {
                    if (skipIndices == null)
                    {
                        skipIndices = new List <int>();
                    }
                    skipIndices.Add(existingDevice.deviceIndex);
                }
            }

            // Iterate over device indices and see what responds
            int deviceIndex = -1;

            while (true)
            {
                deviceIndex++;

                if (skipIndices != null && skipIndices.Contains(deviceIndex))
                {
                    continue;
                }

                GlobalGamepadInputSource gamepad = new GlobalGamepadInputSource(deviceIndex);
                gamepad.UpdateState();

                if (gamepad.IsAvailable)
                {
                    inputManager.AddSource(gamepad);
                }
                else if (deviceIndex >= MinDeviceCheckCount)
                {
                    break;
                }
            }
        }
示例#3
0
        private void WriteInputStats(ref FormattedText target, GamepadInputCollection inputCollection)
        {
            // Initialize the formatted text block we'll write to
            this.PrepareFormattedText(ref target);

            // Compose the formatted text to display
            string allText = "/f[1]Gamepad Stats/f[0]";

            foreach (GamepadInput input in inputCollection)
            {
                string inputText = this.GetInputStatsText(input);
                if (allText.Length != 0)
                {
                    allText += "/n/n";
                }
                allText += inputText;
            }

            target.SourceText = allText;
        }
        public static void UpdateAvailableDecives(GamepadInputCollection inputManager)
        {
            const int MinDeviceCheckCount = 8;

            // Determine which devices are currently active already, so we can skip their indices
            List<int> skipIndices = null;
            foreach (GamepadInput input in inputManager)
            {
                GlobalGamepadInputSource existingDevice = input.Source as GlobalGamepadInputSource;
                if (existingDevice != null)
                {
                    if (skipIndices == null) skipIndices = new List<int>();
                    skipIndices.Add(existingDevice.deviceIndex);
                }
            }

            // Iterate over device indices and see what responds
            int deviceIndex = -1;
            while (true)
            {
                deviceIndex++;

                if (skipIndices != null && skipIndices.Contains(deviceIndex))
                    continue;

                GlobalGamepadInputSource gamepad = new GlobalGamepadInputSource(deviceIndex);
                gamepad.UpdateState();

                if (gamepad.IsAvailable)
                    inputManager.AddSource(gamepad);
                else if (deviceIndex >= MinDeviceCheckCount)
                    break;
            }
        }
		public static void UpdateAvailableDecives(GamepadInputCollection inputManager)
		{
			const int MinDeviceCheckCount = 8;
			const int MaxDeviceCheckCount = 32;

			// Determine which devices are currently active already, so we can skip their indices
			List<int> skipIndices = null;
			foreach (GamepadInput input in inputManager)
			{
				GlobalGamepadInputSource existingDevice = input.Source as GlobalGamepadInputSource;
				if (existingDevice != null)
				{
					if (skipIndices == null) skipIndices = new List<int>();
					skipIndices.Add(existingDevice.deviceIndex);
				}
			}

			// Iterate over device indices and see what responds
			int deviceIndex = -1;
			while (deviceIndex < MaxDeviceCheckCount)
			{
				deviceIndex++;

				if (skipIndices != null && skipIndices.Contains(deviceIndex))
					continue;

				while (deviceIndex >= cachedDevices.Count)
				{
					cachedDevices.Add(new GlobalGamepadInputSource(cachedDevices.Count));
				}
				GlobalGamepadInputSource gamepad = cachedDevices[deviceIndex];
				gamepad.UpdateState();

				if (gamepad.IsAvailable)
				{
					inputManager.AddSource(gamepad);
					Log.Core.Write(
						"Detected new Gamepad Input: \"{0}\" at index {1}",
						gamepad.Description, deviceIndex);
				}
				else if (deviceIndex >= MinDeviceCheckCount)
					break;
			}
		}
示例#6
0
		private void WriteInputStats(ref FormattedText target, GamepadInputCollection inputCollection)
		{
			// Initialize the formatted text block we'll write to
			this.PrepareFormattedText(ref target);

			// Compose the formatted text to display
			string allText = "/f[1]Gamepad Stats/f[0]";
			foreach (GamepadInput input in inputCollection)
			{
				string inputText = this.GetInputStatsText(input);
				if (allText.Length != 0)
					allText += "/n/n";
				allText += inputText;
			}

			target.SourceText = allText;
		}