mirror of
https://github.com/vale981/VoiDPlugins
synced 2025-03-05 09:11:38 -05:00
Update again...
This commit is contained in:
parent
3dd078ea2d
commit
8fa4e35b7f
8 changed files with 35 additions and 34 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit b8b346c4e50186f5f623beedb2fdb682600c2b61
|
Subproject commit 502589660232add52a1ae7bd7de584e7192f2ec2
|
|
@ -3,7 +3,7 @@
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>0.3.0</Version>
|
<Version>0.3.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||||
|
|
|
@ -3,14 +3,14 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace VoiDPlugins.OutputMode
|
namespace VoiDPlugins.OutputMode
|
||||||
{
|
{
|
||||||
public static class Touch
|
public class TouchDevice
|
||||||
{
|
{
|
||||||
private static IntPtr _penHandle;
|
private readonly IntPtr _penHandle;
|
||||||
private static POINTER_TYPE_INFO[]? pointer;
|
private readonly POINTER_TYPE_INFO[]? pointer;
|
||||||
private static uint _pointerId;
|
private readonly uint _pointerId;
|
||||||
private static IntPtr _sourceDevice;
|
private readonly IntPtr _sourceDevice;
|
||||||
|
|
||||||
public static unsafe void Init()
|
public unsafe TouchDevice()
|
||||||
{
|
{
|
||||||
NativeMethods.GetPointerDevices(out uint count, null);
|
NativeMethods.GetPointerDevices(out uint count, null);
|
||||||
POINTER_DEVICE_INFO[] pointerDevices = new POINTER_DEVICE_INFO[count];
|
POINTER_DEVICE_INFO[] pointerDevices = new POINTER_DEVICE_INFO[count];
|
||||||
|
@ -21,7 +21,7 @@ namespace VoiDPlugins.OutputMode
|
||||||
if (device.pointerDeviceType == POINTER_DEVICE_TYPE.EXTERNAL_PEN ||
|
if (device.pointerDeviceType == POINTER_DEVICE_TYPE.EXTERNAL_PEN ||
|
||||||
device.pointerDeviceType == POINTER_DEVICE_TYPE.INTEGRATED_PEN)
|
device.pointerDeviceType == POINTER_DEVICE_TYPE.INTEGRATED_PEN)
|
||||||
{
|
{
|
||||||
_pointerId = (uint)device.startingCursorId;
|
_pointerId = device.startingCursorId;
|
||||||
_sourceDevice = new IntPtr(device.device);
|
_sourceDevice = new IntPtr(device.device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ namespace VoiDPlugins.OutputMode
|
||||||
ClearPointerFlags(POINTER_FLAGS.INRANGE | POINTER_FLAGS.PRIMARY);
|
ClearPointerFlags(POINTER_FLAGS.INRANGE | POINTER_FLAGS.PRIMARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Inject()
|
public void Inject()
|
||||||
{
|
{
|
||||||
if (!NativeMethods.InjectSyntheticPointerInput(_penHandle, pointer!, 1))
|
if (!NativeMethods.InjectSyntheticPointerInput(_penHandle, pointer!, 1))
|
||||||
{
|
{
|
||||||
|
@ -85,38 +85,38 @@ namespace VoiDPlugins.OutputMode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetTarget()
|
public void SetTarget()
|
||||||
{
|
{
|
||||||
pointer![0].penInfo.pointerInfo.hwndTarget = NativeMethods.GetForegroundWindow();
|
pointer![0].penInfo.pointerInfo.hwndTarget = NativeMethods.GetForegroundWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetPosition(POINT point)
|
public void SetPosition(POINT point)
|
||||||
{
|
{
|
||||||
pointer![0].penInfo.pointerInfo.ptPixelLocation = point;
|
pointer![0].penInfo.pointerInfo.ptPixelLocation = point;
|
||||||
pointer[0].penInfo.pointerInfo.ptPixelLocationRaw = point;
|
pointer[0].penInfo.pointerInfo.ptPixelLocationRaw = point;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetPressure(uint pressure)
|
public void SetPressure(uint pressure)
|
||||||
{
|
{
|
||||||
pointer![0].penInfo.pressure = pressure;
|
pointer![0].penInfo.pressure = pressure;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetPointerFlags(POINTER_FLAGS flags)
|
public void SetPointerFlags(POINTER_FLAGS flags)
|
||||||
{
|
{
|
||||||
pointer![0].penInfo.pointerInfo.pointerFlags |= flags;
|
pointer![0].penInfo.pointerInfo.pointerFlags |= flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UnsetPointerFlags(POINTER_FLAGS flags)
|
public void UnsetPointerFlags(POINTER_FLAGS flags)
|
||||||
{
|
{
|
||||||
pointer![0].penInfo.pointerInfo.pointerFlags &= ~flags;
|
pointer![0].penInfo.pointerInfo.pointerFlags &= ~flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ClearPointerFlags()
|
public void ClearPointerFlags()
|
||||||
{
|
{
|
||||||
pointer![0].penInfo.pointerInfo.pointerFlags = 0;
|
pointer![0].penInfo.pointerInfo.pointerFlags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ClearPointerFlags(POINTER_FLAGS flags)
|
public void ClearPointerFlags(POINTER_FLAGS flags)
|
||||||
{
|
{
|
||||||
pointer![0].penInfo.pointerInfo.pointerFlags = flags;
|
pointer![0].penInfo.pointerInfo.pointerFlags = flags;
|
||||||
}
|
}
|
|
@ -5,40 +5,41 @@ namespace VoiDPlugins.OutputMode
|
||||||
{
|
{
|
||||||
public class TouchPointerHandler : IAbsolutePointer, IPressureHandler
|
public class TouchPointerHandler : IAbsolutePointer, IPressureHandler
|
||||||
{
|
{
|
||||||
|
private readonly TouchDevice _touchDevice;
|
||||||
private bool _inContact;
|
private bool _inContact;
|
||||||
private bool _lastContact;
|
private bool _lastContact;
|
||||||
|
|
||||||
public TouchPointerHandler()
|
public TouchPointerHandler()
|
||||||
{
|
{
|
||||||
Touch.Init();
|
_touchDevice = new TouchDevice();
|
||||||
_inContact = false;
|
_inContact = false;
|
||||||
_lastContact = false;
|
_lastContact = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPosition(Vector2 pos)
|
public void SetPosition(Vector2 pos)
|
||||||
{
|
{
|
||||||
Touch.SetPosition(new POINT((int)pos.X, (int)pos.Y));
|
_touchDevice.SetPosition(new POINT((int)pos.X, (int)pos.Y));
|
||||||
if (_inContact != _lastContact)
|
if (_inContact != _lastContact)
|
||||||
{
|
{
|
||||||
if (_inContact)
|
if (_inContact)
|
||||||
{
|
{
|
||||||
Touch.UnsetPointerFlags(POINTER_FLAGS.UP | POINTER_FLAGS.UPDATE);
|
_touchDevice.UnsetPointerFlags(POINTER_FLAGS.UP | POINTER_FLAGS.UPDATE);
|
||||||
Touch.SetPointerFlags(POINTER_FLAGS.DOWN);
|
_touchDevice.SetPointerFlags(POINTER_FLAGS.DOWN);
|
||||||
_lastContact = _inContact;
|
_lastContact = _inContact;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Touch.UnsetPointerFlags(POINTER_FLAGS.DOWN | POINTER_FLAGS.UPDATE);
|
_touchDevice.UnsetPointerFlags(POINTER_FLAGS.DOWN | POINTER_FLAGS.UPDATE);
|
||||||
Touch.SetPointerFlags(POINTER_FLAGS.UP);
|
_touchDevice.SetPointerFlags(POINTER_FLAGS.UP);
|
||||||
_lastContact = _inContact;
|
_lastContact = _inContact;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Touch.SetPointerFlags(POINTER_FLAGS.UPDATE);
|
_touchDevice.SetPointerFlags(POINTER_FLAGS.UPDATE);
|
||||||
}
|
}
|
||||||
Touch.SetTarget();
|
_touchDevice.SetTarget();
|
||||||
Touch.Inject();
|
_touchDevice.Inject();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPressure(float percentage)
|
public void SetPressure(float percentage)
|
||||||
|
@ -46,14 +47,14 @@ namespace VoiDPlugins.OutputMode
|
||||||
var pressure = (uint)(percentage * 1024);
|
var pressure = (uint)(percentage * 1024);
|
||||||
if (pressure > 0)
|
if (pressure > 0)
|
||||||
{
|
{
|
||||||
Touch.SetPressure(pressure);
|
_touchDevice.SetPressure(pressure);
|
||||||
Touch.SetPointerFlags(POINTER_FLAGS.INCONTACT | POINTER_FLAGS.FIRSTBUTTON);
|
_touchDevice.SetPointerFlags(POINTER_FLAGS.INCONTACT | POINTER_FLAGS.FIRSTBUTTON);
|
||||||
_inContact = true;
|
_inContact = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Touch.SetPressure(1);
|
_touchDevice.SetPressure(1);
|
||||||
Touch.UnsetPointerFlags(POINTER_FLAGS.INCONTACT | POINTER_FLAGS.FIRSTBUTTON);
|
_touchDevice.UnsetPointerFlags(POINTER_FLAGS.INCONTACT | POINTER_FLAGS.FIRSTBUTTON);
|
||||||
_inContact = false;
|
_inContact = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace VoiDPlugins.OutputMode
|
||||||
[OnDependencyLoad]
|
[OnDependencyLoad]
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
_pointer = new VMultiAbsolutePointer(TabletReference, _virtualScreen!);
|
_pointer = new VMultiAbsolutePointer(Tablet, _virtualScreen!);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IAbsolutePointer Pointer
|
public override IAbsolutePointer Pointer
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace VoiDPlugins.OutputMode
|
||||||
[OnDependencyLoad]
|
[OnDependencyLoad]
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
_pointer = new VMultiRelativePointer(TabletReference);
|
_pointer = new VMultiRelativePointer(Tablet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IRelativePointer Pointer
|
public override IRelativePointer Pointer
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace VoiDPlugins.OutputMode
|
||||||
[OnDependencyLoad]
|
[OnDependencyLoad]
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
_pointer = new WinInkAbsolutePointer(TabletReference, _virtualScreen!);
|
_pointer = new WinInkAbsolutePointer(Tablet, _virtualScreen!);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IAbsolutePointer Pointer
|
public override IAbsolutePointer Pointer
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace VoiDPlugins.OutputMode
|
||||||
[OnDependencyLoad]
|
[OnDependencyLoad]
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
_pointer = new WinInkRelativePointer(TabletReference, _virtualScreen!);
|
_pointer = new WinInkRelativePointer(Tablet, _virtualScreen!);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IRelativePointer Pointer
|
public override IRelativePointer Pointer
|
||||||
|
|
Loading…
Add table
Reference in a new issue