Welcome to mirror list, hosted at ThFree Co, Russian Federation.

GHOST_TabletManagerWin32.h « intern « ghost « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 290798a6bfb70cb49265bb08da81e04071adaeff (plain)
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
112
113
114
115
116
117
// 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>

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;

	// tablet attributes
	bool hasPressure;
	float pressureScale;
	bool hasTilt;
	float azimuthScale;
	float altitudeScale;
//	float tiltScaleX;
//	float tiltScaleY;
//	UINT tiltMask;
	UINT cursorCount;
	UINT cursorBase;

	// candidate for a base class:
	TabletTool activeTool;

	int prevMouseX;
	int prevMouseY;

	// book-keeping
	std::map<GHOST_WindowWin32*,HCTX> contexts;
	HCTX contextForWindow(GHOST_WindowWin32*);

	void convertTilt(ORIENTATION const&, TabletToolData&);

public:
	GHOST_TabletManagerWin32();
	~GHOST_TabletManagerWin32();

	bool available(); // another base class candidate

	void openForWindow(GHOST_WindowWin32*);
	void closeForWindow(GHOST_WindowWin32*);

	void processPackets(GHOST_WindowWin32*);

	void changeTool(HCTX, UINT serialNumber);
	void dropTool();
	};

/*
The tablet manager is driven by the following Windows event processing code:

case WT_PACKET:
	m_tabletManager->processPackets((HCTX)lParam);
	break;
case WT_CSRCHANGE:
	m_tabletManager->changeTool((HCTX)lParam, wParam);
	break;
case WT_PROXIMITY:
	if (LOWORD(lParam) == 0)
		{
		puts("-- dropping tool --");
		m_tabletManager->dropTool();
		}
	break;
*/

#endif