-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
80 lines (66 loc) · 1.92 KB
/
Copy pathmain.cpp
File metadata and controls
80 lines (66 loc) · 1.92 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <windows.h>
#include <stdio.h>
#include <math.h>
#include "Tablet_IF.h"
int main()
{
unsigned char szBuff[9] = {0};
TABLETSTATE state, prevState;
INPUT Input={0};
bool rightMouse, middleMouse;
HANDLE hSerial;
hSerial = SerialInit(L"COM2", CBR_19200);
if (hSerial == (HANDLE)FALSE){ return -1; }
while (1) {
if (sizeof(szBuff)==SerialReadRaw(hSerial, szBuff, sizeof(szBuff)))
{
state = TabletPC_Parse(szBuff);
PrintStatus(state);
if (state.proximity)
{
::ZeroMemory(&Input,sizeof(INPUT));
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE;
Input.mi.dx = ceil(state.posX*2.15948333);
Input.mi.dy = ceil(state.posY*3.45508224);
::SendInput(1,&Input,sizeof(INPUT));
}
if ((state.buttons & BIT(WACOMBUTTON_TOUCH)) != (prevState.buttons & BIT(WACOMBUTTON_TOUCH)))
{
if (state.buttons & BIT(WACOMBUTTON_TOUCH))
{
::ZeroMemory(&Input,sizeof(INPUT));
Input.type = INPUT_MOUSE;
if (state.tool == WACOMTOOLTYPE_ERASER) {
Input.mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
middleMouse = true;
} else if (state.buttons & BIT(WACOMBUTTON_STYLUS)) {
Input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
rightMouse = true;
} else {
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
}
::SendInput(1,&Input,sizeof(INPUT));
} else {
::ZeroMemory(&Input,sizeof(INPUT));
Input.type = INPUT_MOUSE;
if (middleMouse) {
Input.mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
middleMouse = false;
} else if (rightMouse) {
Input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
rightMouse = false;
} else {
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
}
::SendInput(1,&Input,sizeof(INPUT));
}
}
prevState = state;
}
}
CloseHandle(hSerial);
printf("Press Return to exit.\n");
getchar();
return 0;
}