Ejemplo n.º 1
0
 public void Press(IDeviceReport report)
 {
     if (string.IsNullOrWhiteSpace(Key))
     {
         Keyboard.Press(Key);
     }
 }
Ejemplo n.º 2
0
 public void Release(TabletReference tablet, IDeviceReport report)
 {
     if (!string.IsNullOrWhiteSpace(Key))
     {
         Keyboard.Release(Key);
     }
 }
Ejemplo n.º 3
0
 public void Release(IDeviceReport report)
 {
     if (string.IsNullOrWhiteSpace(Key))
     {
         Keyboard.Release(Key);
     }
 }
Ejemplo n.º 4
0
        public static string GetStringFormat(IDeviceReport report)
        {
            StringBuilder sb = new StringBuilder();

            if (report is ITabletReport tabletReport)
            {
                sb.AppendLines(GetStringFormat(tabletReport));
            }
            if (report is IAuxReport auxReport)
            {
                sb.AppendLines(GetStringFormat(auxReport));
            }
            if (report is IEraserReport eraserReport)
            {
                sb.AppendLines(GetStringFormat(eraserReport));
            }
            if (report is IProximityReport proximityReport)
            {
                sb.AppendLines(GetStringFormat(proximityReport));
            }
            if (report is ITiltReport tiltReport)
            {
                sb.AppendLines(GetStringFormat(tiltReport));
            }
            if (report is ITouchReport touchReport)
            {
                sb.AppendLines(GetStringFormat(touchReport));
            }

            return(sb.ToString());
        }
Ejemplo n.º 5
0
 private void HandleReport(object sender, IDeviceReport report)
 {
     if (BindingEnabled)
     {
         OutputMode?.Read(report);
     }
 }
Ejemplo n.º 6
0
        public void SetProfile(Profile profile)
        {
            OutputMode.Tablet = new TabletReference
            {
                Properties = new TabletConfiguration
                {
                    Specifications = new TabletSpecifications
                    {
                        Digitizer = new DigitizerSpecifications
                        {
                            MaxX   = 2000,
                            MaxY   = 2000,
                            Width  = 20,
                            Height = 20,
                        },
                        Pen = new PenSpecifications
                        {
                            ActiveReportID = new DetectionRange(null, null)
                        }
                    }
                }
            };

            OutputMode.Output = profile.AbsoluteModeSettings.Display.Area;
            OutputMode.Input  = profile.AbsoluteModeSettings.Tablet.Area;

            var data    = new byte[8];
            var randGen = new Random();

            randGen.NextBytes(data);

            var parser = new TabletReportParser();

            Report = parser.Parse(data);
        }
Ejemplo n.º 7
0
 public void HandlePacket(object sender, IDeviceReport report)
 {
     if (PipeServer.IsConnected && JsonWriter != null)
     {
         Serializer.Serialize(JsonWriter, report);
     }
 }
Ejemplo n.º 8
0
 public void Release(IDeviceReport report)
 {
     if (Mode == "Hold")
     {
         IsActive = false;
     }
 }
Ejemplo n.º 9
0
 public void Release(TabletReference tablet, IDeviceReport report)
 {
     if (Enum.TryParse <MouseButton>(Button, true, out var mouseButton))
     {
         Pointer?.MouseUp(mouseButton);
     }
 }
Ejemplo n.º 10
0
 private void SetReport(object sender, IDeviceReport report)
 {
     Application.Instance.AsyncInvoke(() =>
     {
         display.SetReport(report);
     });
 }
Ejemplo n.º 11
0
 public void Read(IDeviceReport report)
 {
     if (report is ITabletReport tabletReport)
     {
         Position(tabletReport);
     }
 }
Ejemplo n.º 12
0
 private void PostDebugReport(TabletReference tablet, IDeviceReport report)
 {
     if (report != null && tablet != null)
     {
         DeviceReport?.Invoke(this, new DebugReportData(tablet, report));
     }
 }
Ejemplo n.º 13
0
 private void DebugReportHandler(object _, IDeviceReport report)
 {
     if (report != null)
     {
         DeviceReport?.Invoke(this, new RpcData(report));
     }
 }
