xref: /haiku/src/servers/input/MouseSettings.h (revision 410ed2fbba58819ac21e27d3676739728416761d)
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(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 		void RetrieveSettings();
69 		status_t SaveSettings();
70 
71 		const mouse_settings* GetSettings() { return &fSettings; }
72 
73 	private:
74 		static status_t GetSettingsPath(BPath &path);
75 
76 		mouse_settings	fSettings, fOriginalSettings;
77 
78 		// FIXME all these extra settings are not specific to each mouse.
79 		// They should be moved into MultipleMouseSettings directly
80 		mode_mouse		fMode, fOriginalMode;
81 		mode_focus_follows_mouse	fFocusFollowsMouseMode;
82 		mode_focus_follows_mouse	fOriginalFocusFollowsMouseMode;
83 		bool			fAcceptFirstClick;
84 		bool			fOriginalAcceptFirstClick;
85 };
86 
87 
88 class MultipleMouseSettings: public BArchivable {
89 	public:
90 		MultipleMouseSettings();
91 		~MultipleMouseSettings();
92 
93 		status_t Archive(BMessage* into, bool deep = false) const;
94 
95 		void Defaults();
96 		void Dump();
97 		status_t SaveSettings();
98 
99 
100 		MouseSettings* AddMouseSettings(BString mouse_name);
101 		MouseSettings* GetMouseSettings(BString mouse_name);
102 
103 	private:
104 		static status_t GetSettingsPath(BPath &path);
105 		void RetrieveSettings();
106 
107 		MouseSettings*	fDeprecatedMouseSettings;
108 
109 		typedef std::map<BString, MouseSettings*> mouse_settings_object;
110 		mouse_settings_object  fMouseSettingsObject;
111 };
112 
113 #endif	// MOUSE_SETTINGS_H
114