forked from OpenTabletDriver/OpenTabletDriver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial support for Wacom DTU-1141
- Loading branch information
Showing
4 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
OpenTabletDriver.Configurations/Configurations/Wacom/DTU-1141.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
28
OpenTabletDriver.Configurations/Parsers/Wacom/DTU/DTUAuxReport.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
39
OpenTabletDriver.Configurations/Parsers/Wacom/DTU/DTUReport.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
OpenTabletDriver.Configurations/Parsers/Wacom/DTU/DTUReportParser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}; | ||
} | ||
} | ||
} |