mirror of
https://github.com/vale981/VoiDPlugins
synced 2025-03-05 17:21:38 -05:00
Update to OTD v0.5.0 API
This commit is contained in:
parent
7ab18085cd
commit
7d4d24bef4
7 changed files with 127 additions and 37 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 53b0b5766bdffce90e11da84c5e47ef919a4b1db
|
Subproject commit 56bc69091d3366deacb387dc705fba3466b180d9
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace VoiDPlugins.MeL.Core
|
namespace VoiDPlugins.MeL.Core
|
||||||
{
|
{
|
||||||
|
|
76
Reconstructor/RingBuffer.cs
Normal file
76
Reconstructor/RingBuffer.cs
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace VoiDPlugins
|
||||||
|
{
|
||||||
|
internal class RingBuffer<T> : IEnumerable<T>
|
||||||
|
{
|
||||||
|
public int Size { private set; get; }
|
||||||
|
public bool IsFilled { private set; get; }
|
||||||
|
|
||||||
|
private T[] dataStream;
|
||||||
|
private int head;
|
||||||
|
|
||||||
|
public RingBuffer(int size)
|
||||||
|
{
|
||||||
|
this.Size = size;
|
||||||
|
this.dataStream = new T[size];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(T item)
|
||||||
|
{
|
||||||
|
this.dataStream[this.head++] = item;
|
||||||
|
if (this.head == this.Size)
|
||||||
|
{
|
||||||
|
this.head = 0;
|
||||||
|
this.IsFilled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T PeekFirst()
|
||||||
|
{
|
||||||
|
var currentPosition = this.head;
|
||||||
|
return this.dataStream[currentPosition];
|
||||||
|
}
|
||||||
|
|
||||||
|
public T PeekLast()
|
||||||
|
{
|
||||||
|
var last = Math.Abs(this.head - 1);
|
||||||
|
return this.dataStream[last];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
this.dataStream = new T[this.Size];
|
||||||
|
this.head = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator<T> GetEnumerator()
|
||||||
|
{
|
||||||
|
if (this.head == 0)
|
||||||
|
{
|
||||||
|
foreach (var item in this.dataStream)
|
||||||
|
{
|
||||||
|
yield return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var item in this.dataStream[this.head..^0])
|
||||||
|
{
|
||||||
|
yield return item;
|
||||||
|
}
|
||||||
|
foreach (var item in this.dataStream[0..this.head])
|
||||||
|
{
|
||||||
|
yield return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,11 +9,11 @@ namespace VoiDPlugins.TouchEmu
|
||||||
[PluginName("Touch Emu"), SupportedPlatform(PluginPlatform.Windows)]
|
[PluginName("Touch Emu"), SupportedPlatform(PluginPlatform.Windows)]
|
||||||
public class TouchOutputMode : AbsoluteOutputMode
|
public class TouchOutputMode : AbsoluteOutputMode
|
||||||
{
|
{
|
||||||
private readonly IVirtualTablet TouchPointer = new TouchPointerHandler();
|
private readonly IAbsolutePointer TouchPointer = new TouchPointerHandler();
|
||||||
public override IVirtualTablet VirtualTablet => TouchPointer;
|
public override IAbsolutePointer Pointer => TouchPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TouchPointerHandler : IVirtualTablet, IPressureHandler
|
public class TouchPointerHandler : IAbsolutePointer, IVirtualTablet
|
||||||
{
|
{
|
||||||
private bool _inContact;
|
private bool _inContact;
|
||||||
private bool _lastContact;
|
private bool _lastContact;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
using System.Numerics;
|
||||||
using HidSharp;
|
using HidSharp;
|
||||||
using OpenTabletDriver.Plugin;
|
using OpenTabletDriver.Plugin;
|
||||||
|
using OpenTabletDriver.Plugin.Platform.Display;
|
||||||
using OpenTabletDriver.Plugin.Platform.Pointer;
|
using OpenTabletDriver.Plugin.Platform.Pointer;
|
||||||
|
|
||||||
namespace VoiDPlugins.VMultiMode
|
namespace VoiDPlugins.VMultiMode
|
||||||
|
@ -68,11 +70,12 @@ namespace VoiDPlugins.VMultiMode
|
||||||
Middle = 4,
|
Middle = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class VMultiHandler<T> where T : VMultiReport, new()
|
public class VMultiHandler<T> where T : VMultiReport, new()
|
||||||
{
|
{
|
||||||
protected T Report;
|
protected T Report;
|
||||||
protected HidStream VMultiDev;
|
protected HidStream VMultiDev;
|
||||||
|
protected Vector2 ScreenMax, ScreenToVMulti;
|
||||||
|
private readonly IVirtualScreen VirtualScreen = (Info.Driver as IVirtualDisplayDriver).VirtualScreen;
|
||||||
|
|
||||||
protected void Init(string Name, byte ReportID)
|
protected void Init(string Name, byte ReportID)
|
||||||
{
|
{
|
||||||
|
@ -90,12 +93,19 @@ namespace VoiDPlugins.VMultiMode
|
||||||
if (device.GetMaxOutputReportLength() == 65 && device.GetMaxInputReportLength() == 65)
|
if (device.GetMaxOutputReportLength() == 65 && device.GetMaxInputReportLength() == 65)
|
||||||
{
|
{
|
||||||
device.TryOpen(out VMultiDev);
|
device.TryOpen(out VMultiDev);
|
||||||
|
if (VMultiDev != null)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (VMultiDev == null)
|
if (VMultiDev == null)
|
||||||
{
|
{
|
||||||
Log.Write(Name, "Cannot find VirtualHID", LogLevel.Error);
|
Log.Write(Name, "Cannot find VirtualHID", LogLevel.Error);
|
||||||
|
Log.Write(Name, "Install VMulti driver here: https://github.com/X9VoiD/vmulti-bin/releases/latest");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
ScreenMax = new Vector2(VirtualScreen.Width, VirtualScreen.Height);
|
||||||
|
ScreenToVMulti = ScreenMax / 32767;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MouseDown(MouseButton button)
|
public void MouseDown(MouseButton button)
|
||||||
|
|
|
@ -10,22 +10,19 @@ namespace VoiDPlugins.VMultiMode
|
||||||
[PluginName("VMulti Absolute Output Mode"), SupportedPlatform(PluginPlatform.Windows)]
|
[PluginName("VMulti Absolute Output Mode"), SupportedPlatform(PluginPlatform.Windows)]
|
||||||
public class VMultiAbsMode : AbsoluteOutputMode
|
public class VMultiAbsMode : AbsoluteOutputMode
|
||||||
{
|
{
|
||||||
private readonly IVirtualTablet AbsHandler = new VMultiAbsHandler();
|
private readonly IAbsolutePointer AbsHandler = new VMultiAbsHandler();
|
||||||
public override IVirtualTablet VirtualTablet => AbsHandler;
|
public override IAbsolutePointer Pointer => AbsHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
[PluginName("VMulti Relative Output Mode"), SupportedPlatform(PluginPlatform.Windows)]
|
[PluginName("VMulti Relative Output Mode"), SupportedPlatform(PluginPlatform.Windows)]
|
||||||
public class VMultiRelMode : AbsoluteOutputMode
|
public class VMultiRelMode : AbsoluteOutputMode
|
||||||
{
|
{
|
||||||
private readonly IVirtualTablet RelHandler = new VMultiRelHandler();
|
private readonly IAbsolutePointer RelHandler = new VMultiRelHandler();
|
||||||
public override IVirtualTablet VirtualTablet => RelHandler;
|
public override IAbsolutePointer Pointer => RelHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VMultiAbsHandler : VMultiHandler<VMultiAbsReport>, IVirtualTablet
|
public class VMultiAbsHandler : VMultiHandler<VMultiAbsReport>, IAbsolutePointer
|
||||||
{
|
{
|
||||||
private readonly float Width = Info.Driver.VirtualScreen.Width;
|
|
||||||
private readonly float Height = Info.Driver.VirtualScreen.Height;
|
|
||||||
|
|
||||||
public VMultiAbsHandler()
|
public VMultiAbsHandler()
|
||||||
{
|
{
|
||||||
Init("VMultiAbs", 0x09);
|
Init("VMultiAbs", 0x09);
|
||||||
|
@ -33,13 +30,14 @@ namespace VoiDPlugins.VMultiMode
|
||||||
|
|
||||||
public void SetPosition(Vector2 pos)
|
public void SetPosition(Vector2 pos)
|
||||||
{
|
{
|
||||||
Report.X = (ushort)(pos.X / Width * 32767);
|
var newPos = pos / ScreenToVMulti;
|
||||||
Report.Y = (ushort)(pos.Y / Height * 32767);
|
Report.X = (ushort)newPos.X;
|
||||||
|
Report.Y = (ushort)newPos.Y;
|
||||||
VMultiDev.Write(Report.ToBytes());
|
VMultiDev.Write(Report.ToBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VMultiRelHandler : VMultiHandler<VMultiRelReport>, IVirtualTablet
|
public class VMultiRelHandler : VMultiHandler<VMultiRelReport>, IAbsolutePointer
|
||||||
{
|
{
|
||||||
private ushort prevX, prevY;
|
private ushort prevX, prevY;
|
||||||
|
|
||||||
|
|
|
@ -4,33 +4,35 @@ using HidSharp;
|
||||||
using OpenTabletDriver.Plugin;
|
using OpenTabletDriver.Plugin;
|
||||||
using OpenTabletDriver.Plugin.Attributes;
|
using OpenTabletDriver.Plugin.Attributes;
|
||||||
using OpenTabletDriver.Plugin.Output;
|
using OpenTabletDriver.Plugin.Output;
|
||||||
|
using OpenTabletDriver.Plugin.Platform.Display;
|
||||||
using OpenTabletDriver.Plugin.Platform.Pointer;
|
using OpenTabletDriver.Plugin.Platform.Pointer;
|
||||||
using static VoiDPlugins.WindowsInk.VMulti;
|
using static VoiDPlugins.WindowsInk.VMulti;
|
||||||
|
|
||||||
namespace VoiDPlugins.WindowsInk
|
namespace VoiDPlugins.WindowsInk
|
||||||
{
|
{
|
||||||
|
|
||||||
[PluginName("Artist Mode (Windows Ink)"), SupportedPlatform(PluginPlatform.Windows)]
|
[PluginName("Artist Mode (Windows Ink)"), SupportedPlatform(PluginPlatform.Windows)]
|
||||||
public class WindowsInk : AbsoluteOutputMode
|
public class WindowsInk : AbsoluteOutputMode
|
||||||
{
|
{
|
||||||
private readonly IVirtualTablet InkHandler = new InkHandler();
|
private readonly IAbsolutePointer InkHandler = new InkHandler();
|
||||||
public override IVirtualTablet VirtualTablet => InkHandler;
|
public override IAbsolutePointer Pointer => InkHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
[PluginName("Artist Mode (Relative Windows Ink)"), SupportedPlatform(PluginPlatform.Windows)]
|
[PluginName("Artist Mode (Relative Windows Ink)"), SupportedPlatform(PluginPlatform.Windows)]
|
||||||
public class WindowsInkRelative : RelativeOutputMode
|
public class WindowsInkRelative : RelativeOutputMode
|
||||||
{
|
{
|
||||||
private readonly IVirtualMouse InkHandler = new InkHandler();
|
private readonly IRelativePointer InkHandler = new InkHandler();
|
||||||
public override IVirtualMouse VirtualMouse => InkHandler;
|
public override IRelativePointer Pointer => InkHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InkHandler : IVirtualTablet, IPressureHandler, IVirtualMouse
|
public class InkHandler : IAbsolutePointer, IRelativePointer, IVirtualTablet, IVirtualMouse
|
||||||
{
|
{
|
||||||
private InkReport InkReport;
|
private readonly IVirtualScreen VirtualScreen = (Info.Driver as IVirtualDisplayDriver).VirtualScreen;
|
||||||
private readonly HidStream VMultiDev;
|
private readonly HidStream VMultiDev;
|
||||||
private bool EraserState;
|
private InkReport InkReport;
|
||||||
private Vector2 LastPos;
|
private Vector2 LastPos;
|
||||||
private readonly float Width = Info.Driver.VirtualScreen.Width;
|
private bool EraserState;
|
||||||
private readonly float Height = Info.Driver.VirtualScreen.Height;
|
private readonly Vector2 ScreenMax, ScreenToVMulti;
|
||||||
|
|
||||||
public InkHandler()
|
public InkHandler()
|
||||||
{
|
{
|
||||||
|
@ -59,6 +61,8 @@ namespace VoiDPlugins.WindowsInk
|
||||||
Log.Write("WindowsInk", "Install VMulti driver here: https://github.com/X9VoiD/vmulti-bin/releases/latest");
|
Log.Write("WindowsInk", "Install VMulti driver here: https://github.com/X9VoiD/vmulti-bin/releases/latest");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScreenMax = new Vector2(VirtualScreen.Width, VirtualScreen.Height) * 32767;
|
||||||
|
ScreenToVMulti = ScreenMax / 32767;
|
||||||
EraserState = false;
|
EraserState = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,17 +113,20 @@ namespace VoiDPlugins.WindowsInk
|
||||||
|
|
||||||
public void SetPosition(Vector2 pos)
|
public void SetPosition(Vector2 pos)
|
||||||
{
|
{
|
||||||
InkReport.X = (ushort)(pos.X / Width * 32767);
|
var newPos = pos / ScreenToVMulti;
|
||||||
InkReport.Y = (ushort)(pos.Y / Height * 32767);
|
InkReport.X = (ushort)newPos.X;
|
||||||
|
InkReport.Y = (ushort)newPos.Y;
|
||||||
VMultiDev.Write(InkReport);
|
VMultiDev.Write(InkReport);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Move(float dX, float dY)
|
public void Translate(Vector2 delta)
|
||||||
{
|
{
|
||||||
LastPos.X = Math.Clamp(LastPos.X + dX, 0, Width);
|
var newPos = LastPos + delta;
|
||||||
LastPos.Y = Math.Clamp(LastPos.Y + dY, 0, Height);
|
LastPos.X = Math.Clamp(newPos.X, 0, ScreenMax.X);
|
||||||
InkReport.X = (ushort)(LastPos.X / Width * 32767);
|
LastPos.Y = Math.Clamp(newPos.Y, 0, ScreenMax.Y);
|
||||||
InkReport.Y = (ushort)(LastPos.Y / Height * 32767);
|
var reportPos = LastPos / ScreenToVMulti;
|
||||||
|
InkReport.X = (ushort)reportPos.X;
|
||||||
|
InkReport.Y = (ushort)reportPos.Y;
|
||||||
VMultiDev.Write(InkReport);
|
VMultiDev.Write(InkReport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue