tagging release
[dasher.git] / Src / DasherCore / Parameters.h
blob1c511df29f4295a9117304bdf151f39e3bc0b4c4
1 #ifndef __parameters_h__
2 #define __parameters_h__
4 #include <string>
6 #ifndef _WIN32
7 #include "../../config.h"
8 #endif
10 // All parameters go into the enums here
11 // They are unique across the different types
12 enum {
13 BP_DRAW_MOUSE_LINE, BP_DRAW_MOUSE,
14 BP_SHOW_SLIDER, BP_START_MOUSE,
15 BP_START_SPACE, BP_START_STYLUS, BP_STOP_IDLE, BP_KEY_CONTROL, BP_CONTROL_MODE,
16 BP_COLOUR_MODE, BP_MOUSEPOS_MODE,
17 BP_OUTLINE_MODE, BP_PALETTE_CHANGE,
18 BP_AUTOCALIBRATE, BP_DASHER_PAUSED,
19 BP_GAME_MODE, BP_TRAINING, BP_REDRAW, BP_LM_DICTIONARY,
20 BP_LM_LETTER_EXCLUSION, BP_AUTO_SPEEDCONTROL, BP_CLICK_MODE,
21 BP_LM_ADAPTIVE, BP_BUTTONONESTATIC, BP_BUTTONONEDYNAMIC,
22 BP_BUTTONMENU, BP_BUTTONPULSING, BP_BUTTONSTEADY,
23 BP_BUTTONDIRECT, BP_BUTTONFOURDIRECT, BP_BUTTONALTERNATINGDIRECT,
24 BP_COMPASSMODE, BP_SOCKET_INPUT_ENABLE, BP_SOCKET_DEBUG,
25 BP_OLD_STYLE_PUSH, BP_CIRCLE_START, BP_GLOBAL_KEYBOARD,
26 BP_DELAY_VIEW, BP_CONVERSION_MODE, BP_PAUSE_OUTSIDE, BP_BACKOFF_BUTTON,
27 BP_TWOBUTTON_REVERSE, BP_SLOW_START, BP_TWOBUTTON_SPEED, END_OF_BPS
30 enum {
31 LP_ORIENTATION = END_OF_BPS, LP_REAL_ORIENTATION, LP_MAX_BITRATE,
32 LP_VIEW_ID, LP_LANGUAGE_MODEL_ID, LP_DASHER_FONTSIZE,
33 LP_UNIFORM, LP_YSCALE, LP_MOUSEPOSDIST, LP_STOP_IDLETIME, LP_TRUNCATION,
34 LP_TRUNCATIONTYPE, LP_LM_MAX_ORDER, LP_LM_EXCLUSION,
35 LP_LM_UPDATE_EXCLUSION, LP_LM_ALPHA, LP_LM_BETA,
36 LP_LM_MIXTURE, LP_MOUSE_POS_BOX, LP_NORMALIZATION, LP_LINE_WIDTH,
37 LP_LM_WORD_ALPHA, LP_USER_LOG_LEVEL_MASK, LP_SPEED_DIVISOR,
38 LP_ZOOMSTEPS, LP_B, LP_S, LP_Z, LP_R, LP_RIGHTZOOM,
39 LP_BOOSTFACTOR, LP_AUTOSPEED_SENSITIVITY, LP_SOCKET_PORT, LP_SOCKET_INPUT_X_MIN, LP_SOCKET_INPUT_X_MAX,
40 LP_SOCKET_INPUT_Y_MIN, LP_SOCKET_INPUT_Y_MAX, LP_OX, LP_OY, LP_MAX_Y, LP_INPUT_FILTER,
41 LP_CIRCLE_PERCENT, LP_TWO_BUTTON_OFFSET, LP_HOLD_TIME, LP_MULTIPRESS_TIME, LP_MULTIPRESS_COUNT,
42 LP_SLOW_START_TIME, LP_DYNAMIC_MEDIAN_FACTOR, END_OF_LPS
45 enum {
46 SP_ALPHABET_ID = END_OF_LPS, SP_ALPHABET_1, SP_ALPHABET_2, SP_ALPHABET_3, SP_ALPHABET_4,
47 SP_COLOUR_ID, SP_DEFAULT_COLOUR_ID, SP_DASHER_FONT, SP_SYSTEM_LOC, SP_USER_LOC, SP_GAME_TEXT_FILE,
48 SP_TRAIN_FILE, SP_SOCKET_INPUT_X_LABEL, SP_SOCKET_INPUT_Y_LABEL, SP_INPUT_FILTER, SP_INPUT_DEVICE,
49 SP_BUTTON_0, SP_BUTTON_1, SP_BUTTON_2, SP_BUTTON_3, SP_BUTTON_4, SP_BUTTON_10, SP_JOYSTICK_DEVICE,
50 END_OF_SPS
53 // Define first int value of the first element of each type.
54 // Useful for offsetting into specific arrays,
55 // since each setting is a unique int, but all 3 arrays start at 0
56 #define FIRST_BP 0
57 #define FIRST_LP END_OF_BPS
58 #define FIRST_SP END_OF_LPS
60 // Define the number of each type of setting
61 #define NUM_OF_BPS END_OF_BPS
62 #define NUM_OF_LPS (END_OF_LPS - END_OF_BPS)
63 #define NUM_OF_SPS (END_OF_SPS - END_OF_LPS)
65 #define PERS true
67 // First level structures with only basic data types because you
68 // cannot initialize struct tables with objects
69 // These will be turned into std::strings in the ParamTables() object
70 struct bp_table {
71 int key;
72 const char *regName;
73 bool persistent;
74 bool defaultValue;
75 const char *humanReadable;
77 struct lp_table {
78 int key;
79 const char *regName;
80 bool persistent;
81 long defaultValue;
82 const char *humanReadable;
84 struct sp_table {
85 int key;
86 const char *regName;
87 bool persistent;
88 const char *defaultValue;
89 const char *humanReadable;
92 // The only important thing here is that these are in the same order
93 // as the enum declarations (could add check in class that enforces this instead)
94 static bp_table boolparamtable[] = {
95 {BP_DRAW_MOUSE_LINE, "DrawMouseLine", PERS, true, "Draw Mouse Line"},
96 {BP_DRAW_MOUSE, "DrawMouse", PERS, false, "Draw Mouse Position"},
97 #ifdef WITH_MAEMO
98 {BP_SHOW_SLIDER, "ShowSpeedSlider", PERS, false, "ShowSpeedSlider"},
99 #else
100 {BP_SHOW_SLIDER, "ShowSpeedSlider", PERS, true, "ShowSpeedSlider"},
101 #endif
102 {BP_START_MOUSE, "StartOnLeft", PERS, true, "StartOnLeft"},
103 {BP_START_SPACE, "StartOnSpace", PERS, false, "StartOnSpace"},
104 {BP_START_STYLUS, "StartOnStylus", PERS, false, "StartOnStylus"},
105 {BP_STOP_IDLE, "StopOnIdle", PERS, false, "StopOnIdle"},
106 {BP_KEY_CONTROL, "KeyControl", PERS, false, "KeyControl"},
107 {BP_CONTROL_MODE, "ControlMode", PERS, false, "ControlMode"},
108 {BP_COLOUR_MODE, "ColourMode", PERS, true, "ColourMode"},
109 {BP_MOUSEPOS_MODE, "StartOnMousePosition", PERS, false, "StartOnMousePosition"},
110 {BP_OUTLINE_MODE, "OutlineBoxes", PERS, true, "OutlineBoxes"},
111 {BP_PALETTE_CHANGE, "PaletteChange", PERS, true, "PaletteChange"},
112 {BP_AUTOCALIBRATE, "Autocalibrate", PERS, true, "Autocalibrate"},
113 {BP_DASHER_PAUSED, "DasherPaused", !PERS, true, "Dasher Paused"},
114 {BP_GAME_MODE, "GameMode", PERS, false, "Dasher Game Mode"},
115 {BP_TRAINING, "Training", !PERS, false, "Provides locking during training"},
116 {BP_REDRAW, "Redraw", !PERS, false, "Force a full redraw at the next timer event"},
117 {BP_LM_DICTIONARY, "Dictionary", PERS, true, "Whether the word-based language model uses a dictionary"},
118 {BP_LM_LETTER_EXCLUSION, "LetterExclusion", PERS, true, "Whether to do letter exclusion in the word-based model"},
119 {BP_AUTO_SPEEDCONTROL, "AutoSpeedControl", PERS, true, "AutoSpeedControl"},
120 {BP_CLICK_MODE, "ClickMode", PERS, false, "Dasher Click Mode"},
121 {BP_LM_ADAPTIVE, "LMAdaptive", PERS, true, "Whether language model should learn as you enter text"},
122 {BP_BUTTONONESTATIC, "ButtonOneStaticMode", PERS, false, "One-button static mode"},
123 {BP_BUTTONONEDYNAMIC, "ButtonOneDynamicMode", PERS, false, "One-button dynamic mode"},
124 {BP_BUTTONMENU, "ButtonMenuMode", PERS, false, "Button menu mode"},
125 {BP_BUTTONPULSING, "ButtonPulsingMode", PERS, false, "One-button dynamic pulsing mode"},
126 {BP_BUTTONSTEADY, "ButtonSteadyMode", PERS, true, "One-button dynamic steady mode"},
127 {BP_BUTTONDIRECT, "ButtonDirectMode", PERS, false, "Three-button direct mode"},
128 {BP_BUTTONFOURDIRECT, "ButtonFourDirectMode", PERS, false, "Four-button direct mode"},
129 {BP_BUTTONALTERNATINGDIRECT, "ButtonAlternatingDirectMode", PERS, true, "Alternating direct mode"},
130 {BP_COMPASSMODE, "ButtonCompassMode", PERS, false, "Compass mode"},
131 {BP_SOCKET_INPUT_ENABLE, "SocketInputEnable", PERS, false, "Read pointer coordinates from network socket instead of mouse"},
132 {BP_SOCKET_DEBUG, "SocketInputDebug", PERS, false, "Print information about socket input processing to console"},
133 {BP_OLD_STYLE_PUSH, "OldStylePush", PERS, false, "Old style node pushing algorithm"},
134 {BP_CIRCLE_START, "CircleStart", PERS, false, "Start on circle mode"},
135 {BP_GLOBAL_KEYBOARD, "GlobalKeyboard", PERS, false, "Whether to assume global control of the keyboard"},
136 {BP_DELAY_VIEW, "DelayView", !PERS, false, "Delayed dynamics (for two button mode)"},
137 {BP_CONVERSION_MODE, "ConversionMode", !PERS, false, "Whether Dasher is operating in conversion (eg Japanese) mode"},
138 {BP_PAUSE_OUTSIDE, "PauseOutside", PERS, false, "Whether to pause when pointer leaves canvas area"},
139 {BP_BACKOFF_BUTTON, "BackoffButton", PERS, true, "Whether to enable the extra backoff button in dynamic mode"},
140 {BP_TWOBUTTON_REVERSE, "TwoButtonReverse", PERS, false, "Reverse the up/down buttons in two button mode"},
141 {BP_SLOW_START, "SlowStart", PERS, false, "Start at low speed and insrease"},
142 {BP_TWOBUTTON_SPEED, "TwoButtonSpeed", PERS, true, "Two button mode auto speed control"}
145 static lp_table longparamtable[] = {
146 {LP_ORIENTATION, "ScreenOrientation", PERS, -2, "Screen Orientation"},
147 {LP_REAL_ORIENTATION, "RealOrientation", !PERS, 0, "Actual screen orientation (allowing for alphabet default)"},
148 {LP_MAX_BITRATE, "MaxBitRateTimes100", PERS, 80, "Max Bit Rate Times 100"},
149 {LP_VIEW_ID, "ViewID", PERS, 1, "ViewID"},
150 {LP_LANGUAGE_MODEL_ID, "LanguageModelID", PERS, 0, "LanguageModelID"},
151 {LP_DASHER_FONTSIZE, "DasherFontSize", PERS, 2, "DasherFontSize"},
152 {LP_UNIFORM, "UniformTimes1000", PERS, 50, "UniformTimes1000"},
153 {LP_YSCALE, "YScaling", PERS, 0, "YScaling"},
154 {LP_MOUSEPOSDIST, "MousePositionBoxDistance", PERS, 50, "MousePositionBoxDistance"},
155 {LP_STOP_IDLETIME, "StopIdleTime", PERS, 1000, "StopIdleTime" },
156 {LP_TRUNCATION, "Truncation", PERS, 0, "Truncation"},
157 {LP_TRUNCATIONTYPE, "TruncationType", PERS, 0, "TruncationType"},
158 {LP_LM_MAX_ORDER, "LMMaxOrder", PERS, 5, "LMMaxOrder"},
159 {LP_LM_EXCLUSION, "LMExclusion", PERS, 0, "LMExclusion"},
160 {LP_LM_UPDATE_EXCLUSION, "LMUpdateExclusion", PERS, 1, "LMUpdateExclusion"},
161 {LP_LM_ALPHA, "LMAlpha", PERS, 49, "LMAlpha"},
162 {LP_LM_BETA, "LMBeta", PERS, 77, "LMBeta"},
163 {LP_LM_MIXTURE, "LMMixture", PERS, 50, "LMMixture"},
164 {LP_MOUSE_POS_BOX, "MousePosBox", !PERS, -1, "Mouse Position Box Indicator"},
165 {LP_NORMALIZATION, "Normalization", !PERS, 1 << 16, "Interval for child nodes"},
166 {LP_LINE_WIDTH, "LineWidth", PERS, 1, "Width to draw crosshair and mouse line"},
167 {LP_LM_WORD_ALPHA, "WordAlpha", PERS, 50, "Alpha value for word-based model"},
168 {LP_USER_LOG_LEVEL_MASK, "UserLogLevelMask", PERS, 0, "Controls level of user logging, 0 = none, 1 = short, 2 = detailed, 3 = both"},
169 {LP_SPEED_DIVISOR, "SpeedDivisor", !PERS, 100, "Factor by which to slow down (multiplied by 100)"},
170 {LP_ZOOMSTEPS, "Zoomsteps", PERS, 32, "Integerised ratio of zoom size for click/button mode, denom 64."},
171 {LP_B, "ButtonMenuBoxes", PERS, 4, "Number of boxes for button menu mode"},
172 {LP_S, "ButtonMenuSafety", PERS, 25, "Safety parameter for button mode, in percent."},
173 {LP_Z, "ButtonMenuBackwardsBox", PERS, 1, "Number of back-up boxes for button menu mode"},
174 {LP_R, "ButtonModeNonuniformity", PERS, 0, "Button mode box non-uniformity"},
175 {LP_RIGHTZOOM, "ButtonCompassModeRightZoom", PERS, 5120, "Zoomfactor (*1024) for compass mode"},
176 {LP_BOOSTFACTOR, "BoostFactor", !PERS, 100, "Boost/brake factor (multiplied by 100)"},
177 {LP_AUTOSPEED_SENSITIVITY, "AutospeedSensitivity", PERS, 100, "Sensitivity of automatic speed control (percent)"},
178 {LP_SOCKET_PORT, "SocketPort", PERS, 20320, "UDP/TCP socket to use for network socket input"},
179 {LP_SOCKET_INPUT_X_MIN, "SocketInputXMinTimes1000", PERS, 0, "Bottom of range of X values expected from network input"},
180 {LP_SOCKET_INPUT_X_MAX, "SocketInputXMaxTimes1000", PERS, 1000, "Top of range of X values expected from network input"},
181 {LP_SOCKET_INPUT_Y_MIN, "SocketInputYMinTimes1000", PERS, 0, "Bottom of range of Y values expected from network input"},
182 {LP_SOCKET_INPUT_Y_MAX, "SocketInputYMaxTimes1000", PERS, 1000, "Top of range of Y values expected from network input"},
183 {LP_OX, "OX", PERS, 2048, "X coordinate of crosshair"},
184 {LP_OY, "OY", PERS, 2048, "Y coordinate of crosshair"},
185 {LP_MAX_Y, "MaxY", PERS, 4096, "Maximum Y coordinate"},
186 {LP_INPUT_FILTER, "InputFilterID", PERS, 3, "Module ID of input filter"},
187 {LP_CIRCLE_PERCENT, "CirclePercent", PERS, 10, "Percentage of nominal vertical range to use for radius of start circle"},
188 {LP_TWO_BUTTON_OFFSET, "TwoButtonOffset", PERS, 1024, "Offset for two button dynamic mode"},
189 {LP_HOLD_TIME, "HoldTime", PERS, 1000, "Time for which buttons must be held to count as long presses, in ms"},
190 {LP_MULTIPRESS_TIME, "MultipressTime", PERS, 3000, "Time in which multiple presses must occur, in ms"},
191 {LP_MULTIPRESS_COUNT, "MultipressCount", PERS, 3, "Time in which multiple presses must occur to count"},
192 {LP_SLOW_START_TIME, "SlowStartTime", PERS, 1000, "Time over which slow start occurs"},
193 {LP_DYNAMIC_MEDIAN_FACTOR, "DynamicMedianFactor", PERS, 30, "Percentage of the median at which dynamic mode auto speed control kicks in"}
196 static sp_table stringparamtable[] = {
197 {SP_ALPHABET_ID, "AlphabetID", PERS, "", "AlphabetID"},
198 {SP_ALPHABET_1, "Alphabet1", PERS, "", "Alphabet History 1"},
199 {SP_ALPHABET_2, "Alphabet2", PERS, "", "Alphabet History 2"},
200 {SP_ALPHABET_3, "Alphabet3", PERS, "", "Alphabet History 3"},
201 {SP_ALPHABET_4, "Alphabet4", PERS, "", "Alphabet History 4"},
202 {SP_COLOUR_ID, "ColourID", PERS, "", "ColourID"},
203 {SP_DEFAULT_COLOUR_ID, "DefaultColourID", !PERS, "", "Default Colour ID (Used for auto-colour mode)"},
204 {SP_DASHER_FONT, "DasherFont", PERS, "", "DasherFont"},
205 {SP_SYSTEM_LOC, "SystemLocation", !PERS, "sys_", "System Directory"},
206 {SP_USER_LOC, "UserLocation", !PERS, "usr_", "User Directory"},
207 {SP_GAME_TEXT_FILE, "GameTextFile", !PERS, "gamemode_english_GB.txt", "File with strings to practice writing"},
208 {SP_TRAIN_FILE, "TrainingFile", !PERS, "", "Training text for alphabet"},
209 {SP_SOCKET_INPUT_X_LABEL, "SocketInputXLabel", PERS, "x", "Label preceding X values for network input"},
210 {SP_SOCKET_INPUT_Y_LABEL, "SocketInputYLabel", PERS, "y", "Label preceding Y values for network input"},
211 #ifdef WITH_MAEMO
212 {SP_INPUT_FILTER, "InputFilter", PERS, "Stylus Control", "Input filter used to provide the current control mode"},
213 #else
214 {SP_INPUT_FILTER, "InputFilter", PERS, "Normal Control", "Input filter used to provide the current control mode"},
215 #endif
216 {SP_INPUT_DEVICE, "InputDevice", PERS, "Mouse Input", "Driver for the input device"},
217 {SP_BUTTON_0, "Button0", PERS, "", "Assignment to button 0"},
218 {SP_BUTTON_1, "Button1", PERS, "", "Assignment to button 1"},
219 {SP_BUTTON_2, "Button2", PERS, "", "Assignment to button 2"},
220 {SP_BUTTON_3, "Button3", PERS, "", "Assignment to button 3"},
221 {SP_BUTTON_4, "Button4", PERS, "", "Assignment to button 4"},
222 {SP_BUTTON_10, "Button10", PERS, "", "Assignment to button 10"},
223 {SP_JOYSTICK_DEVICE, "JoystickDevice", PERS, "/dev/input/js0", "Joystick device"}
226 // This is the structure of each table that the settings will access
227 // Everything is const except the current value of the setting
228 struct bp_info {
229 int key;
230 std::string regName;
231 bool persistent;
232 bool value;
233 bool defaultVal;
234 std::string humanReadable;
236 struct lp_info {
237 int key;
238 std::string regName;
239 bool persistent;
240 long value;
241 long defaultVal;
242 std::string humanReadable;
244 struct sp_info {
245 int key;
246 std::string regName;
247 bool persistent;
248 std::string value;
249 std::string defaultVal;
250 std::string humanReadable;
253 namespace Dasher {
254 class CParamTables;
256 /// \ingroup Core
257 /// \{
258 class Dasher::CParamTables {
260 // These are the parameter tables that store everything
261 public:
262 bp_info BoolParamTable[NUM_OF_BPS];
263 lp_info LongParamTable[NUM_OF_LPS];
264 sp_info StringParamTable[NUM_OF_SPS];
266 public:
267 CParamTables() {
268 // Initialize all the tables with default values
269 // and convert the char* to std::string in the object
270 for(int ii = 0; ii < NUM_OF_BPS; ii++) {
271 BoolParamTable[ii].key = boolparamtable[ii].key;
272 BoolParamTable[ii].value = boolparamtable[ii].defaultValue;
273 BoolParamTable[ii].defaultVal = boolparamtable[ii].defaultValue;
274 BoolParamTable[ii].humanReadable = boolparamtable[ii].humanReadable;
275 BoolParamTable[ii].persistent = boolparamtable[ii].persistent;
276 BoolParamTable[ii].regName = boolparamtable[ii].regName;
279 for(int ij = 0; ij < NUM_OF_LPS; ij++) {
280 LongParamTable[ij].key = longparamtable[ij].key;
281 LongParamTable[ij].value = longparamtable[ij].defaultValue;
282 LongParamTable[ij].defaultVal = longparamtable[ij].defaultValue;
283 LongParamTable[ij].humanReadable = longparamtable[ij].humanReadable;
284 LongParamTable[ij].persistent = longparamtable[ij].persistent;
285 LongParamTable[ij].regName = longparamtable[ij].regName;
288 for(int ik = 0; ik < NUM_OF_SPS; ik++) {
289 StringParamTable[ik].key = stringparamtable[ik].key;
290 StringParamTable[ik].value = stringparamtable[ik].defaultValue;
291 StringParamTable[ik].defaultVal = stringparamtable[ik].defaultValue;
292 StringParamTable[ik].humanReadable = stringparamtable[ik].humanReadable;
293 StringParamTable[ik].persistent = stringparamtable[ik].persistent;
294 StringParamTable[ik].regName = stringparamtable[ik].regName;
297 /// \}
300 #endif