2020-09-15 18:14:22 +08:00
|
|
|
using System.Numerics;
|
|
|
|
using OpenTabletDriver.Plugin;
|
|
|
|
using OpenTabletDriver.Plugin.Attributes;
|
|
|
|
using OpenTabletDriver.Plugin.Output;
|
|
|
|
using OpenTabletDriver.Plugin.Platform.Pointer;
|
2020-10-15 21:25:17 +08:00
|
|
|
using static VoiDPlugins.VMultiMode.VMulti;
|
2020-09-15 18:14:22 +08:00
|
|
|
|
2020-10-15 21:25:17 +08:00
|
|
|
namespace VoiDPlugins.VMultiMode
|
2020-09-15 18:14:22 +08:00
|
|
|
{
|
|
|
|
[PluginName("VMulti Absolute Output Mode"), SupportedPlatform(PluginPlatform.Windows)]
|
|
|
|
public class VMultiAbsMode : AbsoluteOutputMode
|
|
|
|
{
|
2020-10-15 20:35:53 +08:00
|
|
|
private readonly IVirtualTablet AbsHandler = new VMultiAbsHandler();
|
|
|
|
public override IVirtualTablet VirtualTablet => AbsHandler;
|
2020-09-15 18:14:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[PluginName("VMulti Relative Output Mode"), SupportedPlatform(PluginPlatform.Windows)]
|
|
|
|
public class VMultiRelMode : AbsoluteOutputMode
|
|
|
|
{
|
2020-10-15 20:35:53 +08:00
|
|
|
private readonly IVirtualTablet RelHandler = new VMultiRelHandler();
|
|
|
|
public override IVirtualTablet VirtualTablet => RelHandler;
|
2020-09-15 18:14:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public class VMultiAbsHandler : VMultiHandler<VMultiAbsReport>, IVirtualTablet
|
|
|
|
{
|
2020-10-15 20:35:53 +08:00
|
|
|
private readonly float Width = Info.Driver.VirtualScreen.Width;
|
|
|
|
private readonly float Height = Info.Driver.VirtualScreen.Height;
|
|
|
|
|
|
|
|
public VMultiAbsHandler()
|
2020-09-15 18:14:22 +08:00
|
|
|
{
|
|
|
|
Init("VMultiAbs", 0x09);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetPosition(Vector2 pos)
|
|
|
|
{
|
2020-10-15 20:35:53 +08:00
|
|
|
Report.X = (ushort)(pos.X / Width * 32767);
|
|
|
|
Report.Y = (ushort)(pos.Y / Height * 32767);
|
2020-09-15 18:14:22 +08:00
|
|
|
VMultiDev.Write(Report.ToBytes());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class VMultiRelHandler : VMultiHandler<VMultiRelReport>, IVirtualTablet
|
|
|
|
{
|
2020-10-15 20:35:53 +08:00
|
|
|
private ushort prevX, prevY;
|
|
|
|
|
|
|
|
public VMultiRelHandler()
|
2020-09-15 18:14:22 +08:00
|
|
|
{
|
|
|
|
Init("VMultiRel", 0x04);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetPosition(Vector2 pos)
|
|
|
|
{
|
|
|
|
var X = (ushort)pos.X;
|
|
|
|
var Y = (ushort)pos.Y;
|
|
|
|
Report.X = (byte)(X - prevX);
|
|
|
|
Report.Y = (byte)(Y - prevY);
|
|
|
|
prevX = X;
|
|
|
|
prevY = Y;
|
|
|
|
VMultiDev.Write(Report.ToBytes());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|