public static void UpdateAvailableDecives(JoystickInputCollection 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 (JoystickInput input in inputManager) { GlobalJoystickInputSource existingDevice = input.Source as GlobalJoystickInputSource; 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 GlobalJoystickInputSource(cachedDevices.Count)); } GlobalJoystickInputSource joystick = cachedDevices[deviceIndex]; joystick.UpdateState(); if (joystick.IsAvailable) { inputManager.AddSource(joystick); Log.Write(LogType.Verbose, "Detected new Joystick Input: \"{0}\" ({1} | {2}) at index {3}" + Environment.NewLine + "Capabilities: {4} axes, {5} buttons, {6} hats", joystick.Id, joystick.ProductId, joystick.ProductName, deviceIndex, joystick.AxisCount, joystick.ButtonCount, joystick.HatCount); } else if (deviceIndex >= MinDeviceCheckCount) { break; } } }
public static void UpdateAvailableDecives(JoystickInputCollection inputManager) { const int MinDeviceCheckCount = 8; // Determine which devices are currently active already, so we can skip their indices List<int> skipIndices = null; foreach (JoystickInput input in inputManager) { GlobalJoystickInputSource existingDevice = input.Source as GlobalJoystickInputSource; 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; GlobalJoystickInputSource joystick = new GlobalJoystickInputSource(deviceIndex); joystick.UpdateState(); if (joystick.IsAvailable) inputManager.AddSource(joystick); else if (deviceIndex >= MinDeviceCheckCount) break; } }
public static void UpdateAvailableDecives(JoystickInputCollection inputManager) { const int MinDeviceCheckCount = 8; // Determine which devices are currently active already, so we can skip their indices List <int> skipIndices = null; foreach (JoystickInput input in inputManager) { GlobalJoystickInputSource existingDevice = input.Source as GlobalJoystickInputSource; 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; } GlobalJoystickInputSource joystick = new GlobalJoystickInputSource(deviceIndex); joystick.UpdateState(); if (joystick.IsAvailable) { inputManager.AddSource(joystick); } else if (deviceIndex >= MinDeviceCheckCount) { break; } } }
private void WriteInputStats(ref FormattedText target, JoystickInputCollection inputCollection) { // Initialize the formatted text block we'll write to this.PrepareFormattedText(ref target); // Compose the formatted text to display string allText = "/f[1]Joystick Stats/f[0]"; foreach (JoystickInput input in inputCollection) { string inputText = this.GetInputStatsText(input); if (allText.Length != 0) { allText += "/n/n"; } allText += inputText; } target.SourceText = allText; }
public static void UpdateAvailableDecives(JoystickInputCollection 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 (JoystickInput input in inputManager) { GlobalJoystickInputSource existingDevice = input.Source as GlobalJoystickInputSource; 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 GlobalJoystickInputSource(cachedDevices.Count)); } GlobalJoystickInputSource joystick = cachedDevices[deviceIndex]; joystick.UpdateState(); if (joystick.IsAvailable) { inputManager.AddSource(joystick); Log.Core.Write( "Detected new Joystick Input: \"{0}\" at index {1}" + Environment.NewLine + "Capabilities: {2} axes, {3} buttons, {4} hats", joystick.Description, deviceIndex, joystick.AxisCount, joystick.ButtonCount, joystick.HatCount); } else if (deviceIndex >= MinDeviceCheckCount) break; } }
private void WriteInputStats(ref FormattedText target, JoystickInputCollection inputCollection) { // Initialize the formatted text block we'll write to this.PrepareFormattedText(ref target); // Compose the formatted text to display string allText = "/f[1]Joystick Stats/f[0]"; foreach (JoystickInput input in inputCollection) { string inputText = this.GetInputStatsText(input); if (allText.Length != 0) allText += "/n/n"; allText += inputText; } target.SourceText = allText; }