Exemplo n.º 1
0
        private void OnExecute()
        {
            var display = DisplayIdentifier.Parse(Environment.GetEnvironmentVariable("DISPLAY"));

            // Ctrl + C が押されたときの動作を設定しておく
            var w   = new ManualResetEvent(false);
            var cts = new CancellationTokenSource();

            cts.Token.Register(() =>
            {
                Log.WriteMessage("Terminating");
                w.Set();
            });
            Console.CancelKeyPress += (_, e) =>
            {
                e.Cancel = true;
                cts.Cancel();
            };

            GrpcEnvironment.SetLogger(new ConsoleLogger());

            // サーバー開始
            // 0.0.0.0 を指定: https://github.com/grpc/grpc/issues/10570
            using (var wagahighOperator = LocalWagahighOperator.StartProcessAsync(this.Directory ?? "", display).Result)
                using (var server = new GrpcToaServer("0.0.0.0", this.Port, wagahighOperator))
                {
                    server.Start();
                    Log.WriteMessage("Listening " + this.Port);
                    w.WaitOne();
                }
        }
Exemplo n.º 2
0
        private async Task Connect(DisplayIdentifier displayIdentifier)
        {
            this._x11Client = await X11Client.ConnectAsync(displayIdentifier.Host, displayIdentifier.Display).ConfigureAwait(false);

            var s = this._x11Client.Screens[displayIdentifier.Screen];

            this._screenRootWindow = s.Root;

            while (true) // ウィンドウが見つかるまでループ
            {
                await Task.Delay(1000).ConfigureAwait(false);

                var wagahighWindow = await FindWagahighWindow(this._x11Client, s.Root).ConfigureAwait(false);

                if (!wagahighWindow.HasValue)
                {
                    continue;
                }

                var contentWindow = await FindContentWindow(this._x11Client, wagahighWindow.Value).ConfigureAwait(false);

                if (!contentWindow.HasValue)
                {
                    continue;
                }

                this._contentWindow = contentWindow.Value;

                // ウィンドウの位置を左上に移動
                await this._x11Client.ConfigureWindowAsync(wagahighWindow.Value, x : 0, y : 0).ConfigureAwait(false);

                return;
            }
        }
Exemplo n.º 3
0
        private async Task <WagahighOperator> CreateWagahighOperatorAsync()
        {
            if (this.ToaHost != null)
            {
                this.Logger.Info($"Toa サーバー {this.ToaHost}:{this.ToaPort} に接続します。");
                var remoteOperator = new GrpcRemoteWagahighOperator(this.ToaHost, this.ToaPort);
                await remoteOperator.ConnectAsync().ConfigureAwait(false);

                return(remoteOperator);
            }
            else
            {
                this.Logger.Info("ワガママハイスペックを起動します。");
                var display = DisplayIdentifier.Parse(Environment.GetEnvironmentVariable("DISPLAY"));
                return(await LocalWagahighOperator.StartProcessAsync(this.Directory ?? "", display).ConfigureAwait(false));
            }
        }
Exemplo n.º 4
0
        public static async Task <LocalWagahighOperator> StartProcessAsync(string directory, DisplayIdentifier displayIdentifier)
        {
            var instance = new LocalWagahighOperator();

            try
            {
                instance.StartProcess(directory);
                await instance.Connect(displayIdentifier).ConfigureAwait(false);
            }
            catch
            {
                instance.Dispose();
                throw;
            }

            return(instance);
        }
Exemplo n.º 5
0
    private void Start()
    {
        if (m_uiOverlayTexture == null)
        {
            Debug.LogError("No overlay texture was set");
        }

        m_focusGizmo     = GameObject.Find("AS3D_FOCUS_GIZMO");
        m_zoomFocusGizmo = Instantiate((GameObject)Resources.Load("AS3D/AS3D_FOCUS_GIZMO", typeof(GameObject)), transform);
        m_zoomFocusGizmo.transform.localPosition = Vector3.forward * m_focusDistance;
        m_zoomFocusGizmo.name = "AS3D_ZOOM_FOCUS_GIZMO";

        if (m_focusGizmo != null)
        {
            m_focusGizmo.GetComponent <SpriteRenderer>().enabled = false;
            m_useFocusGizmo = true;
        }
        else
        {
            m_useFocusGizmo = false;
        }

        m_zoomFocusGizmo.GetComponent <SpriteRenderer>().enabled = false;

        m_configDirPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}AS3D_Screen_Settings";
        Directory.CreateDirectory(m_configDirPath); // create directory for jsons to be saved in
        WriteDefaultJsonSettings();

        List <string> displayIds = DisplayIdentifier.GetDisplayIDs();

        Debug.Log("Detected displays: " + string.Join(", ", displayIds));

        bool configFound           = false;
        List <DisplayDesc> configs = LoadAllConfigs();

        foreach (string ID in displayIds)
        {
            foreach (DisplayDesc config in configs)
            {
                if (config.m_deviceIds.Contains(ID))
                {
                    m_screenSettings = config;
                    configFound      = true;
                    Debug.Log($"Found config '{config.m_name}' for monitor '{ID}'");
                    break;
                }
            }
        }

        if (!configFound)
        {
            Debug.LogWarning("Could not detect AS3D display or configuration file.");
        }

        m_originalCursorVisibility = Cursor.visible;
        m_originalLockMode         = Cursor.lockState;
        autoStereoUI = GameObject.Find("AutoStereoUI");
        if (autoStereoUI == null)
        {
            Debug.LogWarning("AutoStereoUI not found in scene");
        }
        else
        {
            autoStereoUI.SetActive(false);
            if (m_useFocusGizmo)
            {
                autoStereoUI.GetComponentInChildren <UIBehaviour>().m_focusLengthSlider.interactable = false;
                Debug.Log("Override focus length slider with AS3D_FOCUS_GIZMO in scene");
            }
        }

        m_sourceCamera = GetComponent <Camera>();

        if (m_reconstructView == false)
        {
            m_sourceCamera.cullingMask = 0; // main camera rendering of the scene is disabled
            m_originalClearFlag        = m_sourceCamera.clearFlags;
            m_sourceCamera.clearFlags  = CameraClearFlags.Nothing;
        }

        Shader as3dShader = Shader.Find("Autostereo");

        if (as3dShader != null)
        {
            m_material = new Material(as3dShader);
        }
        else
        {
            Debug.Assert(false, "Autostereo shader could not be found.");
            return;
        }

        m_colorTargets = new RenderTexture[m_maxRenderViews];

        CreateRenderCameras();
    }