ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Windows/prefs_windows.cpp
Revision: 1.4
Committed: 2004-12-03T22:59:39Z (19 years, 6 months ago) by gbeauche
Branch: MAIN
Changes since 1.3: +4 -1 lines
Log Message:
more extfs related prefs items (debugextfs, extdrives)

File Contents

# Content
1 /*
2 * prefs_windows.cpp - Preferences handling, Windows specific stuff
3 *
4 * Basilisk II (C) 1997-2004 Christian Bauer
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #include "sysdeps.h"
22
23 #define WIN32_LEAN_AND_MEAN
24 #include <windows.h>
25
26 #include <stdio.h>
27 #include <stdlib.h>
28
29 #include <string>
30 using std::string;
31
32 #include "prefs.h"
33
34
35 // Platform-specific preferences items
36 prefs_desc platform_prefs_items[] = {
37 {"keycodes", TYPE_BOOLEAN, false, "use keycodes rather than keysyms to decode keyboard"},
38 {"keycodefile", TYPE_STRING, false, "path of keycode translation file"},
39 {"mousewheelmode", TYPE_INT32, false, "mouse wheel support mode (0=page up/down, 1=cursor up/down)"},
40 {"mousewheellines", TYPE_INT32, false, "number of lines to scroll in mouse wheel mode 1"},
41 #ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
42 {"ignoresegv", TYPE_BOOLEAN, false, "ignore illegal memory accesses"},
43 #endif
44 {"enableextfs", TYPE_BOOLEAN, false, "enable extfs system"},
45 {"debugextfs", TYPE_BOOLEAN, false, "debug extfs system"},
46 {"extdrives", TYPE_STRING, false, "define allowed extfs drives"},
47 {NULL, TYPE_END, false, NULL} // End of list
48 };
49
50
51 // Prefs file name and path
52 const char PREFS_FILE_NAME[] = "BasiliskII_prefs";
53 string UserPrefsPath;
54 static string prefs_path;
55
56
57 /*
58 * Load preferences from settings file
59 */
60
61 void LoadPrefs(void)
62 {
63 // Construct prefs path
64 if (UserPrefsPath.empty()) {
65 int pwd_len = GetCurrentDirectory(0, NULL);
66 char *pwd = new char[pwd_len];
67 if (GetCurrentDirectory(pwd_len, pwd) == pwd_len - 1)
68 prefs_path = string(pwd) + '\\';
69 delete[] pwd;
70 prefs_path += PREFS_FILE_NAME;
71 } else
72 prefs_path = UserPrefsPath;
73
74 // Read preferences from settings file
75 FILE *f = fopen(prefs_path.c_str(), "r");
76 if (f != NULL) {
77
78 // Prefs file found, load settings
79 LoadPrefsFromStream(f);
80 fclose(f);
81
82 } else {
83
84 // No prefs file, save defaults
85 SavePrefs();
86 }
87 }
88
89
90 /*
91 * Save preferences to settings file
92 */
93
94 void SavePrefs(void)
95 {
96 FILE *f;
97 if ((f = fopen(prefs_path.c_str(), "w")) != NULL) {
98 SavePrefsToStream(f);
99 fclose(f);
100 }
101 }
102
103
104 /*
105 * Add defaults of platform-specific prefs items
106 * You may also override the defaults set in PrefsInit()
107 */
108
109 void AddPlatformPrefsDefaults(void)
110 {
111 PrefsAddBool("keycodes", false);
112 PrefsReplaceBool("enableextfs", false);
113 PrefsReplaceString("extfs", "");
114 PrefsReplaceString("extdrives", "CDEFGHIJKLMNOPQRSTUVWXYZ");
115 PrefsReplaceInt32("mousewheelmode", 1);
116 PrefsReplaceInt32("mousewheellines", 3);
117 #ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
118 PrefsAddBool("ignoresegv", false);
119 #endif
120 }