-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathMainForm.cs
More file actions
41 lines (32 loc) · 1.16 KB
/
MainForm.cs
File metadata and controls
41 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Linearstar.Windows.RawInput;
namespace RawInput.Sharp.DigitizerExample;
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
RawInputDevice.RegisterDevice(HidUsageAndPage.Pen, RawInputDeviceFlags.None, this.Handle);
RawInputDevice.RegisterDevice(HidUsageAndPage.TouchScreen, RawInputDeviceFlags.None, this.Handle);
RawInputDevice.RegisterDevice(HidUsageAndPage.TouchPad, RawInputDeviceFlags.None, this.Handle);
}
protected override void WndProc(ref Message m)
{
const int WM_INPUT = 0x00FF;
if (m.Msg == WM_INPUT)
{
var data = RawInputData.FromHandle(m.LParam);
if (data is RawInputDigitizerData digitizerData)
{
var contacts = digitizerData.Contacts;
this.textLabel.Text =
$"Touch anywhere in this window.\r\n\r\nContacts: {digitizerData.ContactsCount}\r\n"
+ string.Join("\r\n", contacts.Select(x => x.ToString()));
}
}
base.WndProc(ref m);
}
}