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