Ejemplo n.º 14
0
        public void SetSettings(Settings settings)
        {
            var digitizer =

                OutputMode.Tablet = new TabletState
            {
                Properties = new TabletConfiguration
                {
                    Specifications = new TabletSpecifications
                    {
                        Digitizer = new DigitizerSpecifications
                        {
                            MaxX   = 2000,
                            MaxY   = 2000,
                            Width  = 20,
                            Height = 20,
                        },
                        Pen = new PenSpecifications
                        {
                            ActiveReportID = new DetectionRange(null, null)
                        }
                    }
                }
            };

            OutputMode.Output = new Area
            {
                Width    = settings.DisplayWidth,
                Height   = settings.DisplayHeight,
                Position = new Vector2
                {
                    X = settings.DisplayX,
                    Y = settings.DisplayY
                }
            };

            OutputMode.Input = new Area
            {
                Width    = settings.TabletWidth,
                Height   = settings.TabletHeight,
                Position = new Vector2
                {
                    X = settings.TabletX,
                    Y = settings.TabletY
                },
                Rotation = settings.TabletRotation
            };

            var data    = new byte[8];
            var randGen = new Random();

            randGen.NextBytes(data);

            var parser = new TabletReportParser();

            Report = parser.Parse(data);
        }
 public void Invoke(TabletReference tablet, IDeviceReport report)
 {
     if (report is ITabletReport tabletReport)
     {
         float pressure = (float)tabletReport.Pressure / (float)tablet.Properties.Specifications.Pen.MaxPressure;
         bool  isEraser = report is IEraserReport eraserReport ? eraserReport.Eraser : false;
         Tablet.SetPressure(pressure, isEraser);
     }
 }
Ejemplo n.º 16
0
 public void Invoke(TabletReference tablet, IDeviceReport report)
 {
     if (report is ITabletReport tabletReport)
     {
         float pressure = (float)tabletReport.Pressure / (float)tablet.Properties.Specifications.Pen.MaxPressure;
         Tablet.SetPressure(pressure);
         Tablet.SetButtonState(0, tabletReport.PenButtons[0]);
         Tablet.SetButtonState(1, tabletReport.PenButtons[1]);
     }
 }
Ejemplo n.º 17
0
 private static void InvokeBinding(IDeviceReport report, IBinding binding, bool prevState, bool newState)
 {
     if (newState && !prevState)
     {
         binding.Press(report);
     }
     else if (!newState && prevState)
     {
         binding.Release(report);
     }
 }
Ejemplo n.º 18
0
 private void HandleReport(object sender, IDeviceReport report)
 {
     if (BindingEnabled && OutputMode?.TabletProperties != null)
     {
         OutputMode?.Read(report);
         if (OutputMode is IBindingHandler <IBinding> binding)
         {
             binding.HandleBinding(report);
         }
     }
 }
Ejemplo n.º 19
0
 public virtual void Read(IDeviceReport report)
 {
     if (report is ITabletReport tabletReport)
     {
         Position(tabletReport);
     }
     else if (report is IAuxReport auxReport)
     {
         Aux(auxReport);
     }
 }
Ejemplo n.º 20
0
 public void HandleBinding(IDeviceReport report)
 {
     if (report is ITabletReport tabletReport && TabletProperties.ActiveReportID.IsInRange(tabletReport.ReportID))
     {
         HandlePenBinding(tabletReport);
     }
     if (report is IAuxReport auxReport)
     {
         HandleAuxBinding(auxReport);
     }
 }
Ejemplo n.º 21
0
 private void DebugReportHandler(object _, IDeviceReport report)
 {
     if (report is ITabletReport tabletReport)
     {
         TabletReport?.Invoke(this, new DebugTabletReport(tabletReport));
     }
     if (report is IAuxReport auxReport)
     {
         AuxReport?.Invoke(this, new DebugAuxReport(auxReport));
     }
 }
Ejemplo n.º 22
0
 private static void HandleBindingCollection(IDeviceReport report, IList <bool> prevStates, IList <bool> newStates, IDictionary <int, IBinding> bindings)
 {
     for (int i = 0; i < newStates.Count; i++)
     {
         if (bindings.TryGetValue(i, out IBinding binding) && binding != null)
         {
             InvokeBinding(report, binding, prevStates[i], newStates[i]);
         }
         prevStates[i] = newStates[i];
     }
 }
Ejemplo n.º 23
0
        public void Press(IDeviceReport report)
        {
            if (Mode == "Toggle")
            {
                IsActive = !IsActive;
            }
            else if (Mode == "Hold")
            {
                IsActive = true;
            }

            SetPosition = true;
        }
