示例#1
0
        //private ushort dispPacketCounter = 0;


        //private void RemoteDisplayProcessor()
        //{
        //    var receiveThread = new Thread(() =>
        //    {
        //        byte[] incoming = new byte[100 * 16];
        //        while (_running)
        //        {
        //            lock (_socketLock)
        //            {

        //                if (_tcpClient != null)
        //                {
        //                    try
        //                    {
        //                        var rotations = Math.Min(_tcpClient.Available / 16, 100);

        //                        if (rotations > 0)
        //                        {
        //                            if (State < CommState.ActiveNoDriver)
        //                                State = _sharedMem.IsDriverActive ? CommState.Active : CommState.ActiveNoDriver;

        //                            _tcpClient.Client.Receive(incoming, 0, 16 * rotations, SocketFlags.None);
        //                            var rotData = StructFromBytes<USBRotationData>(incoming, 16 * (rotations - 1));
        //                            //Debug.WriteLine("r:" + rotations + " w: " + rotData.w.ToString("F6") + " x: " + rotData.x.ToString("F6") + "y: " + rotData.y.ToString("F6") + "z:" + rotData.z.ToString("F6"));
        //                            var packet = USBPacket.Create((byte)(ROTATION_DATA | HMD_SOURCE), dispPacketCounter++, rotData);
        //                            var d = StructToBytes(packet);
        //                            SetPacketCrc(ref d);
        //                            _sharedMem.WriteIncomingPacket(d);
        //                        }
        //                    }
        //                    catch
        //                    {

        //                    }
        //                }
        //            }
        //        }

        //    });

        //    receiveThread.Start();

        //    while (_running)
        //    {
        //        var result = ProcessScreen();
        //        if (!result)
        //            Thread.Sleep(10);
        //    }

        //    receiveThread.Join();
        //    receiveThread = null;

        //}

        //private bool ProcessScreen()
        //{
        //    var size = _sharedMem.GetScreenImage(out ScreenData);
        //    if (size <= 0) return false;

        //    _frameCount++;

        //    lock (_socketLock)
        //    {
        //        if (_tcpClient == null)
        //        {
        //            _isConnecting = false;
        //            _tcpClient = new TcpClient();
        //        }
        //    }

        //    using (var ms = new MemoryStream(ScreenData))
        //    {
        //        ScreenImage = Image.FromStream(ms);
        //    }

        //    SendFrame(ScreenData, size);

        //    if (chkPreview.Checked)
        //        pbScreen.Invalidate();
        //    return true;
        //}

        //private void OnRemoteConnect(IAsyncResult ar)
        //{
        //    lock (_socketLock)
        //    {
        //        _isConnecting = false;
        //        try
        //        {
        //            _tcpClient.EndConnect(ar);
        //            _socket = _tcpClient.Client;
        //            State = _sharedMem.IsDriverActive ? CommState.Active : CommState.ActiveNoDriver;
        //            ResetRotation();
        //        }
        //        catch
        //        {
        //            _socket = null;
        //        }
        //    }
        //}

        private void MonitorForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            EnableOpenTrack(false);
            EnableCustomHMD(false);
            EnablePSVR(false);
            _trayIcon.Dispose();
            _trayIcon = null;

            tmrConsumer.Enabled = false;
            _sharedMem.EnableWatchDog(false);

            SetState(CommState.TrackerActive, false);

            _sharedMem.Dispose();
            _sharedMem = null;
            //if (ulMainHandle != 0)
            //    OpenVR.Overlay.DestroyOverlay(ulMainHandle);
            //OpenVR.Shutdown();
            //if (_socket != null && _socket.Connected)
            //{
            //    _socket.Shutdown(SocketShutdown.Both);
            //    _socket.Close();
            //}
            //lock (_socketLock)
            //{
            //    if (_tcpClient != null)
            //        _tcpClient.Dispose();
            //    _tcpClient = null;
            //}
        }
示例#2
0
 private void MonitorForm_Load(object sender, EventArgs e)
 {
     _sharedMem = new ShMem();
     _sharedMem.EnableWatchDog(false);
     IsVisible           = true;
     tmrConsumer.Enabled = true;
 }
示例#3
0
 private void chkWatchDog_CheckedChanged(object sender, EventArgs e)
 {
     if (_sharedMem == null)
     {
         return;
     }
     _sharedMem.EnableWatchDog(chkWatchDog.Checked);
 }
示例#4
0
        private void MonitorForm_Load(object sender, EventArgs e)
        {
            //_serverAddr = IPAddress.Parse("192.168.0.27");
            //_endPoint = new IPEndPoint(_serverAddr, 2222);



            _sharedMem = new ShMem();
            _sharedMem.EnableWatchDog(false);
            IsVisible   = true;
            _commThread = new Thread(USBProcessor);
            //_dispThread = new Thread(RemoteDisplayProcessor);
            _running = true;
            _commThread.Start();
            //_dispThread.Start();
        }