Пример #1
0
        private void updateInputArea([CanBeNull] InputDeviceTree inputDevice)
        {
            if (inputDevice == null)
            {
                return;
            }

            var   digitizer   = inputDevice.Properties.Specifications.Digitizer;
            float inputWidth  = digitizer.Width;
            float inputHeight = digitizer.Height;

            AreaSize.Default = new Vector2(inputWidth, inputHeight);

            // if it's clear the user has not configured the area, take the full area from the tablet that was just found.
            if (AreaSize.Value == Vector2.Zero)
            {
                AreaSize.SetDefault();
            }

            AreaOffset.Default = new Vector2(inputWidth / 2, inputHeight / 2);

            // likewise with the position, use the centre point if it has not been configured.
            // it's safe to assume no user would set their centre point to 0,0 for now.
            if (AreaOffset.Value == Vector2.Zero)
            {
                AreaOffset.SetDefault();
            }

            tablet.Value = new TabletInfo(inputDevice.Properties.Name, AreaSize.Default);

            switch (inputDevice.OutputMode)
            {
            case AbsoluteOutputMode absoluteOutputMode:
            {
                // Set input area in millimeters
                absoluteOutputMode.Input = new Area
                {
                    Width    = AreaSize.Value.X,
                    Height   = AreaSize.Value.Y,
                    Position = new System.Numerics.Vector2(AreaOffset.Value.X, AreaOffset.Value.Y),
                    Rotation = Rotation.Value
                };
                break;
            }
            }
        }
Пример #2
0
            public void SetTabletSize(Vector2 size)
            {
                tablet.Value = size != Vector2.Zero ? new TabletInfo($"test tablet T-{RNG.Next(999):000}", size) : null;

                AreaSize.Default = new Vector2(size.X, size.Y);

                // if it's clear the user has not configured the area, take the full area from the tablet that was just found.
                if (AreaSize.Value == Vector2.Zero)
                {
                    AreaSize.SetDefault();
                }

                AreaOffset.Default = new Vector2(size.X / 2, size.Y / 2);

                // likewise with the position, use the centre point if it has not been configured.
                // it's safe to assume no user would set their centre point to 0,0 for now.
                if (AreaOffset.Value == Vector2.Zero)
                {
                    AreaOffset.SetDefault();
                }
            }