public DesktopMirrorManager()
        {
            TouchInjector.InitializeTouchInjection();

            ConfigUtility.RegisterCustomConfigLayout("desktop", new List <ConfigUtility.ConfigLayout>()
            {
                new ConfigUtility.ConfigLayout()
                {
                    NonAddonFileKey = "desktop", Category = "Basic Settings", Key = "enabled", Title = "Enable Desktop Mirror?", Description = "Enables/Disables the improved desktop mirror", Type = "bool", Default = false
                },
                new ConfigUtility.ConfigLayout()
                {
                    NonAddonFileKey = "desktop", Category = "Screen Settings", Key = "distance", Title = "Display Distance", Description = "Distance of primary display from the middle of the play space", Type = "float", Default = 2f
                },
                new ConfigUtility.ConfigLayout()
                {
                    NonAddonFileKey = "desktop", Category = "Screen Settings", Key = "width", Title = "Display Overlay Width", Description = "Meter Width of each overlay", Type = "float", Default = 2.5f
                },
                new ConfigUtility.ConfigLayout()
                {
                    NonAddonFileKey = "desktop", Category = "Screen Settings", Key = "show_without_dashboard", Title = "Show without Dashboard", Description = "Show the desktop mirror even when the dashboard isn't visible", Type = "bool", Default = false
                },
                new ConfigUtility.ConfigLayout()
                {
                    NonAddonFileKey = "desktop", Category = "Screen Settings", Key = "position", Title = "Desktop Position", Default = "Opposite Dashboard", Description = "Where to place the desktop mirror: opposite the dashboard or at the rear of the play space", Type = "string", Options = new object[] { "Opposite Dashboard", "Rear of Playspace" }
                },
                new ConfigUtility.ConfigLayout()
                {
                    NonAddonFileKey = "desktop", Category = "Screen Settings", Key = "use_touch", Title = "Use Touch Injection", Default = false, Description = "Use Touch Injection instead of Mouse, experimental but often provides a better experience.", Type = "bool"
                }
            });

            ConfigUtility.Listen("desktop.enabled", (k, v) =>
            {
                if (v is bool)
                {
                    if ((bool)v)
                    {
                        Enable();
                    }
                    else
                    {
                        Disable();
                    }
                }
            });

            Microsoft.Win32.SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged;
        }
Exemple #2
0
        public DesktopMirror(int screenIndex, Screen screenObject)
        {
            _width    = ConfigUtility.Get <float>("desktop.width");
            _distance = ConfigUtility.Get <float>("desktop.distance", 2f);

            ConfigUtility.Listen("desktop.width", DesktopWidthChanged);
            ConfigUtility.Listen("desktop.distance", DesktopDistanceChanged);
            ConfigUtility.Listen("desktop.position", DesktopPositionChanged);
            ConfigUtility.Listen("desktop.show_without_dashboard", DesktopAppearanceChanged);
            ConfigUtility.Listen("desktop.use_touch", (key, v) =>
            {
                useTouch = (bool)v;
            });

            useTouch = ConfigUtility.Get <bool>("desktop.use_touch", true);

            SteamVR_Event.Listen("DashboardActivated", (d) =>
            {
                if (_screenIndex > 0)
                {
                    return;
                }

                SetRootPosition();
                InternalOverlay.Show();
            });

            SteamVR_Event.Listen("DashboardDeactivated", (d) =>
            {
                if (_screenIndex > 0)
                {
                    return;
                }

                if (!ConfigUtility.Get <bool>("desktop.show_without_dashboard", false))
                {
                    InternalOverlay.Hide();
                }
            });

            _screenIndex  = screenIndex;
            _screenObject = screenObject;

            Logger.Debug("[DESKTOP] Found Screen: " + screenObject.DeviceName + " with bounds of " + screenObject.Bounds.ToString() + " and working area " + screenObject.WorkingArea.ToString());

            Setup();
        }