mirror of
https://github.com/vale981/VoiDPlugins
synced 2025-03-04 16:51:38 -05:00
Allow sending pointer events from all instances
This commit is contained in:
parent
5da36b89b2
commit
11c8e31647
5 changed files with 27 additions and 46 deletions
|
@ -13,7 +13,7 @@ namespace VoiDPlugins.OutputMode
|
|||
public unsafe class VMultiAbsolutePointer : IAbsolutePointer, ISynchronousPointer
|
||||
{
|
||||
private readonly AbsoluteInputReport* _rawPointer;
|
||||
private readonly VMultiInstance<AbsoluteInputReport>? _instance;
|
||||
private readonly VMultiInstance<AbsoluteInputReport> _instance;
|
||||
private Vector2 _conversionFactor;
|
||||
private Vector2 _prev;
|
||||
private bool _dirty;
|
||||
|
@ -21,23 +21,18 @@ namespace VoiDPlugins.OutputMode
|
|||
public VMultiAbsolutePointer(TabletReference tabletReference, IVirtualScreen virtualScreen)
|
||||
{
|
||||
_instance = new VMultiInstance<AbsoluteInputReport>("VMultiAbs", new AbsoluteInputReport());
|
||||
if (SharedStore.GetStore(tabletReference, STORE_KEY).TryAdd(INSTANCE, _instance))
|
||||
{
|
||||
_rawPointer = _instance.Pointer;
|
||||
_conversionFactor = new Vector2(32767, 32767) / new Vector2(virtualScreen.Width, virtualScreen.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
_instance = null;
|
||||
}
|
||||
var sharedStore = SharedStore.GetStore(tabletReference, STORE_KEY);
|
||||
if (!sharedStore.TryAdd(INSTANCE, _instance))
|
||||
_instance = sharedStore.Get<VMultiInstance<AbsoluteInputReport>>(INSTANCE);
|
||||
|
||||
_rawPointer = _instance.Pointer;
|
||||
_conversionFactor = new Vector2(32767, 32767) / new Vector2(virtualScreen.Width, virtualScreen.Height);
|
||||
}
|
||||
|
||||
public void SetPosition(Vector2 pos)
|
||||
{
|
||||
if (pos == _prev)
|
||||
return;
|
||||
if (_rawPointer is null)
|
||||
return;
|
||||
|
||||
pos *= _conversionFactor;
|
||||
_rawPointer->X = (ushort)pos.X;
|
||||
|
@ -52,7 +47,7 @@ namespace VoiDPlugins.OutputMode
|
|||
|
||||
public void Flush()
|
||||
{
|
||||
if (_dirty && _instance is not null)
|
||||
if (_dirty)
|
||||
{
|
||||
_dirty = false;
|
||||
_instance.Write();
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace VoiDPlugins.OutputMode
|
|||
public unsafe class VMultiRelativePointer : IRelativePointer, ISynchronousPointer
|
||||
{
|
||||
private readonly RelativeInputReport* _rawPointer;
|
||||
private readonly VMultiInstance<RelativeInputReport>? _instance;
|
||||
private readonly VMultiInstance<RelativeInputReport> _instance;
|
||||
private Vector2 _error;
|
||||
private Vector2 _prev;
|
||||
private bool _dirty;
|
||||
|
@ -19,14 +19,11 @@ namespace VoiDPlugins.OutputMode
|
|||
public VMultiRelativePointer(TabletReference tabletReference)
|
||||
{
|
||||
_instance = new VMultiInstance<RelativeInputReport>("VMultiRel", new RelativeInputReport());
|
||||
if (SharedStore.GetStore(tabletReference, STORE_KEY).TryAdd(INSTANCE, _instance))
|
||||
{
|
||||
_rawPointer = _instance.Pointer;
|
||||
}
|
||||
else
|
||||
{
|
||||
_instance = null;
|
||||
}
|
||||
var sharedStore = SharedStore.GetStore(tabletReference, STORE_KEY);
|
||||
if (!sharedStore.TryAdd(INSTANCE, _instance))
|
||||
_instance = sharedStore.Get<VMultiInstance<RelativeInputReport>>(INSTANCE);
|
||||
|
||||
_rawPointer = _instance.Pointer;
|
||||
}
|
||||
|
||||
public void SetPosition(Vector2 delta)
|
||||
|
|
|
@ -20,10 +20,8 @@ namespace VoiDPlugins.OutputMode
|
|||
{
|
||||
if (pos == _prev)
|
||||
return;
|
||||
if (Instance is null)
|
||||
return;
|
||||
|
||||
Instance!.EnableButtonBit((int)WindowsInkButtonFlags.InRange);
|
||||
Instance.EnableButtonBit((int)WindowsInkButtonFlags.InRange);
|
||||
pos *= _conversionFactor;
|
||||
RawPointer->X = (ushort)pos.X;
|
||||
RawPointer->Y = (ushort)pos.Y;
|
||||
|
|
|
@ -15,8 +15,8 @@ namespace VoiDPlugins.OutputMode
|
|||
private readonly IVirtualScreen _screen;
|
||||
private ThinVMultiAbsPointer? _osPointer;
|
||||
protected DigitizerInputReport* RawPointer { get; }
|
||||
protected VMultiInstance<DigitizerInputReport>? Instance { get; }
|
||||
protected SharedStore? SharedStore { get; }
|
||||
protected VMultiInstance<DigitizerInputReport> Instance { get; }
|
||||
protected SharedStore SharedStore { get; }
|
||||
protected bool Dirty { get; set; }
|
||||
|
||||
[Property("Sync")]
|
||||
|
@ -46,53 +46,46 @@ namespace VoiDPlugins.OutputMode
|
|||
}
|
||||
else
|
||||
{
|
||||
Instance = null;
|
||||
SharedStore = null;
|
||||
RawPointer = null;
|
||||
Instance = SharedStore.Get<VMultiInstance<DigitizerInputReport>>(INSTANCE);
|
||||
RawPointer = Instance.Pointer;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetEraser(bool isEraser)
|
||||
{
|
||||
if (!SharedStore?.Get<bool>(MANUAL_ERASER) ?? false)
|
||||
if (!SharedStore.Get<bool>(MANUAL_ERASER))
|
||||
{
|
||||
WindowsInkButtonHandler.EraserStateTransition(SharedStore!, Instance!, isEraser);
|
||||
WindowsInkButtonHandler.EraserStateTransition(SharedStore, Instance, isEraser);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPressure(float percentage)
|
||||
{
|
||||
if (RawPointer != null)
|
||||
RawPointer->Pressure = (ushort)(percentage * 8191);
|
||||
RawPointer->Pressure = (ushort)(percentage * 8191);
|
||||
}
|
||||
|
||||
public void SetTilt(Vector2 tilt)
|
||||
{
|
||||
if (RawPointer != null)
|
||||
{
|
||||
RawPointer->XTilt = (byte)tilt.X;
|
||||
RawPointer->YTilt = (byte)tilt.Y;
|
||||
}
|
||||
RawPointer->XTilt = (byte)tilt.X;
|
||||
RawPointer->YTilt = (byte)tilt.Y;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (RawPointer is not null && _osPointer is not null && !ForcedSync)
|
||||
{
|
||||
if (_osPointer is not null && !ForcedSync)
|
||||
_osPointer.SetPosition(new Vector2(RawPointer->X, RawPointer->Y));
|
||||
}
|
||||
}
|
||||
|
||||
public void Flush()
|
||||
{
|
||||
if (RawPointer is not null && Dirty)
|
||||
if (Dirty)
|
||||
{
|
||||
Dirty = false;
|
||||
|
||||
if (ForcedSync)
|
||||
_osPointer?.SetPosition(new Vector2(RawPointer->X, RawPointer->Y));
|
||||
|
||||
Instance!.Write();
|
||||
Instance.Write();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,6 @@ namespace VoiDPlugins.OutputMode
|
|||
{
|
||||
if (_prev == Vector2.Zero && delta == Vector2.Zero)
|
||||
return;
|
||||
if (Instance is null)
|
||||
return;
|
||||
|
||||
Instance.EnableButtonBit((int)WindowsInkButtonFlags.InRange);
|
||||
delta += _error;
|
||||
|
|
Loading…
Add table
Reference in a new issue