コード例 #1
0
        private void FindControllers()
        {
            // If we already have a controller, skip the search
            if (controller != null)
            {
                return;
            }

            try
            {
                DS4Devices.findControllers();
                IEnumerable <DS4Device> devices = DS4Devices.getDS4Controllers();

                if (devices.Count() < 1)
                {
                    return;
                }

                DS4Device device = devices.FirstOrDefault();

                Console.WriteLine("Controller found: " + device.MacAddress + " (" + device.ConnectionType + ")");

                controller = new DS4Controller(device);
                controller.SetLightBarColor(Color.WhiteSmoke);

                OnDeviceConnectionStateChanged(controller, true);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
            }
        }
コード例 #2
0
        private void OnDeviceConnectionStateChanged(DS4Controller controller, bool isConnected)
        {
            DeviceConnectionStateChangedEventArgs args = new DeviceConnectionStateChangedEventArgs();

            args.Controller  = controller;
            args.IsConnected = isConnected;

            DeviceConnectionStateChanged?.Invoke(this, args);
        }
コード例 #3
0
        private void PurgeInactiveControllers()
        {
            if (controller == null)
            {
                return;
            }

            if (controller.Device == null)
            {
                OnDeviceConnectionStateChanged(controller, false);

                controller.Purge();
                controller = null;
            }
        }