Пример #1
0
        public MainForm()
        {
            this.FormBorderStyle = FormBorderStyle.None;
            InitializeComponent();

            ControllerData = new ControllerData();
            state          = new SteamController.SteamControllerState();
            // 5s lookback for smoothing
            sensorData = new SensorCollector(5, true);

            LoadThemes();
            LoadSettings();
            if (File.Exists("ctrl.last"))
            {
                settings.Theme = File.ReadAllText("ctrl.last");
                File.Delete("ctrl.last");
            }
            if (!string.IsNullOrWhiteSpace(settings.Theme) && File.Exists(settings.Theme))
            {
                LoadTheme(settings.Theme, false); // we'll just let this task spool off on its own and pray
            }
            if (!string.IsNullOrWhiteSpace(settings.Background))
            {
                try
                {
                    this.BackColor = ColorTranslator.FromHtml(settings.Background);
                }
                catch { }
            }
            LoadControllers(true);
        }
Пример #2
0
        protected override void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            base.Initalize(data, cache, themePath, themeData);
            this.data = data;

            output = true;

            InputName = themeData["inputName"]?.Value <string>();
            output    = !(themeData["invert"]?.Value <bool>() ?? false);

            // super simplistic parsing for now, only supports single prefix ! and &&
            string Calc = themeData["calc"]?.Value <string>();

            if (!string.IsNullOrWhiteSpace(Calc))
            {
                calcFunc = Calc
                           .Split(new string[] { "&&" }, StringSplitOptions.None)
                           .Select(raw =>
                {
                    string trimed = raw.Trim();
                    bool invert   = trimed.StartsWith("!");
                    trimed        = trimed.TrimStart('!');
                    return(new Tuple <bool, string>(invert, trimed));
                })
                           .ToList();
            }
        }
Пример #3
0
        protected override void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            base.Initalize(data, cache, themePath, themeData);
            this.data = data;

            Background = Color.White;
            Foreground = Color.Black;

            AxisName  = themeData["axisName"]?.Value <string>();
            Direction = themeData["direction"]?.Value <string>();

            Min    = themeData["min"]?.Value <int>() ?? 0;
            Max    = themeData["max"]?.Value <int>() ?? 0;
            Width  = themeData["width"]?.Value <float>() ?? 0;
            Height = themeData["height"]?.Value <float>() ?? 0;

            string ForegroundCode = themeData["foreground"]?.Value <string>();
            string BackgroundCode = themeData["background"]?.Value <string>();

            try
            {
                Foreground = Color.FromArgb(int.Parse(ForegroundCode, System.Globalization.NumberStyles.HexNumber));
            }
            catch { }
            try
            {
                Background = Color.FromArgb(int.Parse(BackgroundCode, System.Globalization.NumberStyles.HexNumber));
            }
            catch { }
        }
Пример #4
0
        protected override void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            base.Initalize(data, cache, themePath, themeData);
            this.data = data;

            AxisNameX = themeData["axisNameX"]?.Value <string>();
            AxisNameY = themeData["axisNameY"]?.Value <string>();

            ScaleFactorX = themeData["scaleFactorX"]?.Value <float>() ?? 0;
            ScaleFactorY = themeData["scaleFactorY"]?.Value <float>() ?? 0;
        }
Пример #5
0
        protected override void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            base.Initalize(data, cache, themePath, themeData);

            Height         = themeData["height"]?.Value <float>() ?? 0;
            Width          = themeData["width"]?.Value <float>() ?? 0;
            DrawFromCenter = themeData["center"]?.Value <bool>() ?? false;

            string imageName = themeData["image"]?.Value <string>();

            if (!string.IsNullOrWhiteSpace(imageName))
            {
                DisplayImage = cache.LoadImage(imageName);
            }
        }
