示例#1
0
        private void FindDevices(IList <DeviceInstance> gameControllerList, IdentifierList preferred)
        {
            var newJoy1    = Guid.Empty;
            var preferJoy1 = preferred[0];
            var newJoy2    = Guid.Empty;
            var preferJoy2 = preferred[1];

            foreach (var deviceInstance in gameControllerList)
            {
                if (DetectDevice(deviceInstance, ref joystickDevice1, "T.16000M", ref preferJoy1, (guid) => mainForm.SetDevicesState(0, true, ref guid)))
                {
                    continue;
                }
                if (DetectDevice(deviceInstance, ref joystickDevice2, "T.16000M", ref preferJoy2, (guid) => mainForm.SetDevicesState(1, true, ref guid)))
                {
                    continue;
                }

                if (DetectDevice(deviceInstance, ref joystickDevice1, "T.16000M", ref newJoy1, (guid) => mainForm.SetDevicesState(0, true, ref guid)))
                {
                    preferJoy1 = newJoy1;
                    continue;
                }
                if (DetectDevice(deviceInstance, ref joystickDevice2, "T.16000M", ref newJoy2, (guid) => mainForm.SetDevicesState(1, true, ref guid)))
                {
                    preferJoy2 = newJoy2;
                    continue;
                }
            }
            preferred[0] = preferJoy1;
            preferred[1] = preferJoy2;
        }
示例#2
0
        public bool ValidateDeviceExistance()
        {
            // Find all the GameControl devices that are attached.

            var gameControllerList = input.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly);

            // check for devices existance
            var guids = new IdentifierList(Properties.Settings.Default.PreferredJoyGuids);

            for (int i = 0; i < guids.Count; i++)
            {
                for (int t = i + 1; t < guids.Count; t++)
                {
                    if (guids[t] == guids[i])
                    {
                        guids[t] = Guid.Empty;
                    }
                }
            }
            while (guids.Count > numDevices)
            {
                guids.RemoveAt(guids.Count - 1);
            }
            while (guids.Count < numDevices)
            {
                guids.Add(Guid.Empty);
            }

            FindDevices(gameControllerList, guids);

            var newPreferred = guids.ToString();

            if (Properties.Settings.Default.PreferredJoyGuids != newPreferred)
            {
                Properties.Settings.Default.PreferredJoyGuids = newPreferred;
                Properties.Settings.Default.Save();
            }
            return(AllDevicesReady() && vjoyEnabled);
        }