xref: /haiku/src/add-ons/input_server/devices/wacom/TabletDevice.h (revision 0562493379cd52eb7103531f895f10bb8e77c085)
1 /*
2  * Copyright 2003-2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
3  * Distributed under the terms of the MIT license.
4  */
5 
6 // This class encapsulates all info and status about a tablet.
7 // It runs the thread polling from the USB and sends messages
8 // to/via the InputServer.
9 
10 #ifndef TABLET_DEVICE_H
11 #define TABLET_DEVICE_H
12 
13 #include <OS.h>
14 
15 #include "PointingDevice.h"
16 
17 class TabletDevice : public PointingDevice {
18  public:
19 								TabletDevice(MasterServerDevice* parent,
20 									DeviceReader* reader);
21 	virtual						~TabletDevice();
22 
23 	virtual	status_t			InitCheck();
24 
25 	virtual	status_t			Start();
26 	virtual	status_t			Stop();
27 
28 			status_t			DetectDevice(const DeviceReader* reader);
29 
30 			void				SetDevice(float maxX, float maxY,
31 									uint32 mode = DEVICE_INTUOS);
32 
33 			void				ReadData(const uchar* data,
34 									bool& hasContact,
35 									uint32& mode,
36 									uint32& buttons,
37 									float& x, float& y,
38 									float& pressure,
39 									int32& clicks,
40 									int32& eraser,
41 									float& wheelX,
42 									float& wheelY,
43 									float& tiltX,
44 									float& tiltY) const;
45 
46 			void				SetStatus(uint32 mode,
47 									uint32 buttons,
48 									float x, float y,
49 									float pressure,
50 									int32 clicks,
51 									uint32 modifiers,
52 									int32 eraser,
53 									float wheelX,
54 									float wheelY,
55 									float tiltX = 0.0,
56 									float tiltY = 0.0,
57 									const uchar* data = NULL);
58 
59 			void				SetContact(bool contact);
60 
61  private:
62 	static int32				poll_usb_device(void* arg);
63 
64 			bool				_DeviceSupportsTilt() const;
65 			void				_GetName(uint16 productID,
66 									const char** name) const;
67 
68 	enum {
69 		DEVICE_UNKOWN,
70 		DEVICE_PENPARTNER,
71 		DEVICE_GRAPHIRE,
72 		DEVICE_INTUOS,
73 		DEVICE_INTUOS3,
74 		DEVICE_PL500,
75 		DEVICE_VOLITO,
76 		DEVICE_PENSTATION,
77 		DEVICE_CINTIQ,
78 	};
79 
80 	enum {
81 		MODE_PEN,
82 		MODE_MOUSE,
83 	};
84 
85 			thread_id			fThreadID;
86 
87 			// device specific settings
88 			uint32				fDeviceMode;
89 			float				fMaxX;
90 			float				fMaxY;
91 			int					fDataBytes;
92 
93 			float				fPosX;
94 			float				fPosY;
95 			float				fFakeMouseX;
96 			float				fFakeMouseY;
97 			uint32				fButtons;
98 			float				fPressure;
99 			uint32				fModifiers;
100 			bool				fEraser;
101 			float				fTiltX;
102 			float				fTiltY;
103 			float				fWheelX;
104 			float				fWheelY;
105 			bigtime_t			fLastClickTime;
106 			int32				fClicks;
107 			bool				fHasContact;
108 
109 			float				fJitterX;
110 			float				fJitterY;
111 };
112 
113 #endif	// WACOM_TABLET_H
114