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