Ejemplo n.º 24
0
 private void HandleReport(object sender, IDeviceReport report)
 {
     if (report is ITabletReport tabletReport)
     {
         RawTabletReport  = tabletReport.StringFormat(true);
         TabletProperties = tabletReport.StringFormat(false).Split(", ", StringSplitOptions.None).ToObservableCollection();
     }
     if (report is IAuxReport auxReport)
     {
         RawAuxReport  = auxReport.StringFormat(true);
         AuxProperties = auxReport.StringFormat(false).Split(", ", StringSplitOptions.None).ToObservableCollection();
     }
 }
Ejemplo n.º 25
0
        private void handleDeviceReported(object sender, IDeviceReport report)
        {
            switch (report)
            {
            case ITabletReport tabletReport:
                handleTabletReport(tabletReport);
                break;

            case IAuxReport auxiliaryReport:
                handleAuxiliaryReport(auxiliaryReport);
                break;
            }
        }
Ejemplo n.º 26
0
 private bool Validate(IDeviceReport report)
 {
     if (report is ITabletReport tabletReport)
     {
         return(tabletReport.Raw != null && tabletReport.PenButtons != null);
     }
     else if (report is IAuxReport auxReport)
     {
         return(auxReport.Raw != null && auxReport.AuxButtons != null);
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 27
0
        public static void HandleBinding(TabletState tablet, IDeviceReport report)
        {
            if (tablet == null)
            {
                return;
            }

            if (report is ITabletReport tabletReport && tablet.Digitizer.ActiveReportID.IsInRange(tabletReport.ReportID))
            {
                HandlePenBinding(tablet.Digitizer, tabletReport);
            }
            if (report is IAuxReport auxReport)
            {
                HandleAuxBinding(auxReport);
            }
        }
Ejemplo n.º 28
0
        public virtual void Invoke(TabletReference tablet, IDeviceReport report, bool newState)
        {
            if (Binding is IStateBinding stateBinding)
            {
                if (newState && !PreviousState)
                {
                    stateBinding.Press(tablet, report);
                }
                else if (!newState && PreviousState)
                {
                    stateBinding.Release(tablet, report);
                }
            }

            PreviousState = newState;
        }
Ejemplo n.º 29
0
        private void HandleReport(object sender, IDeviceReport report)
        {
            if (report is ITabletReport tabletReport)
            {
                reportPeriod += (stopwatch.Restart().TotalMilliseconds - reportPeriod) / 10.0f;

                rawTabletBox.Update(tabletReport?.StringFormat(true));
                tabletBox.Update(tabletReport?.StringFormat(false).Replace(", ", Environment.NewLine));
                reportRateBox.Update($"{(uint)(1000 / reportPeriod)}hz");
            }
            if (report is IAuxReport auxReport)
            {
                rawAuxBox.Update(auxReport?.StringFormat(true));
                auxBox.Update(auxReport?.StringFormat(false).Replace(", ", Environment.NewLine));
            }
        }
Ejemplo n.º 30
0
        public static string GetStringFormat(IDeviceReport report)
        {
            StringBuilder sb = new StringBuilder();

            if (report is IAbsolutePositionReport absolutePositionReport)
            {
                sb.AppendLines(GetStringFormat(absolutePositionReport));
            }
            if (report is ITabletReport tabletReport)
            {
                sb.AppendLines(GetStringFormat(tabletReport));
            }
            if (report is IAuxReport auxReport)
            {
                sb.AppendLines(GetStringFormat(auxReport));
            }
            if (report is IEraserReport eraserReport)
            {
                sb.AppendLines(GetStringFormat(eraserReport));
            }
            if (report is IProximityReport proximityReport)
            {
                sb.AppendLines(GetStringFormat(proximityReport));
            }
            if (report is ITiltReport tiltReport)
            {
                sb.AppendLines(GetStringFormat(tiltReport));
            }
            if (report is ITouchReport touchReport)
            {
                sb.AppendLines(GetStringFormat(touchReport));
            }
            if (report is IMouseReport mouseReport)
            {
                sb.AppendLines(GetStringFormat(mouseReport));
            }
            if (report is IToolReport toolReport)
            {
                sb.AppendLines(GetStringFormat(toolReport));
            }
            if (report is OutOfRangeReport oorReport)
            {
                sb.AppendLines(GetStringFormat(oorReport));
            }

            return(sb.ToString());
        }