Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ internal static StylusPointPropertyInfo CreatePropertyInfo(UnsafeNativeMethods.P
{
StylusPointProperty stylusProp = new StylusPointProperty(propGuid, StylusPointPropertyIds.IsKnownButton(propGuid));

int logicalMin = prop.logicalMin;
int logicalMax = prop.logicalMax;

// Some touch digitizers report HID descriptors with invalid min/max values
// (e.g. Logical Minimum 0, Logical Maximum -1 from unsigned 0xFF interpreted
// as signed). Swap them so the StylusPointPropertyInfo constructor does not
// throw an ArgumentException. See dotnet/wpf#7069, #8435, and #8826.
if (logicalMax < logicalMin)
{
(logicalMin, logicalMax) = (logicalMax, logicalMin);
}

// Set Units
StylusPointPropertyUnit? unit = StylusPointPropertyUnitHelper.FromPointerUnit(prop.unit);

Expand All @@ -88,14 +100,14 @@ internal static StylusPointPropertyInfo CreatePropertyInfo(UnsafeNativeMethods.P
// Calculated resolution is a scaling factor from logical units into the physical space
// at the given exponentiation.
resolution =
(prop.logicalMax - prop.logicalMin) / ((prop.physicalMax - prop.physicalMin) * exponent);
(logicalMax - logicalMin) / ((prop.physicalMax - prop.physicalMin) * exponent);
}
}

result = new StylusPointPropertyInfo(
stylusProp,
prop.logicalMin,
prop.logicalMax,
logicalMin,
logicalMax,
unit.Value,
resolution);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ private void InitStylusPointDescription()
float res;
_pimcContext.GetPacketPropertyInfo(i, out guid, out min, out max, out units, out res); // Calls Unmanaged code - SecurityCritical with SUC.

// Some touch digitizers report HID descriptors with min greater than max.
// Swap them so the StylusPointPropertyInfo constructor does not throw an
// ArgumentException. See dotnet/wpf#7069, #8435, and #8826.
if (max < min)
{
(min, max) = (max, min);
}

if (pressureIndex == -1 && guid == StylusPointPropertyIds.NormalPressure)
{
pressureIndex = i;
Expand Down
Loading