xref: /haiku/src/add-ons/input_server/devices/wacom/MasterServerDevice.h (revision e6b30aee0fd7a23d6a6baab9f3718945a0cd838a)
1 /*
2  * Copyright 2005-2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
3  * Distributed under the terms of the MIT license.
4  */
5 #ifndef MASTER_SERVER_DEVICE_H
6 #define MASTER_SERVER_DEVICE_H
7 
8 #include <add-ons/input_server/InputServerDevice.h>
9 #include <List.h>
10 #include <Locker.h>
11 #include <String.h>
12 
13 // export this for the input_server
14 extern "C" _EXPORT BInputServerDevice* instantiate_input_device();
15 
16 class MasterServerDevice : public BInputServerDevice {
17  public:
18 							MasterServerDevice();
19 	virtual					~MasterServerDevice();
20 
21 							// BInputServerDevice
22 	virtual status_t		InitCheck();
23 	virtual status_t		SystemShuttingDown();
24 
25 	virtual status_t		Start(const char* device, void* cookie);
26 	virtual	status_t		Stop(const char* device, void* cookie);
27 	virtual status_t		Control(const char	*device,
28 									void		*cookie,
29 									uint32		code,
30 									BMessage	*message);
31 
32 							// MasterServerDevice
33 			bigtime_t		DoubleClickSpeed() const
34 								{ return fDblClickSpeed; }
35 			const float*	AccelerationTable() const
36 								{ return fAccelerationTable; }
37 
38 							// debugging
39 	inline	BString&		LogString()
40 								{ return fLogString; }
41 			void			LogDataBytes(uchar* data, int bytes);
42 			void			DumpLogString(const char* path);
43 
44 private:
45 			void			_SearchDevices();
46 
47 			void			_StopAll();
48 			void			_AddDevice(const char* path);
49 			void			_HandleNodeMonitor(BMessage* message);
50 
51 			void			_CalculateAccelerationTable();
52 
53 							// thread function for watching
54 							// the status of master device
55 //	static	int32			_ps2_disabler(void* cookie);
56 //			void			_StartPS2DisablerThread();
57 //			void			_StopPS2DisablerThread();
58 
59 			bool			_LockDevices();
60 			void			_UnlockDevices();
61 
62 			// list of mice objects
63 			BList			fDevices;
64 	volatile bool			fActive;
65 
66 			// debugging
67 			BString			fLogString;
68 
69 			// global stuff for all mice objects
70 			int32			fSpeed;
71 			int32			fAcceleration;
72 			bigtime_t		fDblClickSpeed;
73 			float			fAccelerationTable[256];
74 
75 			// support halting the PS/2 mouse thread as long as we exist
76 			thread_id		fPS2DisablerThread;
77 			BLocker			fDeviceLock;
78 };
79 
80 #endif	// MASTER_SERVER_DEVICE_H
81