How to get graphic tablet pen pressure value?

依然范特西╮ 提交于 2019-11-28 19:58:01

Wacom provides an extensive API to get data directly from the tablet.The API includes example code for detecting pressure, tilt and other interactions:

  • Tilt Test: Demonstrates pressure, use of the eraser and pen tilt properties
  • Pressure Test: Demonstrates how to detect and display pen pressure

These code samples are in C, but there are also examples that in c#.net that include code to handle pressure:

  • WintabDN: Interface, scribble and tablet control samples using Wintab .NET

Using this project as an example, you can get the pressure like this:

// Create a data object and hook a packetlistener to receive
// updatse by the tablet
m_wtData = new CWintabData();
m_wtData.SetWTPacketEventHandler(handler);

//Handles packet receive event
void handler(object sender,MessageReceivedEventArgs e)
{
     //Get the packet id
     uint pktID = (uint)eventArgs_I.Message.WParam;

     //Get the data for that packet
     WintabPacket pkt = m_wtData.GetDataPacket((uint)eventArgs_I.Message.LParam, pktID);

     //Grab the pressure
     var pressure = pk.pkNormalPressure.pkAbsoluteNormalPressure;
}

Next, here is a CodeProject that explains how to use the Wacom Tablet with the WPF InkCanvas

A good starting point for any tablet related development on windows is also the Ink API.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!