Exemple #1
0
 public void RemoveRemoteController(VjoyController rc)
 {
     lock (this.controllers)
     {
         this.controllers.Remove(rc);
         if (this.controllers.Count == 0)
         {
             Release();
         }
     }
 }
Exemple #2
0
        public bool AddRemoteController(VjoyController rc)
        {
            if (!IsExported())
            {
                return(false);
            }

            lock (this.controllers)
            {
                if (GetStatus() != Status.Acquired)
                {
                    if (!Acquire())
                    {
                        return(false);
                    }
                }
                this.controllers.Add(rc);
            }
            return(true);
        }
Exemple #3
0
        public VjoyClient(TcpClient tcpClient)
        {
            this.clientAddress = ((IPEndPoint)tcpClient.Client.RemoteEndPoint).Address;
            this.clientId      = ((IPEndPoint)tcpClient.Client.RemoteEndPoint).Port;
            this.tcpClient     = tcpClient;
            this.sendLock      = new Object();
            this.controllers   = new VjoyController[16];
            for (uint i = 0; i < 16; i++)
            {
                VjoyController controller           = new VjoyController();
                VjoyDevice     device               = Program.VjoyInterface.GetDevice(i + 1);
                device.GetConfig().PropertyChanged += VjoyDeviceConfig_PropertyChanged;
                device.AddRemoteController(controller);
                this.controllers[i] = controller;
            }

            //this.setupThread = new Thread(SetupThread);
            //this.setupThread.Start();
            string lines = "";

            lines += string.Format("init {0} {1} {2}\n", Environment.MachineName,
                                   Program.NetworkInterface.GetUdpPort(), this.clientId);
            VjoyDevice[] vjoyDevices = Program.VjoyInterface.GetDevices();
            foreach (VjoyDevice vjoyDevice in vjoyDevices)
            {
                vjoyDevice.StatusChanged   += VjoyDevice_StatusChanged;
                vjoyDevice.ExportedChanged += VjoyDevice_StatusChanged;
                uint   id     = vjoyDevice.GetVjoyDeviceId();
                string status = GetJoystickStatus(vjoyDevice);
                lines += string.Format("vjoy_status {0} {1}\n", id, status);
                foreach (string prop in vjoyDevice.GetConfig().GetProperties())
                {
                    lines += string.Format("vjoy_config {0} {1}\n", id, prop);
                }
            }
            Send(lines);
        }