public static List<GenericInput> GetNewInputDevices(IntPtr windowHandle, List<GenericInput> currentDevices) { List<GenericInput> newDevices = new List<GenericInput>(); DeviceList gameControllerList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly); for (int i = 0; i < gameControllerList.Count; i++) { gameControllerList.MoveNext(); DeviceInstance deviceInstance = (DeviceInstance)gameControllerList.Current; Device device = null; try { device = new Device(deviceInstance.InstanceGuid); } catch (Exception) { } if (device != null && device.DeviceInformation.ProductGuid != new Guid("0306057e-0000-0000-0000-504944564944") && // Wiimotes are excluded !CheckIfDirectInputDeviceExists(device, currentDevices)) { AcquireDirectInputDevice(windowHandle, device, DeviceDataFormat.Joystick); JoystickInput input = new JoystickInput(device); newDevices.Add(input); } } return newDevices; }
private void AddJoystickDevices(IntPtr windowHandle) { DeviceList gameControllerList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly); for (int i = 0; i < gameControllerList.Count; i++) { gameControllerList.MoveNext(); DeviceInstance deviceInstance = (DeviceInstance)gameControllerList.Current; Device device = new Device(deviceInstance.InstanceGuid); if (device.DeviceInformation.ProductGuid != new Guid("0306057e-0000-0000-0000-504944564944") && // Wiimotes are excluded !CheckIfDirectInputDeviceExists(device)) { device.SetCooperativeLevel(windowHandle, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive); device.SetDataFormat(DeviceDataFormat.Joystick); device.Acquire(); JoystickInput input = new JoystickInput(device); AddInputDevice(input); input.InitCurrentlyInvokedInput(); InvokeNewInputDeviceEvent(input.DeviceInstanceId, input); } } }
public static List <GenericInput> GetNewInputDevices(IntPtr windowHandle, List <GenericInput> currentDevices) { List <GenericInput> newDevices = new List <GenericInput>(); DeviceList gameControllerList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly); for (int i = 0; i < gameControllerList.Count; i++) { gameControllerList.MoveNext(); DeviceInstance deviceInstance = (DeviceInstance)gameControllerList.Current; Device device = null; try { device = new Device(deviceInstance.InstanceGuid); } catch (Exception) { } if (device != null && device.DeviceInformation.ProductGuid != new Guid("0306057e-0000-0000-0000-504944564944") && // Wiimotes are excluded !CheckIfDirectInputDeviceExists(device, currentDevices)) { AcquireDirectInputDevice(windowHandle, device, DeviceDataFormat.Joystick); JoystickInput input = new JoystickInput(device); newDevices.Add(input); } } return(newDevices); }
private void AddNewDevices() { List <GenericInput> newDevices = new List <GenericInput>(); newDevices.AddRange(KeyboardInput.GetNewInputDevices(windowHandle, inputDevices)); newDevices.AddRange(JoystickInput.GetNewInputDevices(windowHandle, inputDevices)); newDevices.AddRange(WiiMoteInput.GetNewInputDevices(windowHandle, inputDevices)); //newDevices.AddRange(SpeechInput.GetNewInputDevices(windowHandle, inputDevices)); foreach (GenericInput inputDevice in newDevices) { AddInputDevice(inputDevice); InitInputDevice(inputDevice); } }