Пример #6
0
        private void Initalize(ControllerData data, string themePath, JObject themeData)
        {
            this.data = data;
            cache     = new UI_ImageCache(themePath);
            Items     = new List <UI_Item>();

            Height = themeData["height"]?.Value <int>() ?? 100;
            Width  = themeData["width"]?.Value <int>() ?? 100;

            themeData["children"]?.ToList().ForEach(child =>
            {
                string uiType = child["type"]?.Value <string>() ?? "";

                switch (uiType)
                {
                case "":
                    Items.Add(new UI_Item(data, cache, themePath, (JObject)child));
                    break;

                case "image":
                    Items.Add(new UI_GraphicalItem(data, cache, themePath, (JObject)child));
                    break;

                case "showhide":
                    Items.Add(new UL_ShowHide(data, cache, themePath, (JObject)child));
                    break;

                case "slider":
                    Items.Add(new UL_Slider(data, cache, themePath, (JObject)child));
                    break;

                case "trailpad":
                    Items.Add(new UL_TrailPad(data, cache, themePath, (JObject)child));
                    break;

                case "pbar":
                    Items.Add(new UL_PBar(data, cache, themePath, (JObject)child));
                    break;

                case "basic3d1":
                    Items.Add(new UL_Basic3D1(data, cache, themePath, (JObject)child));
                    break;

                default:
                    throw new Exception("Unknown UI Widget Type");
                }
            });
        }
Пример #7
0
        protected virtual void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            this.cache = cache;
            Items      = new List <UI_Item>();

            X   = themeData["x"]?.Value <float>() ?? 0;
            Y   = themeData["y"]?.Value <float>() ?? 0;
            Rot = themeData["rot"]?.Value <float>() ?? 0;

            themeData["children"]?.ToList().ForEach(child =>
            {
                string uiType = child["type"]?.Value <string>() ?? "";

                switch (uiType)
                {
                case "":
                    Items.Add(new UI_Item(data, cache, themePath, (JObject)child));
                    break;

                case "image":
                    Items.Add(new UI_GraphicalItem(data, cache, themePath, (JObject)child));
                    break;

                case "showhide":
                    Items.Add(new UL_ShowHide(data, cache, themePath, (JObject)child));
                    break;

                case "slider":
                    Items.Add(new UL_Slider(data, cache, themePath, (JObject)child));
                    break;

                case "trailpad":
                    Items.Add(new UL_TrailPad(data, cache, themePath, (JObject)child));
                    break;

                case "pbar":
                    Items.Add(new UL_PBar(data, cache, themePath, (JObject)child));
                    break;

                case "basic3d1":
                    Items.Add(new UL_Basic3D1(data, cache, themePath, (JObject)child));
                    break;

                default:
                    throw new Exception("Unknown UI Widget Type");
                }
            });
        }
Пример #8
0
        protected override void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            base.Initalize(data, cache, themePath, themeData);
            this.data  = data;
            this.cache = cache;

            DisplayType = themeData["mode"]?.Value <string>();
            string ImageName = themeData["image"]?.Value <string>();

            ShadowLName = themeData["shadowl"]?.Value <string>();
            ShadowRName = themeData["shadowr"]?.Value <string>();
            ShadowUName = themeData["shadowu"]?.Value <string>();
            ShadowDName = themeData["shadowd"]?.Value <string>();

            if (!string.IsNullOrWhiteSpace(ImageName))
            {
                DisplayImage = cache.LoadImage(ImageName);
            }

            if (!string.IsNullOrWhiteSpace(ShadowLName))
            {
                ShadowL = cache.LoadImage(ShadowLName);
            }

            if (!string.IsNullOrWhiteSpace(ShadowRName))
            {
                ShadowR = cache.LoadImage(ShadowRName);
            }

            if (!string.IsNullOrWhiteSpace(ShadowUName))
            {
                ShadowU = cache.LoadImage(ShadowUName);
            }

            if (!string.IsNullOrWhiteSpace(ShadowDName))
            {
                ShadowD = cache.LoadImage(ShadowDName);
            }

            Width  = themeData["width"]?.Value <float>() ?? 0;
            Height = themeData["height"]?.Value <float>() ?? 0;

            TiltTranslateX = themeData["tilttranslatex"]?.Value <float>() ?? 0;
            TiltTranslateY = themeData["tilttranslatey"]?.Value <float>() ?? 0;
        }
