Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,666 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In the following Packets in the RealTimeStylus API, I need to get the coordinates of the current input point on the screen. But strangely I found that this coordinate is normal for mouse input, while when it comes to finger and pen, the coordinate calculated by the same method is ten times bigger. I don't know why this is, and simply removing ten times results in the mouse coordinates being ten times smaller, which is clearly not the correct solution. What should I do, please and thank you.
STDMETHOD(Packets)(IRealTimeStylus* piRtsSrc, const StylusInfo* pStylusInfo, ULONG /*cPktCount*/, ULONG /*cPktBuffLength*/, LONG* pPacket, ULONG* /*pcInOutPkts*/, LONG** /*ppInOutPkts*/)
{
FLOAT fInkToDeviceScaleX = 0.0f;
FLOAT fInkToDeviceScaleY = 0.0f;
ULONG ulPacketProperties = 0;
PACKET_PROPERTY* pPacketProperties;
piRtsSrc->GetPacketDescriptionData(pStylusInfo->tcid, &fInkToDeviceScaleX, &fInkToDeviceScaleY, &ulPacketProperties, &pPacketProperties);
TouchMode mode{};
for (int i = 0; i < ulPacketProperties; i++)
{
GUID guid = pPacketProperties[i].guid;
if (guid == GUID_PACKETPROPERTY_GUID_X) mode.pt.x = LONG(pPacket[i] * fInkToDeviceScaleX + 0.5);
else if (guid == GUID_PACKETPROPERTY_GUID_Y) mode.pt.y = LONG(pPacket[i] * fInkToDeviceScaleY + 0.5);
else if (guid == GUID_PACKETPROPERTY_GUID_NORMAL_PRESSURE) mode.pressure = pPacket[i];
else if (guid == GUID_PACKETPROPERTY_GUID_WIDTH) mode.touchWidth = pPacket[i];
else if (guid == GUID_PACKETPROPERTY_GUID_HEIGHT) mode.touchHeight = pPacket[i];
}
std::unique_lock<std::shared_mutex> lock2(PointPosSm);
TouchPos[TouchPointer[pStylusInfo->cid]] = mode;
lock2.unlock();
return S_OK;
}