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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// safe & friendly WinTab wrapper
// by Mike Erwin, July 2010
#ifndef GHOST_TABLET_MANAGER_WIN32_H
#define GHOST_TABLET_MANAGER_WIN32_H
#define _WIN32_WINNT 0x501 // require Windows XP or newer
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "wintab.h"
#include <map>
#include "GHOST_Types.h"
class GHOST_WindowWin32;
// BEGIN from Wacom's Utils.h
typedef UINT ( API * WTINFOA ) ( UINT, UINT, LPVOID );
typedef HCTX ( API * WTOPENA ) ( HWND, LPLOGCONTEXTA, BOOL );
typedef BOOL ( API * WTCLOSE ) ( HCTX );
typedef BOOL ( API * WTQUEUESIZESET ) ( HCTX, int );
typedef int ( API * WTPACKETSGET ) ( HCTX, int, LPVOID );
typedef BOOL ( API * WTPACKET ) ( HCTX, UINT, LPVOID );
// END
typedef enum { TABLET_NONE, TABLET_PEN, TABLET_ERASER, TABLET_MOUSE } TabletToolType;
typedef struct
{
TabletToolType type : 4; // plenty of room to grow
// capabilities
bool hasPressure : 1;
bool hasTilt : 1;
} TabletTool;
typedef struct
{
TabletTool tool;
float pressure;
float tilt_x, tilt_y;
} TabletToolData;
class GHOST_TabletManagerWin32
{
// the Wintab library
HMODULE lib_Wintab;
// WinTab function pointers
WTOPENA func_Open;
WTCLOSE func_Close;
WTINFOA func_Info;
WTQUEUESIZESET func_QueueSizeSet;
WTPACKETSGET func_PacketsGet;
WTPACKET func_Packet;
void getExtraInfo(); // to help support new/untested tablets
// tablet attributes
bool hasPressure;
float pressureScale;
bool hasTilt;
float azimuthScale;
float altitudeScale;
// float tiltScaleX;
// float tiltScaleY;
// UINT tiltMask;
UINT cursorCount;
UINT cursorBase;
WTPKT allTools; // standard info available from any tool (mouse/pen/etc.)
WTPKT someTools; // extra info available from only some tools
// book-keeping
std::map<GHOST_WindowWin32*,HCTX> contexts;
HCTX contextForWindow(GHOST_WindowWin32*);
GHOST_WindowWin32* activeWindow;
TabletTool activeTool;
BYTE sysButtonMap[32]; // user's custom button assignments for active tool
int prevMouseX;
int prevMouseY;
UINT prevButtons;
void convertTilt(ORIENTATION const&, TabletToolData&);
bool convertButton(const UINT button, GHOST_TButtonMask&);
public:
GHOST_TabletManagerWin32();
~GHOST_TabletManagerWin32();
bool available(); // another base class candidate
void openForWindow(GHOST_WindowWin32*);
void closeForWindow(GHOST_WindowWin32*);
// returns whether any packets resulted in GHOST events
bool processPackets(GHOST_WindowWin32* = NULL);
// void processPacket(GHOST_WindowWin32*, UINT serialNumber);
void changeTool(GHOST_WindowWin32*, UINT serialNumber);
void dropTool();
bool anyButtonsDown();
};
#endif
|