Пример #9
0
        protected override void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            base.Initalize(data, cache, themePath, themeData);
            this.data = data;

            PadPosHistory = new List <PointF?>();

            InputName = themeData["inputName"]?.Value <string>();
            string imageName   = themeData["image"]?.Value <string>();
            int    TrailLength = themeData["length"]?.Value <int>() ?? 0;

            float Width  = themeData["width"]?.Value <float>() ?? 0;
            float Height = themeData["height"]?.Value <float>() ?? 0;

            if (!string.IsNullOrWhiteSpace(imageName) && TrailLength > 0)
            {
                Image  ImagePadDecayBase = cache.LoadImage(imageName);
                string SizeSuffix        = string.Empty;
                if (Width > 0 && Height > 0)
                {
                    ImagePadDecayBase = new Bitmap(ImagePadDecayBase, (int)Width, (int)Height);
                }
                //int scaledTrailLength = (int)(TrailLength * (MainForm.fpsLimit / 60.0f));
                ImagePadDecay = new Image[TrailLength];
                for (int x = 0; x < ImagePadDecay.Length; x++)
                {
                    float percent = ((x + 1) * 1.0f / ImagePadDecay.Length);

                    ImagePadDecay[x] = cache.GetImage($"{imageName}:{Width}:{Height}:{percent}", () => { return(UI_ImageCache.SetImageOpacity(ImagePadDecayBase, percent * 0.15f)); });
                }
            }
            else
            {
                ImagePadDecay = new Image[0];
            }
        }
Пример #10
0
        public MainForm(int instanceNumber = 0)
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.None;     // no borders
            this.SetStyle(ControlStyles.ResizeRedraw, true); // this is to avoid visual artifacts

            RegistryKey winLogonKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian", false);

            if (winLogonKey != null)
            {
                hIDGuardianWhitelistToolStripMenuItem.Visible = true;
                RegistryKey whitelistKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist\" + Process.GetCurrentProcess().Id, false);
                hIDGuardianWhitelistToolStripMenuItem.Checked = whitelistKey != null;
            }

            IconManager   = new IconImageManager();
            DeviceManager = new DeviceManager();

            ControllerData = new ControllerData();
            state          = new ControllerState();
            // 5s lookback for smoothing
            sensorData = new SensorCollector(5, true);

            this.instanceNumber = instanceNumber;

            if (this.instanceNumber > 0)
            {
                this.Text = $"{this.Text} #{(instanceNumber + 1)}";
            }

            LoadThemes();
            LoadSettings();
            if (File.Exists("ctrl.last"))
            {
                settings.Theme = File.ReadAllText("ctrl.last");
                File.Delete("ctrl.last");
            }
            if (settings.CustomSize)
            {
                this.Width  = settings.Width ?? this.Width;
                this.Height = settings.Height ?? this.Height;
            }
            if (!string.IsNullOrWhiteSpace(settings.Theme) && File.Exists(settings.Theme))
            {
                LoadTheme(settings.Theme, true); // we'll just let this task spool off on its own and pray
            }
            if (!string.IsNullOrWhiteSpace(settings.Background))
            {
                try
                {
                    this.BackColor = ColorTranslator.FromHtml(settings.Background);
                }
                catch { }
            }
            tsmiAutoSelectOnlyController.Checked = settings.AutoSelectOnlyController;

            DeviceManager.ControllerAdded   += DeviceManager_ControllerAdded;
            DeviceManager.ControllerRemoved += DeviceManager_ControllerRemoved;

//            foreach(IDeviceProvider provider in DeviceManager.GetManualDeviceProviders())
//            {
//                ToolStripItem itm = tsmiManualControllers.DropDownItems.Add(provider.ToString(), null, LoadManualDevice);
//                itm.Tag = provider;
//            }
        }
Пример #11
0
 public UL_Basic3D1(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData) : base(data, cache, themePath, themeData)
 {
 }
Пример #12
0
 public UI_GraphicalItem(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData) : base(data, cache, themePath, themeData)
 {
 }
Пример #13
0
 public UI_Item(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
 {
     Initalize(data, cache, themePath, themeData);
 }
Пример #14
0
 public UI(ControllerData data, string themePath, JObject themeData)
 {
     Initalize(data, themePath, themeData);
 }
Пример #15
0
        public UI(ControllerData data, string themePath, string json)
        {
            JObject themeData = JObject.Parse(json);

            Initalize(data, themePath, themeData);
        }