mirror of
https://github.com/vale981/VoiDPlugins
synced 2025-03-04 16:51: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>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>0.3.0</Version>
|
||||
<Version>0.3.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
|
|
|
@ -3,14 +3,14 @@ using System.Runtime.InteropServices;
|
|||
|
||||
namespace VoiDPlugins.OutputMode
|
||||
{
|
||||
public static class Touch
|
||||
public class TouchDevice
|
||||
{
|
||||
private static IntPtr _penHandle;
|
||||
private static POINTER_TYPE_INFO[]? pointer;
|
||||
private static uint _pointerId;
|
||||
private static IntPtr _sourceDevice;
|
||||
private readonly IntPtr _penHandle;
|
||||
private readonly POINTER_TYPE_INFO[]? pointer;
|
||||
private readonly uint _pointerId;
|
||||
private readonly IntPtr _sourceDevice;
|
||||
|
||||
public static unsafe void Init()
|
||||
public unsafe TouchDevice()
|
||||
{
|
||||
NativeMethods.GetPointerDevices(out uint count, null);
|
||||
POINTER_DEVICE_INFO[] pointerDevices = new POINTER_DEVICE_INFO[count];
|
||||
|
@ -21,7 +21,7 @@ namespace VoiDPlugins.OutputMode
|
|||
if (device.pointerDeviceType == POINTER_DEVICE_TYPE.EXTERNAL_PEN ||
|
||||
device.pointerDeviceType == POINTER_DEVICE_TYPE.INTEGRATED_PEN)
|
||||
{
|
||||
_pointerId = (uint)device.startingCursorId;
|
||||
_pointerId = device.startingCursorId;
|
||||
_sourceDevice = new IntPtr(device.device);
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ namespace VoiDPlugins.OutputMode
|
|||
ClearPointerFlags(POINTER_FLAGS.INRANGE | POINTER_FLAGS.PRIMARY);
|
||||
}
|
||||
|
||||
public static void Inject()
|
||||
public void Inject()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
public static void SetPosition(POINT point)
|
||||
public void SetPosition(POINT point)
|
||||
{
|
||||
pointer![0].penInfo.pointerInfo.ptPixelLocation = point;
|
||||
pointer[0].penInfo.pointerInfo.ptPixelLocationRaw = point;
|
||||
}
|
||||
|
||||
public static void SetPressure(uint pressure)
|
||||
public void SetPressure(uint 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;
|
||||
}
|
||||
|
||||
public static void UnsetPointerFlags(POINTER_FLAGS flags)
|
||||
public void UnsetPointerFlags(POINTER_FLAGS flags)
|
||||
{
|
||||
pointer![0].penInfo.pointerInfo.pointerFlags &= ~flags;
|
||||
}
|
||||
|
||||
public static void ClearPointerFlags()
|
||||
public void ClearPointerFlags()
|
||||
{
|
||||
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;
|
||||
}
|
|
@ -5,40 +5,41 @@ namespace VoiDPlugins.OutputMode
|
|||
{
|
||||
public class TouchPointerHandler : IAbsolutePointer, IPressureHandler
|
||||
{
|
||||
private readonly TouchDevice _touchDevice;
|
||||
private bool _inContact;
|
||||
private bool _lastContact;
|
||||
|
||||
public TouchPointerHandler()
|
||||
{
|
||||
Touch.Init();
|
||||
_touchDevice = new TouchDevice();
|
||||
_inContact = false;
|
||||
_lastContact = false;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Touch.UnsetPointerFlags(POINTER_FLAGS.UP | POINTER_FLAGS.UPDATE);
|
||||
Touch.SetPointerFlags(POINTER_FLAGS.DOWN);
|
||||
_touchDevice.UnsetPointerFlags(POINTER_FLAGS.UP | POINTER_FLAGS.UPDATE);
|
||||
_touchDevice.SetPointerFlags(POINTER_FLAGS.DOWN);
|
||||
_lastContact = _inContact;
|
||||
}
|
||||
else
|
||||
{
|
||||
Touch.UnsetPointerFlags(POINTER_FLAGS.DOWN | POINTER_FLAGS.UPDATE);
|
||||
Touch.SetPointerFlags(POINTER_FLAGS.UP);
|
||||
_touchDevice.UnsetPointerFlags(POINTER_FLAGS.DOWN | POINTER_FLAGS.UPDATE);
|
||||
_touchDevice.SetPointerFlags(POINTER_FLAGS.UP);
|
||||
_lastContact = _inContact;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Touch.SetPointerFlags(POINTER_FLAGS.UPDATE);
|
||||
_touchDevice.SetPointerFlags(POINTER_FLAGS.UPDATE);
|
||||
}
|
||||
Touch.SetTarget();
|
||||
Touch.Inject();
|
||||
_touchDevice.SetTarget();
|
||||
_touchDevice.Inject();
|
||||
}
|
||||
|
||||
public void SetPressure(float percentage)
|
||||
|
@ -46,14 +47,14 @@ namespace VoiDPlugins.OutputMode
|
|||
var pressure = (uint)(percentage * 1024);
|
||||
if (pressure > 0)
|
||||
{
|
||||
Touch.SetPressure(pressure);
|
||||
Touch.SetPointerFlags(POINTER_FLAGS.INCONTACT | POINTER_FLAGS.FIRSTBUTTON);
|
||||
_touchDevice.SetPressure(pressure);
|
||||
_touchDevice.SetPointerFlags(POINTER_FLAGS.INCONTACT | POINTER_FLAGS.FIRSTBUTTON);
|
||||
_inContact = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Touch.SetPressure(1);
|
||||
Touch.UnsetPointerFlags(POINTER_FLAGS.INCONTACT | POINTER_FLAGS.FIRSTBUTTON);
|
||||
_touchDevice.SetPressure(1);
|
||||
_touchDevice.UnsetPointerFlags(POINTER_FLAGS.INCONTACT | POINTER_FLAGS.FIRSTBUTTON);
|
||||
_inContact = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace VoiDPlugins.OutputMode
|
|||
[OnDependencyLoad]
|
||||
public void Initialize()
|
||||
{
|
||||
_pointer = new VMultiAbsolutePointer(TabletReference, _virtualScreen!);
|
||||
_pointer = new VMultiAbsolutePointer(Tablet, _virtualScreen!);
|
||||
}
|
||||
|
||||
public override IAbsolutePointer Pointer
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace VoiDPlugins.OutputMode
|
|||
[OnDependencyLoad]
|
||||
public void Initialize()
|
||||
{
|
||||
_pointer = new VMultiRelativePointer(TabletReference);
|
||||
_pointer = new VMultiRelativePointer(Tablet);
|
||||
}
|
||||
|
||||
public override IRelativePointer Pointer
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace VoiDPlugins.OutputMode
|
|||
[OnDependencyLoad]
|
||||
public void Initialize()
|
||||
{
|
||||
_pointer = new WinInkAbsolutePointer(TabletReference, _virtualScreen!);
|
||||
_pointer = new WinInkAbsolutePointer(Tablet, _virtualScreen!);
|
||||
}
|
||||
|
||||
public override IAbsolutePointer Pointer
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace VoiDPlugins.OutputMode
|
|||
[OnDependencyLoad]
|
||||
public void Initialize()
|
||||
{
|
||||
_pointer = new WinInkRelativePointer(TabletReference, _virtualScreen!);
|
||||
_pointer = new WinInkRelativePointer(Tablet, _virtualScreen!);
|
||||
}
|
||||
|
||||
public override IRelativePointer Pointer
|
||||
|
|
Loading…
Add table
Reference in a new issue