Skip to content

Commit

Permalink
Merge pull request OpenTabletDriver#2503 from gonX/artistmode-disable…
Browse files Browse the repository at this point in the history
…proximity

Linux Artist Mode: Ignore proximity
  • Loading branch information
InfinityGhost authored Nov 23, 2022
2 parents 62b9e98 + 986910f commit 428c4ba
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace OpenTabletDriver.Desktop.Interop.Input.Absolute
{
public class EvdevVirtualTablet : EvdevVirtualMouse, IPressureHandler, ITiltHandler, IEraserHandler, IHoverDistanceHandler, IProximityHandler, ISynchronousPointer
public class EvdevVirtualTablet : EvdevVirtualMouse, IPressureHandler, ITiltHandler, IEraserHandler, IHoverDistanceHandler, ISynchronousPointer
{
// order seems important due to reset ordering (to satisfy libinput)
// tools -> touch -> buttons
Expand All @@ -25,7 +25,6 @@ public class EvdevVirtualTablet : EvdevVirtualMouse, IPressureHandler, ITiltHand
private const int RESOLUTION = 1000; // subpixels per screen pixel

private bool _isEraser;
private bool _proximity = true;

public unsafe EvdevVirtualTablet(IVirtualScreen virtualScreen)
{
Expand Down Expand Up @@ -96,7 +95,7 @@ public unsafe EvdevVirtualTablet(IVirtualScreen virtualScreen)

public void SetPosition(Vector2 pos)
{
Device.Write(EventType.EV_KEY, _isEraser ? EventCode.BTN_TOOL_RUBBER : EventCode.BTN_TOOL_PEN, _proximity ? 1 : 0);
Device.Write(EventType.EV_KEY, _isEraser ? EventCode.BTN_TOOL_RUBBER : EventCode.BTN_TOOL_PEN, 1);
Device.Write(EventType.EV_ABS, EventCode.ABS_X, (int)(pos.X * RESOLUTION));
Device.Write(EventType.EV_ABS, EventCode.ABS_Y, (int)(pos.Y * RESOLUTION));
}
Expand All @@ -118,11 +117,6 @@ public void SetEraser(bool isEraser)
this._isEraser = isEraser;
}

public void SetProximity(bool proximity)
{
this._proximity = proximity;
}

public void SetHoverDistance(uint distance)
{
Device.Write(EventType.EV_ABS, EventCode.ABS_DISTANCE, (int)distance);
Expand All @@ -141,7 +135,6 @@ public void Reset()
Device.Write(EventType.EV_ABS, EventCode.ABS_PRESSURE, 0);

_isEraser = false;
_proximity = true; // we counterintuitively set this to true since its the initial state
}

public void Flush()
Expand Down
9 changes: 2 additions & 7 deletions OpenTabletDriver/Output/AbsoluteOutputMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,8 @@ protected override void OnOutput(IDeviceReport report)
pressureHandler.SetPressure(tabletReport.Pressure / (float)Tablet.Configuration.Specifications.Pen!.MaxPressure);
if (report is ITiltReport tiltReport && Pointer is ITiltHandler tiltHandler)
tiltHandler.SetTilt(tiltReport.Tilt);
if (report is IProximityReport proximityReport)
{
if (Pointer is IProximityHandler proximityHandler)
proximityHandler.SetProximity(proximityReport.NearProximity);
if (Pointer is IHoverDistanceHandler hoverDistanceHandler)
hoverDistanceHandler.SetHoverDistance(proximityReport.HoverDistance);
}
if (report is IProximityReport proximityReport && Pointer is IHoverDistanceHandler hoverDistanceHandler)
hoverDistanceHandler.SetHoverDistance(proximityReport.HoverDistance);
if (Pointer is ISynchronousPointer synchronousPointer)
{
if (report is OutOfRangeReport)
Expand Down
9 changes: 2 additions & 7 deletions OpenTabletDriver/Output/RelativeOutputMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,8 @@ protected override void OnOutput(IDeviceReport report)
pressureHandler.SetPressure(tabletReport.Pressure / (float)Tablet.Configuration.Specifications.Pen!.MaxPressure);
if (report is ITiltReport tiltReport && Pointer is ITiltHandler tiltHandler)
tiltHandler.SetTilt(tiltReport.Tilt);
if (report is IProximityReport proximityReport)
{
if (Pointer is IProximityHandler proximityHandler)
proximityHandler.SetProximity(proximityReport.NearProximity);
if (Pointer is IHoverDistanceHandler hoverDistanceHandler)
hoverDistanceHandler.SetHoverDistance(proximityReport.HoverDistance);
}
if (report is IProximityReport proximityReport && Pointer is IHoverDistanceHandler hoverDistanceHandler)
hoverDistanceHandler.SetHoverDistance(proximityReport.HoverDistance);
if (Pointer is ISynchronousPointer synchronousPointer)
{
if (report is OutOfRangeReport)
Expand Down
19 changes: 0 additions & 19 deletions OpenTabletDriver/Platform/Pointer/IProximityHandler.cs

This file was deleted.

0 comments on commit 428c4ba

Please sign in to comment.