Skip to content

Commit

Permalink
Add initial support for Wacom DTU-1141
Browse files Browse the repository at this point in the history
  • Loading branch information
mochaaP committed Dec 28, 2024
1 parent 9bf597c commit 593d97f
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
29 changes: 29 additions & 0 deletions OpenTabletDriver.Configurations/Configurations/Wacom/DTU-1141.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"Name": "Wacom DTU-1141",
"Specifications": {
"Digitizer": {
"Width": 234.66,
"Height": 131.99,
"MaxX": 23672,
"MaxY": 13403
},
"Pen": {
"MaxPressure": 1023,
"ButtonCount": 1
},
"AuxiliaryButtons": {
"ButtonCount": 4
}
},
"DigitizerIdentifiers": [
{
"VendorID": 1386,
"ProductID": 822,
"InputReportLength": 64,
"ReportParser": "OpenTabletDriver.Configurations.Parsers.Wacom.DTU.DTUReportParser",
"FeatureInitReport": [
"AgI="
]
}
]
}
28 changes: 28 additions & 0 deletions OpenTabletDriver.Configurations/Parsers/Wacom/DTU/DTUAuxReport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using OpenTabletDriver.Tablet;

namespace OpenTabletDriver.Configurations.Parsers.Wacom.DTU
{
public struct DTUAuxReport : IAuxReport
{
public DTUAuxReport(byte[] report)
{
Raw = report;

var auxByte = report[1];
AuxButtons = new bool[]
{
auxByte.IsBitSet(0),
auxByte.IsBitSet(1),
auxByte.IsBitSet(2),
auxByte.IsBitSet(3),
auxByte.IsBitSet(4),
auxByte.IsBitSet(5),
auxByte.IsBitSet(6),
auxByte.IsBitSet(7),
};
}

public byte[] Raw { set; get; }
public bool[] AuxButtons { set; get; }
}
}
39 changes: 39 additions & 0 deletions OpenTabletDriver.Configurations/Parsers/Wacom/DTU/DTUReport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Buffers.Binary;
using System.Numerics;
using System.Runtime.CompilerServices;
using OpenTabletDriver.Tablet;

namespace OpenTabletDriver.Configurations.Parsers.Wacom.DTU
{
public struct DTUReport : ITabletReport
{
public DTUReport(byte[] report)
{
Raw = report;

Position = new Vector2
{
X = BinaryPrimitives.ReadUInt16BigEndian(report.AsSpan(3, 4)),
Y = BinaryPrimitives.ReadUInt16BigEndian(report.AsSpan(5, 6))
};
Pressure = BinaryPrimitives.ReadUInt16BigEndian(report.AsSpan(1, 2)) & (uint)0x0FFFu;

var penByte = (byte)(report[1] >> 4);
// Bit 0 = Pen Tip
// Bit 1 = Pen Button 1
// Bit 2 = Pen Button 2
// Bit 3 = Hovering
PenButtons = new bool[]
{
penByte.IsBitSet(1),
penByte.IsBitSet(2)
};
}

public byte[] Raw { set; get; }
public Vector2 Position { set; get; }
public uint Pressure { set; get; }
public bool[] PenButtons { set; get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using OpenTabletDriver.Tablet;

namespace OpenTabletDriver.Configurations.Parsers.Wacom.DTU
{
public class DTUReportParser : IReportParser<IDeviceReport>
{
public virtual IDeviceReport Parse(byte[] data)
{
return data[0] switch
{
0x11 => new DTUReport(data),
0x15 => new DTUAuxReport(data),
_ => new DeviceReport(data)
};
}
}
}

0 comments on commit 593d97f

Please sign in to comment.