| 1 | #include "platform.h" |
|---|
| 2 | #include "keyboard.h" |
|---|
| 3 | #include "conf.h" |
|---|
| 4 | #include "histogram.h" |
|---|
| 5 | #include "font.h" |
|---|
| 6 | #include "camera.h" |
|---|
| 7 | #include "raw.h" |
|---|
| 8 | #include "gui_draw.h" |
|---|
| 9 | #include "gui_osd.h" |
|---|
| 10 | #include "gui_grid.h" |
|---|
| 11 | #include "core.h" |
|---|
| 12 | #include "stdlib.h" |
|---|
| 13 | #include "script.h" |
|---|
| 14 | |
|---|
| 15 | //------------------------------------------------------------------- |
|---|
| 16 | #define CONF_FILE "A/CHDK/CCHDK.CFG" |
|---|
| 17 | #define CONF_MAGICK_VALUE (0x33204741) |
|---|
| 18 | |
|---|
| 19 | #define CONF_INFO(id, param, type, def, func) { id, sizeof( param ), ¶m , type, {def}, func } |
|---|
| 20 | #define CONF_DEF_PTR 1 |
|---|
| 21 | #define CONF_DEF_VALUE 2 |
|---|
| 22 | |
|---|
| 23 | //------------------------------------------------------------------- |
|---|
| 24 | typedef struct { |
|---|
| 25 | unsigned short id; |
|---|
| 26 | unsigned short size; |
|---|
| 27 | void *var; |
|---|
| 28 | int type; |
|---|
| 29 | union { |
|---|
| 30 | void *ptr; |
|---|
| 31 | int i; |
|---|
| 32 | color cl; |
|---|
| 33 | }; |
|---|
| 34 | void (*func)(); |
|---|
| 35 | } ConfInfo; |
|---|
| 36 | |
|---|
| 37 | //------------------------------------------------------------------- |
|---|
| 38 | Conf conf; |
|---|
| 39 | |
|---|
| 40 | int state_shooting_progress = SHOOTING_PROGRESS_NONE; |
|---|
| 41 | int state_save_raw_nth_only; |
|---|
| 42 | int state_expos_recalculated; |
|---|
| 43 | int state_expos_under; |
|---|
| 44 | int state_expos_over; |
|---|
| 45 | int auto_started; |
|---|
| 46 | int shot_histogram_enabled; |
|---|
| 47 | |
|---|
| 48 | int state_debug1; |
|---|
| 49 | int debug_propcase_show; |
|---|
| 50 | int debug_propcase_page; |
|---|
| 51 | int debug_vals_show; |
|---|
| 52 | int debug_pardata_show; |
|---|
| 53 | |
|---|
| 54 | // reyalp: putting these in conf, since the conf values are lookups for them |
|---|
| 55 | // prefixes and extentions available for raw images (index with conf.raw_prefix etc) |
|---|
| 56 | const char* img_prefixes[NUM_IMG_PREFIXES]={ "IMG_", "CRW_", "SND_" /*, "AUT_", "ETC_","SDR_", "MVI_", "MRK_"*/}; |
|---|
| 57 | const char* img_exts[NUM_IMG_EXTS]={ ".JPG", ".CRW", ".CR2", ".THM", ".WAV"/*, ".AVI", ".MRK"*/}; |
|---|
| 58 | // ugh |
|---|
| 59 | const char *video_bitrate_strings[VIDEO_BITRATE_STEPS]={ "0.25x", "0.5x","0.75x", "1x", "1.25x", "1.5x", "1.75x", "2x", "2.5x", "3x"}; |
|---|
| 60 | |
|---|
| 61 | //------------------------------------------------------------------- |
|---|
| 62 | static int def_ubasic_vars[SCRIPT_NUM_PARAMS] = {0}; |
|---|
| 63 | static int def_batt_volts_max, def_batt_volts_min; |
|---|
| 64 | static OSD_pos def_histo_pos, def_dof_pos, def_batt_icon_pos, def_space_icon_pos, def_space_hor_pos, def_space_ver_pos, def_batt_txt_pos, def_space_txt_pos, |
|---|
| 65 | def_mode_state_pos, def_mode_raw_pos, def_mode_video_pos, def_mode_ev_pos, def_values_pos, def_clock_pos, def_ev_video_pos, def_temp_pos; |
|---|
| 66 | static int def_user_menu_vars[USER_MENU_ITEMS] = {0}; |
|---|
| 67 | |
|---|
| 68 | static void conf_change_script_file(); |
|---|
| 69 | static void conf_change_histo_mode(); |
|---|
| 70 | static void conf_change_histo_layout(); |
|---|
| 71 | static void conf_change_font_cp(); |
|---|
| 72 | static void conf_change_menu_rbf_file(); |
|---|
| 73 | static void conf_change_menu_symbol_rbf_file(); |
|---|
| 74 | static void conf_change_alt_mode_button(); |
|---|
| 75 | static void conf_change_grid_file(); |
|---|
| 76 | static void conf_change_video_bitrate(); |
|---|
| 77 | |
|---|
| 78 | void ubasic_camera_set_raw(int mode) |
|---|
| 79 | { |
|---|
| 80 | conf.save_raw = mode; |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | void ubasic_camera_set_nr(int mode) |
|---|
| 84 | { |
|---|
| 85 | // "Auto", "Off", "On" |
|---|
| 86 | conf.raw_nr = mode; |
|---|
| 87 | } |
|---|
| 88 | int ubasic_camera_script_autostart() |
|---|
| 89 | { |
|---|
| 90 | // 1 = Autostarted |
|---|
| 91 | return auto_started; |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | void ubasic_camera_set_script_autostart(int state) |
|---|
| 95 | { |
|---|
| 96 | // 1 = Autostarted |
|---|
| 97 | auto_started = state; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | int ubasic_camera_get_nr() |
|---|
| 101 | { |
|---|
| 102 | // "Auto", "Off", "On" |
|---|
| 103 | return conf.raw_nr; |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | void clear_values() |
|---|
| 108 | { |
|---|
| 109 | if (conf.clear_override) |
|---|
| 110 | { |
|---|
| 111 | conf.av_override_value=0; |
|---|
| 112 | conf.tv_override_koef=0; |
|---|
| 113 | conf.subj_dist_override_koef=0; |
|---|
| 114 | conf.iso_override_koef=0; |
|---|
| 115 | conf.nd_filter_state=0; |
|---|
| 116 | } |
|---|
| 117 | if (conf.clear_zoom_override) |
|---|
| 118 | { |
|---|
| 119 | conf.zoom_override = 0; |
|---|
| 120 | } |
|---|
| 121 | if (conf.clear_bracket) |
|---|
| 122 | { |
|---|
| 123 | conf.av_bracket_value=0; |
|---|
| 124 | conf.tv_bracket_value=0; |
|---|
| 125 | conf.iso_bracket_koef=0; |
|---|
| 126 | conf.subj_dist_bracket_koef=0; |
|---|
| 127 | } |
|---|
| 128 | if (conf.clear_video) |
|---|
| 129 | { |
|---|
| 130 | conf.video_mode = 0; |
|---|
| 131 | conf.video_quality = VIDEO_DEFAULT_QUALITY; |
|---|
| 132 | conf.video_bitrate = VIDEO_DEFAULT_BITRATE; |
|---|
| 133 | shooting_video_bitrate_change(conf.video_bitrate); |
|---|
| 134 | } |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | static const ConfInfo conf_info[] = { |
|---|
| 138 | /* !!! Do NOT change ID for items defined already! Append a new one at the end! !!! */ |
|---|
| 139 | CONF_INFO( 1, conf.show_osd, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 140 | CONF_INFO( 2, conf.save_raw, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 141 | CONF_INFO( 3, conf.script_shoot_delay, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 142 | CONF_INFO( 4, conf.show_histo, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 143 | CONF_INFO( 5, conf.ubasic_vars, CONF_DEF_PTR, ptr:&def_ubasic_vars, NULL), |
|---|
| 144 | CONF_INFO( 6, conf.script_param_set, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 145 | CONF_INFO( 7, conf.show_dof, CONF_DEF_VALUE, i:DOF_DONT_SHOW, NULL), |
|---|
| 146 | CONF_INFO( 8, conf.batt_volts_max, CONF_DEF_PTR, ptr:&def_batt_volts_max, NULL), |
|---|
| 147 | CONF_INFO( 9, conf.batt_volts_min, CONF_DEF_PTR, ptr:&def_batt_volts_min, NULL), |
|---|
| 148 | CONF_INFO( 10, conf.batt_step_25, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 149 | CONF_INFO( 11, conf.batt_perc_show, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 150 | CONF_INFO( 12, conf.batt_volts_show, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 151 | CONF_INFO( 13, conf.batt_icon_show, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 152 | CONF_INFO( 14, conf.show_state, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 153 | CONF_INFO( 15, conf.show_values, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 154 | CONF_INFO( 16, conf.show_overexp, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 155 | CONF_INFO( 17, conf.histo_mode, CONF_DEF_VALUE, i:HISTO_MODE_LINEAR, conf_change_histo_mode), |
|---|
| 156 | CONF_INFO( 18, conf.histo_auto_ajust, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 157 | CONF_INFO( 19, conf.histo_ignore_boundary, CONF_DEF_VALUE, i:4, NULL), |
|---|
| 158 | CONF_INFO( 20, conf.histo_layout, CONF_DEF_VALUE, i:OSD_HISTO_LAYOUT_A, conf_change_histo_layout), |
|---|
| 159 | CONF_INFO( 21, conf.histo_pos, CONF_DEF_PTR, ptr:&def_histo_pos, NULL), |
|---|
| 160 | CONF_INFO( 22, conf.dof_pos, CONF_DEF_PTR, ptr:&def_dof_pos, NULL), |
|---|
| 161 | CONF_INFO( 23, conf.batt_icon_pos, CONF_DEF_PTR, ptr:&def_batt_icon_pos, NULL), |
|---|
| 162 | CONF_INFO( 24, conf.batt_txt_pos, CONF_DEF_PTR, ptr:&def_batt_txt_pos , NULL), |
|---|
| 163 | CONF_INFO( 25, conf.mode_state_pos, CONF_DEF_PTR, ptr:&def_mode_state_pos , NULL), |
|---|
| 164 | CONF_INFO( 26, conf.values_pos, CONF_DEF_PTR, ptr:&def_values_pos , NULL), |
|---|
| 165 | CONF_INFO( 27, conf.histo_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_WHITE), NULL), |
|---|
| 166 | CONF_INFO( 28, conf.osd_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL), |
|---|
| 167 | CONF_INFO( 29, conf.batt_icon_color, CONF_DEF_VALUE, cl:COLOR_WHITE, NULL), |
|---|
| 168 | CONF_INFO( 30, conf.menu_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL), |
|---|
| 169 | CONF_INFO( 31, conf.reader_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_GREY, COLOR_WHITE), NULL), |
|---|
| 170 | CONF_INFO( 32, conf.ricoh_ca1_mode, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 171 | CONF_INFO( 33, conf.flashlight, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 172 | // CONF_INFO( 34, conf.ns_enable_memdump, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 173 | CONF_INFO( 34, conf.debug_shortcut_action, CONF_DEF_VALUE, i:0, NULL), // backwards compatible |
|---|
| 174 | CONF_INFO( 35, conf.raw_in_dir, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 175 | CONF_INFO( 36, conf.raw_prefix, CONF_DEF_VALUE, i:RAW_PREFIX_CRW, NULL), |
|---|
| 176 | CONF_INFO( 37, conf.raw_ext, CONF_DEF_VALUE, i:RAW_EXT_CRW, NULL), |
|---|
| 177 | CONF_INFO( 38, conf.reader_file, CONF_DEF_PTR, ptr:"A/README.TXT", conf_change_script_file), |
|---|
| 178 | CONF_INFO( 39, conf.reader_pos, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 179 | CONF_INFO( 40, conf.sokoban_level, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 180 | CONF_INFO( 41, conf.show_clock, CONF_DEF_VALUE, i:2, NULL), |
|---|
| 181 | CONF_INFO( 42, conf.clock_pos, CONF_DEF_PTR, ptr:&def_clock_pos , NULL), |
|---|
| 182 | CONF_INFO( 43, conf.reader_autoscroll, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 183 | CONF_INFO( 44, conf.reader_autoscroll_delay,CONF_DEF_VALUE, i:5, NULL), |
|---|
| 184 | CONF_INFO( 45, conf.reader_rbf_file, CONF_DEF_PTR, ptr:"", NULL), |
|---|
| 185 | CONF_INFO( 46, conf.reader_codepage, CONF_DEF_VALUE, i:FONT_CP_WIN, NULL), |
|---|
| 186 | CONF_INFO( 47, conf.splash_show, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 187 | CONF_INFO( 48, conf.histo_color2, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_RED, COLOR_WHITE), NULL), |
|---|
| 188 | CONF_INFO( 49, conf.zebra_draw, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 189 | CONF_INFO( 50, conf.zebra_mode, CONF_DEF_VALUE, i:ZEBRA_MODE_BLINKED_2, NULL), |
|---|
| 190 | CONF_INFO( 51, conf.zebra_restore_screen, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 191 | CONF_INFO( 52, conf.zebra_restore_osd, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 192 | CONF_INFO( 53, conf.zebra_over, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 193 | CONF_INFO( 54, conf.zebra_under, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 194 | CONF_INFO( 55, conf.zebra_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_RED, COLOR_RED), NULL), |
|---|
| 195 | CONF_INFO( 56, conf.zebra_draw_osd, CONF_DEF_VALUE, i:ZEBRA_DRAW_HISTO, NULL), |
|---|
| 196 | CONF_INFO( 57, conf.user_menu_as_root, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 197 | CONF_INFO( 58, conf.zoom_value, CONF_DEF_VALUE, i:ZOOM_SHOW_X, NULL), |
|---|
| 198 | CONF_INFO( 59, conf.use_zoom_mf, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 199 | CONF_INFO( 60, conf.raw_save_first_only, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 200 | CONF_INFO( 61, conf.reader_wrap_by_words, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 201 | CONF_INFO( 62, conf.menu_symbol_rbf_file, CONF_DEF_PTR, ptr:"A/CHDK/SYMBOLS/icon_10.rbf", conf_change_menu_symbol_rbf_file), |
|---|
| 202 | CONF_INFO( 63, conf.alt_mode_button, CONF_DEF_VALUE, i:KEY_PRINT, conf_change_alt_mode_button), |
|---|
| 203 | CONF_INFO( 64, conf.lang_file, CONF_DEF_PTR, ptr:"", NULL), |
|---|
| 204 | CONF_INFO( 65, conf.font_cp, CONF_DEF_VALUE, i:FONT_CP_WIN_1251, conf_change_font_cp), |
|---|
| 205 | CONF_INFO( 66, conf.menu_rbf_file, CONF_DEF_PTR, ptr:"", conf_change_menu_rbf_file), |
|---|
| 206 | CONF_INFO( 67, conf.alt_prevent_shutdown, CONF_DEF_VALUE, i:ALT_PREVENT_SHUTDOWN_ALT, NULL), |
|---|
| 207 | CONF_INFO( 68, conf.show_grid_lines, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 208 | CONF_INFO( 69, conf.grid_lines_file, CONF_DEF_PTR, ptr:"", conf_change_grid_file), |
|---|
| 209 | CONF_INFO( 70, conf.raw_nr, CONF_DEF_VALUE, i:NOISE_REDUCTION_AUTO_CANON, NULL), |
|---|
| 210 | CONF_INFO( 71, conf.grid_force_color, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 211 | CONF_INFO( 72, conf.grid_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL), |
|---|
| 212 | |
|---|
| 213 | CONF_INFO( 80, conf.dof_subj_dist_as_near_limit,CONF_DEF_VALUE, i:0, NULL), |
|---|
| 214 | CONF_INFO( 81, conf.dof_use_exif_subj_dist, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 215 | CONF_INFO( 82, conf.dof_subj_dist_in_misc, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 216 | CONF_INFO( 83, conf.dof_near_limit_in_misc, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 217 | CONF_INFO( 84, conf.dof_far_limit_in_misc, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 218 | CONF_INFO( 85, conf.dof_hyperfocal_in_misc, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 219 | CONF_INFO( 86, conf.dof_depth_in_misc, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 220 | |
|---|
| 221 | CONF_INFO( 87, conf.values_show_in_review, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 222 | CONF_INFO( 88, conf.values_show_zoom, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 223 | CONF_INFO( 89, conf.values_show_real_aperture,CONF_DEF_VALUE, i:0, NULL), |
|---|
| 224 | CONF_INFO( 90, conf.values_show_real_iso, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 225 | CONF_INFO( 91, conf.values_show_market_iso, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 226 | CONF_INFO( 92, conf.values_show_iso_only_in_autoiso_mode, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 227 | CONF_INFO( 93, conf.values_show_ev_seted, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 228 | CONF_INFO( 94, conf.values_show_ev_measured, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 229 | CONF_INFO( 95, conf.values_show_bv_measured, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 230 | CONF_INFO( 96, conf.values_show_bv_seted, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 231 | CONF_INFO( 97, conf.values_show_overexposure, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 232 | CONF_INFO( 98, conf.values_show_luminance, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 233 | |
|---|
| 234 | CONF_INFO( 99, conf.video_mode, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 235 | CONF_INFO(100, conf.video_quality, CONF_DEF_VALUE, i:VIDEO_DEFAULT_QUALITY,NULL), |
|---|
| 236 | CONF_INFO(101, conf.video_bitrate, CONF_DEF_VALUE, i:VIDEO_DEFAULT_BITRATE, conf_change_video_bitrate), |
|---|
| 237 | |
|---|
| 238 | CONF_INFO(102, conf.tv_override_value, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 239 | CONF_INFO(103, conf.tv_override_koef, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 240 | |
|---|
| 241 | CONF_INFO(104, conf.av_override_value, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 242 | CONF_INFO(105, conf.iso_override_value, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 243 | CONF_INFO(106, conf.iso_override_koef, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 244 | |
|---|
| 245 | CONF_INFO(107, conf.subj_dist_override_value,CONF_DEF_VALUE, i:0, NULL), |
|---|
| 246 | CONF_INFO(108, conf.subj_dist_override_koef, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 247 | |
|---|
| 248 | CONF_INFO(109, conf.tv_bracket_value, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 249 | CONF_INFO(110, conf.av_bracket_value, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 250 | CONF_INFO(111, conf.iso_bracket_value, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 251 | CONF_INFO(112, conf.iso_bracket_koef, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 252 | CONF_INFO(113, conf.subj_dist_bracket_value,CONF_DEF_VALUE, i:0, NULL), |
|---|
| 253 | CONF_INFO(114, conf.subj_dist_bracket_koef, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 254 | CONF_INFO(115, conf.bracket_type, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 255 | |
|---|
| 256 | CONF_INFO(116, conf.recalc_exposure, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 257 | CONF_INFO(117, conf.tv_exposure_order, CONF_DEF_VALUE, i:2, NULL), |
|---|
| 258 | CONF_INFO(118, conf.av_exposure_order, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 259 | CONF_INFO(119, conf.iso_exposure_order, CONF_DEF_VALUE, i:3, NULL), |
|---|
| 260 | |
|---|
| 261 | CONF_INFO(120, conf.script_startup, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 262 | CONF_INFO(121, conf.remote_enable, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 263 | |
|---|
| 264 | CONF_INFO(122, conf.values_show_canon_overexposure, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 265 | CONF_INFO(123, conf.clear_override, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 266 | |
|---|
| 267 | CONF_INFO(124, conf.show_osd_in_review, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 268 | |
|---|
| 269 | CONF_INFO(125, conf.dof_dist_from_lens, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 270 | |
|---|
| 271 | CONF_INFO(126, conf.clear_bracket, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 272 | CONF_INFO(127, conf.zebra_multichannel, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 273 | |
|---|
| 274 | CONF_INFO(128, conf.nd_filter_state, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 275 | CONF_INFO(129, conf.histo_show_ev_grid, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 276 | |
|---|
| 277 | CONF_INFO(130, conf.osd_color_warn, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_RED), NULL), |
|---|
| 278 | CONF_INFO(131, conf.space_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL), |
|---|
| 279 | CONF_INFO(132, conf.space_icon_show, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 280 | CONF_INFO(133, conf.space_icon_pos, CONF_DEF_PTR, ptr:&def_space_icon_pos, NULL), |
|---|
| 281 | CONF_INFO(134, conf.space_perc_show, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 282 | CONF_INFO(135, conf.space_mb_show, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 283 | CONF_INFO(136, conf.space_txt_pos, CONF_DEF_PTR, ptr:&def_space_txt_pos , NULL), |
|---|
| 284 | CONF_INFO(137, conf.show_remaining_raw, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 285 | CONF_INFO(138, conf.mode_raw_pos, CONF_DEF_PTR, ptr:&def_mode_raw_pos , NULL), |
|---|
| 286 | CONF_INFO(139, conf.show_raw_state, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 287 | |
|---|
| 288 | CONF_INFO(140, conf.show_values_in_video, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 289 | CONF_INFO(141, conf.tv_enum_type, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 290 | |
|---|
| 291 | CONF_INFO(142, conf.user_menu_enable, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 292 | CONF_INFO(143, conf.user_menu_vars, CONF_DEF_PTR, ptr:&def_user_menu_vars, NULL), |
|---|
| 293 | CONF_INFO(144, conf.zoom_scale, CONF_DEF_VALUE, i:100, NULL), |
|---|
| 294 | CONF_INFO(145, conf.space_bar_show, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 295 | CONF_INFO(146, conf.space_bar_size, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 296 | CONF_INFO(147, conf.space_ver_pos, CONF_DEF_PTR, ptr:&def_space_ver_pos, NULL), |
|---|
| 297 | CONF_INFO(148, conf.space_hor_pos, CONF_DEF_PTR, ptr:&def_space_hor_pos, NULL), |
|---|
| 298 | CONF_INFO(149, conf.space_bar_width, CONF_DEF_VALUE, i:2, NULL), |
|---|
| 299 | CONF_INFO(150, conf.space_perc_warn, CONF_DEF_VALUE, i:10, NULL), |
|---|
| 300 | CONF_INFO(151, conf.space_mb_warn, CONF_DEF_VALUE, i:20, NULL), |
|---|
| 301 | CONF_INFO(152, conf.space_warn_type, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 302 | CONF_INFO(153, conf.remaining_raw_treshold, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 303 | CONF_INFO(154, conf.unlock_optical_zoom_for_video, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 304 | CONF_INFO(155, conf.clock_format, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 305 | CONF_INFO(156, conf.clock_indicator, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 306 | CONF_INFO(157, conf.clock_halfpress, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 307 | |
|---|
| 308 | CONF_INFO(158, conf.autoiso_enable, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 309 | CONF_INFO(159, conf.autoiso_shutter, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 310 | CONF_INFO(160, conf.autoiso_user_factor, CONF_DEF_VALUE, i:5, NULL), |
|---|
| 311 | CONF_INFO(161, conf.autoiso_is_factor, CONF_DEF_VALUE, i:2, NULL), |
|---|
| 312 | CONF_INFO(162, conf.autoiso_max_iso_hi, CONF_DEF_VALUE, i:55, NULL), |
|---|
| 313 | CONF_INFO(163, conf.autoiso_max_iso_auto, CONF_DEF_VALUE, i:35, NULL), |
|---|
| 314 | CONF_INFO(164, conf.autoiso_min_iso, CONF_DEF_VALUE, i:5, NULL), |
|---|
| 315 | |
|---|
| 316 | CONF_INFO(165, conf.menu_title_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_WHITE, COLOR_BLACK), NULL), |
|---|
| 317 | CONF_INFO(166, conf.menu_cursor_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_SELECTED_BG, COLOR_SELECTED_FG), NULL), |
|---|
| 318 | CONF_INFO(167, conf.menu_center, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 319 | CONF_INFO(168, conf.mute_on_zoom, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 320 | CONF_INFO(169, conf.bad_pixel_removal, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 321 | CONF_INFO(170, conf.video_af_key, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 322 | CONF_INFO(171, conf.osd_color_override, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_RED), NULL), |
|---|
| 323 | CONF_INFO(172, conf.override_disable, CONF_DEF_VALUE, i:2, NULL), |
|---|
| 324 | CONF_INFO(173, conf.override_disable_all, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 325 | CONF_INFO(174, conf.hide_osd, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 326 | CONF_INFO(175, conf.save_raw_in_video, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 327 | CONF_INFO(176, conf.show_movie_time, CONF_DEF_VALUE, i:3, NULL), |
|---|
| 328 | CONF_INFO(177, conf.show_movie_refresh, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 329 | CONF_INFO(178, conf.mode_video_pos, CONF_DEF_PTR, ptr:&def_mode_video_pos , NULL), |
|---|
| 330 | CONF_INFO(179, conf.clear_video, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 331 | CONF_INFO(180, conf.fast_ev, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 332 | CONF_INFO(181, conf.fast_ev_step, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 333 | CONF_INFO(182, conf.mode_ev_pos, CONF_DEF_PTR, ptr:&def_mode_ev_pos , NULL), |
|---|
| 334 | CONF_INFO(183, conf.menu_symbol_enable, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 335 | CONF_INFO(184, conf.menu_symbol_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL), |
|---|
| 336 | CONF_INFO(185, conf.curve_file, CONF_DEF_PTR, ptr:"", NULL), |
|---|
| 337 | CONF_INFO(186, conf.curve_enable, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 338 | CONF_INFO(187, conf.edge_overlay_enable, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 339 | CONF_INFO(188, conf.edge_overlay_thresh, CONF_DEF_VALUE, i:40, NULL), |
|---|
| 340 | CONF_INFO(189, conf.edge_overlay_color, CONF_DEF_VALUE, cl:0x66, NULL), |
|---|
| 341 | CONF_INFO(190, conf.synch_enable, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 342 | CONF_INFO(191, conf.synch_delay_enable, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 343 | CONF_INFO(192, conf.synch_delay_value, CONF_DEF_VALUE, i:100, NULL), |
|---|
| 344 | CONF_INFO(193, conf.synch_delay_coarse_value, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 345 | CONF_INFO(194, conf.script_file, CONF_DEF_PTR, ptr:"", conf_change_script_file), |
|---|
| 346 | CONF_INFO(195, conf.mem_view_addr_init, CONF_DEF_VALUE, i:0x1000, NULL), |
|---|
| 347 | CONF_INFO(196, conf.save_raw_in_sports, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 348 | CONF_INFO(197, conf.save_raw_in_burst, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 349 | CONF_INFO(198, conf.save_raw_in_ev_bracketing, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 350 | CONF_INFO(199, conf.save_raw_in_timer, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 351 | CONF_INFO(200, conf.raw_exceptions_warn, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 352 | CONF_INFO(201, conf.menu_select_first_entry, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 353 | CONF_INFO(202, conf.fast_movie_control, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 354 | CONF_INFO(203, conf.show_temp, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 355 | CONF_INFO(204, conf.temp_pos, CONF_DEF_PTR, ptr:&def_temp_pos , NULL), |
|---|
| 356 | CONF_INFO(205, conf.fast_movie_quality_control, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 357 | CONF_INFO(206, conf.remote_zoom_enable, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 358 | CONF_INFO(207, conf.zoom_timeout, CONF_DEF_VALUE, i:5, NULL), |
|---|
| 359 | CONF_INFO(208, conf.start_sound, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 360 | CONF_INFO(209, conf.sub_batch_prefix, CONF_DEF_VALUE, i:2, NULL), // SND_ |
|---|
| 361 | CONF_INFO(210, conf.sub_batch_ext, CONF_DEF_VALUE, i:1, NULL), // .CRW |
|---|
| 362 | CONF_INFO(211, conf.sub_in_dark_value, CONF_DEF_VALUE, i:30, NULL), |
|---|
| 363 | CONF_INFO(212, conf.sub_out_dark_value, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 364 | CONF_INFO(213, conf.debug_display, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 365 | CONF_INFO(214, conf.script_param_save, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 366 | CONF_INFO(215, conf.ev_video_pos, CONF_DEF_PTR, ptr:&def_ev_video_pos, NULL), |
|---|
| 367 | CONF_INFO(216, conf.zoom_override_value, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 368 | CONF_INFO(217, conf.zoom_override, CONF_DEF_VALUE, i:0, NULL), |
|---|
| 369 | CONF_INFO(218, conf.clear_zoom_override, CONF_DEF_VALUE, i:1, NULL), |
|---|
| 370 | |
|---|
| 371 | }; |
|---|
| 372 | #define CONF_NUM (sizeof(conf_info)/sizeof(conf_info[0])) |
|---|
| 373 | |
|---|
| 374 | //------------------------------------------------------------------- |
|---|
| 375 | static void conf_change_histo_mode() { |
|---|
| 376 | histogram_set_mode(conf.histo_mode); |
|---|
| 377 | } |
|---|
| 378 | |
|---|
| 379 | static void conf_change_histo_layout() { |
|---|
| 380 | if (conf.histo_layout==OSD_HISTO_LAYOUT_Y || conf.histo_layout==OSD_HISTO_LAYOUT_Y_argb) { |
|---|
| 381 | histogram_set_main(HISTO_Y); |
|---|
| 382 | } else { |
|---|
| 383 | histogram_set_main(HISTO_RGB); |
|---|
| 384 | } |
|---|
| 385 | } |
|---|
| 386 | |
|---|
| 387 | static void conf_change_font_cp() { |
|---|
| 388 | font_init(); |
|---|
| 389 | font_set(conf.font_cp); |
|---|
| 390 | } |
|---|
| 391 | |
|---|
| 392 | static void conf_change_script_file() { |
|---|
| 393 | script_load(conf.script_file, 2); |
|---|
| 394 | } |
|---|
| 395 | |
|---|
| 396 | static void conf_change_menu_rbf_file() { |
|---|
| 397 | if (!rbf_load(conf.menu_rbf_file)) |
|---|
| 398 | rbf_load_from_8x16(current_font); |
|---|
| 399 | rbf_set_codepage(FONT_CP_WIN); |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | static void conf_change_menu_symbol_rbf_file() { |
|---|
| 403 | rbf_load_symbol(conf.menu_symbol_rbf_file); //AKA |
|---|
| 404 | } |
|---|
| 405 | |
|---|
| 406 | static void conf_change_alt_mode_button() { |
|---|
| 407 | #if CAM_ADJUSTABLE_ALT_BUTTON |
|---|
| 408 | kbd_set_alt_mode_key_mask(conf.alt_mode_button); |
|---|
| 409 | #else |
|---|
| 410 | conf.alt_mode_button = KEY_PRINT; |
|---|
| 411 | #endif |
|---|
| 412 | } |
|---|
| 413 | |
|---|
| 414 | static void conf_change_grid_file() { |
|---|
| 415 | grid_lines_load(conf.grid_lines_file); |
|---|
| 416 | } |
|---|
| 417 | |
|---|
| 418 | static void conf_change_video_bitrate() { |
|---|
| 419 | shooting_video_bitrate_change(conf.video_bitrate); |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | //------------------------------------------------------------------- |
|---|
| 423 | static void conf_init_defaults() { |
|---|
| 424 | // init some defaults values |
|---|
| 425 | def_batt_volts_max = get_vbatt_max(); |
|---|
| 426 | def_batt_volts_min = get_vbatt_min(); |
|---|
| 427 | def_histo_pos.x = 45; |
|---|
| 428 | def_histo_pos.y = vid_get_bitmap_screen_height()-HISTO_HEIGHT-40; |
|---|
| 429 | def_dof_pos.x = 90; |
|---|
| 430 | def_dof_pos.y = 45; |
|---|
| 431 | def_batt_icon_pos.x = 178; |
|---|
| 432 | def_batt_icon_pos.y = 0; |
|---|
| 433 | def_batt_txt_pos.x=178; |
|---|
| 434 | def_batt_txt_pos.y=1*FONT_HEIGHT; |
|---|
| 435 | def_space_icon_pos.x = vid_get_bitmap_screen_width()-100; |
|---|
| 436 | def_space_icon_pos.y = 0; |
|---|
| 437 | def_space_ver_pos.x = vid_get_bitmap_screen_width()-7; |
|---|
| 438 | def_space_ver_pos.y = 0; |
|---|
| 439 | def_space_hor_pos.x = 0; |
|---|
| 440 | def_space_hor_pos.y = vid_get_bitmap_screen_height()-7; |
|---|
| 441 | def_space_txt_pos.x=128; |
|---|
| 442 | def_space_txt_pos.y=0; |
|---|
| 443 | def_mode_state_pos.x=35; |
|---|
| 444 | def_mode_state_pos.y=0; |
|---|
| 445 | def_mode_raw_pos.x=vid_get_bitmap_screen_width()-7*FONT_WIDTH-2; |
|---|
| 446 | def_mode_raw_pos.y=vid_get_bitmap_screen_height()-3*FONT_HEIGHT-2; |
|---|
| 447 | def_mode_video_pos.x=vid_get_bitmap_screen_width()-25*FONT_WIDTH-2; |
|---|
| 448 | def_mode_video_pos.y=vid_get_bitmap_screen_height()-6*FONT_HEIGHT-2; |
|---|
| 449 | def_mode_ev_pos.x=vid_get_bitmap_screen_width()-40*FONT_WIDTH-2; |
|---|
| 450 | def_mode_ev_pos.y=vid_get_bitmap_screen_height()-8*FONT_HEIGHT-2; |
|---|
| 451 | def_values_pos.x=vid_get_bitmap_screen_width()-9*FONT_WIDTH; |
|---|
| 452 | def_values_pos.y=30; |
|---|
| 453 | def_clock_pos.x=vid_get_bitmap_screen_width()-5*FONT_WIDTH-2; |
|---|
| 454 | def_clock_pos.y=0; |
|---|
| 455 | def_temp_pos.x=vid_get_bitmap_screen_width()-9*FONT_WIDTH-2; |
|---|
| 456 | def_temp_pos.y=1*FONT_HEIGHT; |
|---|
| 457 | def_ev_video_pos.x=18; |
|---|
| 458 | def_ev_video_pos.y=80; |
|---|
| 459 | |
|---|
| 460 | } |
|---|
| 461 | |
|---|
| 462 | //------------------------------------------------------------------- |
|---|
| 463 | void conf_load_defaults() { |
|---|
| 464 | register int i; |
|---|
| 465 | |
|---|
| 466 | for (i=0; i<CONF_NUM; ++i) { |
|---|
| 467 | switch (conf_info[i].type) { |
|---|
| 468 | case CONF_DEF_VALUE: |
|---|
| 469 | memcpy(conf_info[i].var, &(conf_info[i].i), conf_info[i].size); |
|---|
| 470 | break; |
|---|
| 471 | case CONF_DEF_PTR: |
|---|
| 472 | memcpy(conf_info[i].var, conf_info[i].ptr, conf_info[i].size); |
|---|
| 473 | break; |
|---|
| 474 | } |
|---|
| 475 | if (conf_info[i].func) { |
|---|
| 476 | conf_info[i].func(); |
|---|
| 477 | } |
|---|
| 478 | } |
|---|
| 479 | } |
|---|
| 480 | |
|---|
| 481 | //------------------------------------------------------------------- |
|---|
| 482 | void conf_save() { |
|---|
| 483 | static const long t=CONF_MAGICK_VALUE; |
|---|
| 484 | register int i; |
|---|
| 485 | int fd; |
|---|
| 486 | char *buf=umalloc(sizeof(t)+CONF_NUM*(sizeof(conf_info[0].id)+sizeof(conf_info[0].size))+sizeof(conf)); |
|---|
| 487 | char *p=buf; |
|---|
| 488 | |
|---|
| 489 | fd = open(CONF_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0777); |
|---|
| 490 | if (fd>=0){ |
|---|
| 491 | memcpy(p, &t, sizeof(t)); |
|---|
| 492 | p+=sizeof(t); |
|---|
| 493 | for (i=0; i<CONF_NUM; ++i) { |
|---|
| 494 | memcpy(p, &(conf_info[i].id), sizeof(conf_info[i].id)); |
|---|
| 495 | p+=sizeof(conf_info[i].id); |
|---|
| 496 | memcpy(p, &(conf_info[i].size), sizeof(conf_info[i].size)); |
|---|
| 497 | p+=sizeof(conf_info[i].size); |
|---|
| 498 | memcpy(p, conf_info[i].var, conf_info[i].size); |
|---|
| 499 | p+=conf_info[i].size; |
|---|
| 500 | } |
|---|
| 501 | |
|---|
| 502 | write(fd, buf, p-buf); |
|---|
| 503 | close(fd); |
|---|
| 504 | } |
|---|
| 505 | ufree(buf); |
|---|
| 506 | } |
|---|
| 507 | |
|---|
| 508 | //------------------------------------------------------------------- |
|---|
| 509 | void conf_restore() { |
|---|
| 510 | int fd, rcnt, i; |
|---|
| 511 | long t; |
|---|
| 512 | unsigned short id, size; |
|---|
| 513 | void *ptr; |
|---|
| 514 | |
|---|
| 515 | conf_init_defaults(); |
|---|
| 516 | |
|---|
| 517 | conf_load_defaults(); |
|---|
| 518 | |
|---|
| 519 | fd = open(CONF_FILE, O_RDONLY, 0777); |
|---|
| 520 | if (fd>=0){ |
|---|
| 521 | // read magick value |
|---|
| 522 | rcnt = read(fd, &t, sizeof(t)); |
|---|
| 523 | if (rcnt==sizeof(t) && t==CONF_MAGICK_VALUE) { |
|---|
| 524 | while (1) { |
|---|
| 525 | rcnt = read(fd, &id, sizeof(id)); |
|---|
| 526 | if (rcnt!=sizeof(id)) break; |
|---|
| 527 | |
|---|
| 528 | rcnt = read(fd, &size, sizeof(size)); |
|---|
| 529 | if (rcnt!=sizeof(size)) break; |
|---|
| 530 | |
|---|
| 531 | for (i=0; i<CONF_NUM; ++i) { |
|---|
| 532 | if (conf_info[i].id==id && conf_info[i].size==size) { |
|---|
| 533 | ptr=umalloc(size); |
|---|
| 534 | if (ptr) { |
|---|
| 535 | rcnt = read(fd, ptr, size); |
|---|
| 536 | if (rcnt == size) { |
|---|
| 537 | memcpy(conf_info[i].var, ptr, size); |
|---|
| 538 | if (conf_info[i].func) { |
|---|
| 539 | conf_info[i].func(); |
|---|
| 540 | } |
|---|
| 541 | } |
|---|
| 542 | ufree(ptr); |
|---|
| 543 | } |
|---|
| 544 | break; |
|---|
| 545 | } |
|---|
| 546 | } |
|---|
| 547 | if (i == CONF_NUM) { // unknown id, just skip data |
|---|
| 548 | lseek(fd, size, SEEK_CUR); |
|---|
| 549 | } |
|---|
| 550 | } |
|---|
| 551 | } |
|---|
| 552 | close(fd); |
|---|
| 553 | } |
|---|
| 554 | // clear any "clear on restart" values |
|---|
| 555 | clear_values(); |
|---|
| 556 | } |
|---|
| 557 | |
|---|
| 558 | //------------------------------------------------------------------- |
|---|