xref: /haiku/src/servers/input/MouseSettings.h (revision 909af08f4328301fbdef1ffb41f566c3b5bec0c7)
1 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
2 //
3 //	Copyright (c) 2004, Haiku
4 //
5 //  This software is part of the Haiku distribution and is covered
6 //  by the Haiku license.
7 //
8 //
9 //  File:			MouseSettings.h
10 //  Authors:		Jérôme Duval,
11 //					Andrew McCall (mccall@digitalparadise.co.uk),
12 //					Axel Dörfler (axeld@pinc-software.de)
13 //  Description:	Input Server
14 //  Created:		August 29, 2004
15 //
16 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
17 
18 #ifndef MOUSE_SETTINGS_H_
19 #define MOUSE_SETTINGS_H_
20 
21 #include <Archivable.h>
22 #include <InterfaceDefs.h>
23 #include <kb_mouse_settings.h>
24 #include <Path.h>
25 #include <String.h>
26 #include <SupportDefs.h>
27 
28 #include <map>
29 
30 
31 class MouseSettings {
32 	public:
33 		MouseSettings();
34 		MouseSettings(const mouse_settings* originalSettings);
35 		~MouseSettings();
36 
37 		void Defaults();
38 		void Dump();
39 
40 		int32 MouseType() const { return fSettings.type; }
41 		void SetMouseType(int32 type);
42 
43 		bigtime_t ClickSpeed() const;
44 		void SetClickSpeed(bigtime_t click_speed);
45 
46 		int32 MouseSpeed() const { return fSettings.accel.speed; }
47 		void SetMouseSpeed(int32 speed);
48 
49 		int32 AccelerationFactor() const
50 			{ return fSettings.accel.accel_factor; }
51 		void SetAccelerationFactor(int32 factor);
52 
53 		uint32 Mapping(int32 index) const;
54 		void Mapping(mouse_map &map) const;
55 		void SetMapping(int32 index, uint32 button);
56 		void SetMapping(mouse_map &map);
57 
58 		mode_mouse MouseMode() const { return fMode; }
59 		void SetMouseMode(mode_mouse mode);
60 
61 		mode_focus_follows_mouse FocusFollowsMouseMode() const
62 			{ return fFocusFollowsMouseMode; }
63 		void SetFocusFollowsMouseMode(mode_focus_follows_mouse mode);
64 
65 		bool AcceptFirstClick() const { return fAcceptFirstClick; }
66 		void SetAcceptFirstClick(bool acceptFirstClick);
67 
68 		const mouse_settings* GetSettings() { return &fSettings; }
69 
70 	private:
71 		void _AssureValidMapping();
72 
73 	private:
74 		mouse_settings	fSettings;
75 
76 		// FIXME all these extra settings are not specific to each mouse.
77 		// They should be moved into MultipleMouseSettings directly
78 		mode_mouse		fMode;
79 		mode_focus_follows_mouse	fFocusFollowsMouseMode;
80 		bool			fAcceptFirstClick;
81 };
82 
83 
84 class MultipleMouseSettings: public BArchivable {
85 	public:
86 		MultipleMouseSettings();
87 		~MultipleMouseSettings();
88 
89 		status_t Archive(BMessage* into, bool deep = false) const;
90 
91 		void Defaults();
92 		void Dump();
93 		status_t SaveSettings();
94 
95 
96 		MouseSettings* AddMouseSettings(BString mouse_name);
97 		MouseSettings* GetMouseSettings(BString mouse_name);
98 
99 	private:
100 		static status_t GetSettingsPath(BPath &path);
101 		void RetrieveSettings();
102 
103 		typedef std::map<BString, MouseSettings*> mouse_settings_object;
104 		mouse_settings_object  fMouseSettingsObject;
105 };
106 
107 #endif	// MOUSE_SETTINGS_H
108