- Timestamp:
- 01/16/12 08:22:51 (16 months ago)
- Location:
- trunk
- Files:
-
- 4 deleted
- 68 edited
- 5 copied
-
. (modified) (1 prop)
-
CHDK/LANG/english.lng (modified) (1 diff)
-
CHDK/russian.key (copied) (copied from branches/reyalp-flt/CHDK/russian.key)
-
Makefile (modified) (1 diff)
-
core/Makefile (modified) (4 diffs)
-
core/conf.c (modified) (26 diffs)
-
core/curves.c (modified) (11 diffs)
-
core/curves.h (modified) (1 diff)
-
core/dng.c (modified) (3 diffs)
-
core/dng.h (modified) (2 diffs)
-
core/edgeoverlay.c (modified) (27 diffs)
-
core/edgeoverlay.h (modified) (2 diffs)
-
core/gui.c (modified) (34 diffs)
-
core/gui_4wins.c (modified) (5 diffs)
-
core/gui_4wins.h (deleted)
-
core/gui_batt.c (modified) (1 diff)
-
core/gui_calendar.c (modified) (2 diffs)
-
core/gui_debug.c (modified) (5 diffs)
-
core/gui_draw.c (modified) (3 diffs)
-
core/gui_fselect.c (modified) (13 diffs)
-
core/gui_fselect.h (modified) (1 diff)
-
core/gui_games.c (copied) (copied from branches/reyalp-flt/core/gui_games.c)
-
core/gui_grid.c (modified) (5 diffs)
-
core/gui_grid.h (modified) (1 diff)
-
core/gui_lang.h (modified) (1 diff)
-
core/gui_mastermind.c (modified) (5 diffs)
-
core/gui_mastermind.h (deleted)
-
core/gui_menu.c (modified) (18 diffs)
-
core/gui_menu.h (modified) (2 diffs)
-
core/gui_mpopup.c (modified) (7 diffs)
-
core/gui_mpopup.h (modified) (1 diff)
-
core/gui_osd.c (modified) (10 diffs)
-
core/gui_osd.h (modified) (1 diff)
-
core/gui_palette.c (modified) (3 diffs)
-
core/gui_palette.h (modified) (1 diff)
-
core/gui_read.c (modified) (22 diffs)
-
core/gui_reversi.c (modified) (1 diff)
-
core/gui_reversi.h (deleted)
-
core/gui_snake.c (modified) (1 diff)
-
core/gui_sokoban.c (modified) (11 diffs)
-
core/gui_sokoban.h (deleted)
-
core/gui_tbox.c (copied) (copied from branches/reyalp-flt/core/gui_tbox.c)
-
core/gui_tetris.c (modified) (2 diffs)
-
core/luascript.c (modified) (4 diffs)
-
core/main.c (modified) (3 diffs)
-
core/module_exportlist.c (modified) (11 diffs)
-
core/module_load.c (modified) (10 diffs)
-
core/module_load.h (modified) (4 diffs)
-
core/modules.c (modified) (12 diffs)
-
core/modules.h (modified) (3 diffs)
-
core/modules/Makefile (modified) (5 diffs)
-
core/modules/module_inspector.c (modified) (4 diffs)
-
core/modules/module_menu.c (modified) (1 diff)
-
core/modules/simple_game.c (modified) (2 diffs)
-
core/modules/simple_module.c (modified) (1 diff)
-
core/motion_detector.c (modified) (7 diffs)
-
core/motion_detector.h (modified) (7 diffs)
-
core/raw.c (modified) (1 diff)
-
core/raw_merge.c (modified) (3 diffs)
-
core/raw_merge.h (modified) (1 diff)
-
core/script.c (modified) (4 diffs)
-
core/zebra.c (copied) (copied from branches/reyalp-flt/core/zebra.c)
-
core/zebra.h (copied) (copied from branches/reyalp-flt/core/zebra.h)
-
include/conf.h (modified) (8 diffs)
-
include/gui.h (modified) (2 diffs)
-
include/histogram.h (modified) (1 diff)
-
include/lang.h (modified) (1 diff)
-
include/platform.h (modified) (1 diff)
-
lib/font/rbf_font.c (modified) (6 diffs)
-
lib/lang/lang.c (modified) (2 diffs)
-
lib/ubasic/Makefile (modified) (1 diff)
-
lib/ubasic/ubasic.c (modified) (4 diffs)
-
platform/generic/wrappers.c (modified) (5 diffs)
-
tools/elf2flt/flt.h (modified) (1 diff)
-
tools/elf2flt/myio.c (modified) (5 diffs)
-
tools/elf2flt/stoplist.txt (modified) (1 diff)
-
tools/makeexport.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/reyalp-flt merged: 1527-1568
- Property svn:mergeinfo changed
-
trunk/CHDK/LANG/english.lng
r1568 r1569 587 587 473 "Options" 588 588 589 474 "Select keyboard profile" 590 475 "Load keyboard profile" 591 476 "More ->" 592 477 "Make dir" 593 478 "Rename" 594 479 "Enter name of directory:" 595 480 "Enter new name of file:" -
trunk/Makefile
r1505 r1569 123 123 zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)CHDK/SCRIPTS/EDITOR/* > $(DEVNULL) 124 124 zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)CHDK/syscurves.CVF > $(DEVNULL) 125 zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)CHDK/russian.key > $(DEVNULL) 125 126 zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)doc/changelog.txt > $(DEVNULL) 126 127 zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)doc/changelog.txt > $(DEVNULL) -
trunk/core/Makefile
r1568 r1569 18 18 19 19 OPT_OBJS= 20 ifdef OPT_GAMES 21 CFLAGS+=-DOPT_GAMES 22 endif 20 23 ifdef OPT_CURVES 21 24 CFLAGS+=-DOPT_CURVES 22 #OPT_OBJS+=curves.o23 25 endif 24 26 ifdef OPT_TEXTREADER 25 27 CFLAGS+=-DOPT_TEXTREADER 26 #OPT_OBJS+=gui_read.o 28 endif 29 ifdef OPT_CALENDAR 30 CFLAGS+=-DOPT_CALENDAR 27 31 endif 28 32 ifdef OPT_DEBUGGING … … 39 43 endif 40 44 ifdef OPT_SCRIPTING 41 OPT_OBJS+= motion_detector.oscript.o45 OPT_OBJS+=script.o 42 46 endif 43 47 ifdef OPT_LUA … … 60 64 gui.o kbd.o action_stack.o conf.o module_wrappers.o module_exportlist.o \ 61 65 histogram.o gui_batt.o gui_space.o gui_osd.o raw.o \ 62 gui_usb.o gui_lang.o gui_grid.o modules.o module_load.o\63 levent.o shot_histogram.o bitvector.o console.o\66 gui_usb.o gui_lang.o modules.o module_load.o \ 67 levent.o shot_histogram.o console.o \ 64 68 usb_input.o usb_module.o usb_remote.o $(OPT_OBJS) 65 69 … … 103 107 module_exportlist.h: $(topdir)tools/makeexport$(EXE) module_exportlist.c 104 108 @echo $< \-\> $@ 105 $(topdir)tools/makeexport$(EXE) module_exportlist.c module_exportlist.h modules/exportlist.txt 109 $(topdir)tools/makeexport$(EXE) module_exportlist.c module_exportlist.h modules/exportlist.txt module_hashlist.h 106 110 107 111 flt.h: $(topdir)tools/elf2flt/flt.h -
trunk/core/conf.c
r1568 r1569 7 7 #include "raw.h" 8 8 #include "modules.h" 9 #include "module_load.h" 9 10 #include "gui_draw.h" 10 11 #include "gui_osd.h" … … 17 18 //------------------------------------------------------------------- 18 19 #define CONF_FILE "A/CHDK/CCHDK.CFG" 19 #define CONF_MAGICK_VALUE (0x33204741) 20 21 #define CONF_INFO(id, param, type, def, func) { id, sizeof( param ), type, ¶m, {def}/*, func*/ } 22 23 24 //------------------------------------------------------------------- 25 typedef struct { 26 unsigned short id; 27 unsigned char size; 28 char type; 29 void *var; 30 union { 31 void *ptr; 32 int i; 33 color cl; 34 }; 35 // Since only a few of the ConfInfo entries have a 'func' it saves space to not store the function addresses in the ConfInfo struct 36 // handled in conf_info_func code 37 //void (*func)(); 38 } ConfInfo; 39 40 //------------------------------------------------------------------- 41 Conf conf; 20 #define CONF_MAGICK_VALUE (0x33204741) 21 22 //------------------------------------------------------------------- 23 Conf conf = { MAKE_API_VERSION(2,0) }; 42 24 43 25 int state_shooting_progress = SHOOTING_PROGRESS_NONE; … … 71 53 static void conf_change_menu_symbol_rbf_file(); 72 54 static void conf_change_alt_mode_button(); 73 static void conf_change_grid_file();74 55 static void conf_change_video_bitrate(); 75 56 static void conf_change_dng_ext(); … … 149 130 shooting_video_bitrate_change(conf.video_bitrate); 150 131 } 151 conf.edge_overlay_pano = 0; // reset it because otherwise this feature cant be used at startup (when buffer is empty) - needs workaround other than this!132 //conf.edge_overlay_pano = 0; // reset it because otherwise this feature cant be used at startup (when buffer is empty) - needs workaround other than this! 152 133 } 153 134 … … 155 136 /* !!! Do NOT change ID for items defined already! Append a new one at the end! !!! */ 156 137 CONF_INFO( 1, conf.show_osd, CONF_DEF_VALUE, i:1, NULL), 157 CONF_INFO( 2, conf.save_raw, CONF_DEF_VALUE, i:0, NULL),138 CONF_INFO( 2, conf.save_raw, CONF_DEF_VALUE, i:0, conf_change_dng), 158 139 CONF_INFO( 3, conf.script_shoot_delay, CONF_DEF_VALUE, i:0, NULL), 159 140 CONF_INFO( 4, conf.show_histo, CONF_DEF_VALUE, i:0, NULL), … … 184 165 CONF_INFO( 29, conf.batt_icon_color, CONF_DEF_VALUE, cl:COLOR_WHITE, NULL), 185 166 CONF_INFO( 30, conf.menu_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL), 186 CONF_INFO( 31, conf.reader_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_GREY, COLOR_WHITE), NULL),167 //CONF_INFO( 31, conf.reader_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_GREY, COLOR_WHITE), NULL), 187 168 CONF_INFO( 32, conf.ricoh_ca1_mode, CONF_DEF_VALUE, i:0, NULL), 188 169 CONF_INFO( 33, conf.flashlight, CONF_DEF_VALUE, i:0, NULL), … … 192 173 CONF_INFO( 36, conf.raw_prefix, CONF_DEF_VALUE, i:RAW_PREFIX_CRW, NULL), 193 174 CONF_INFO( 37, conf.raw_ext, CONF_DEF_VALUE, i:DEFAULT_RAW_EXT, NULL), 194 CONF_INFO( 38, conf.reader_file, CONF_CHAR_PTR, ptr:"A/CHDK/BOOKS/README.TXT", NULL),195 CONF_INFO( 39, conf.reader_pos, CONF_DEF_VALUE, i:0, NULL),196 CONF_INFO( 40, conf.sokoban_level, CONF_DEF_VALUE, i:0, NULL),175 //CONF_INFO( 38, conf.reader_file, CONF_CHAR_PTR, ptr:"A/CHDK/BOOKS/README.TXT", NULL), 176 //CONF_INFO( 39, conf.reader_pos, CONF_DEF_VALUE, i:0, NULL), 177 //CONF_INFO( 40, conf.sokoban_level, CONF_DEF_VALUE, i:0, NULL), 197 178 CONF_INFO( 41, conf.show_clock, CONF_DEF_VALUE, i:2, NULL), 198 179 CONF_INFO( 42, conf.clock_pos, CONF_OSD_POS_PTR, ptr:&def_clock_pos , NULL), 199 CONF_INFO( 43, conf.reader_autoscroll, CONF_DEF_VALUE, i:0, NULL),200 CONF_INFO( 44, conf.reader_autoscroll_delay,CONF_DEF_VALUE, i:5, NULL),201 CONF_INFO( 45, conf.reader_rbf_file, CONF_CHAR_PTR, ptr:"", NULL),202 CONF_INFO( 46, conf.reader_codepage, CONF_DEF_VALUE, i:FONT_CP_WIN, NULL),180 //CONF_INFO( 43, conf.reader_autoscroll, CONF_DEF_VALUE, i:0, NULL), 181 //CONF_INFO( 44, conf.reader_autoscroll_delay,CONF_DEF_VALUE, i:5, NULL), 182 //CONF_INFO( 45, conf.reader_rbf_file, CONF_CHAR_PTR, ptr:"", NULL), 183 //CONF_INFO( 46, conf.reader_codepage, CONF_DEF_VALUE, i:FONT_CP_WIN, NULL), 203 184 CONF_INFO( 47, conf.splash_show, CONF_DEF_VALUE, i:1, NULL), 204 185 CONF_INFO( 48, conf.histo_color2, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_RED, COLOR_WHITE), NULL), 205 186 CONF_INFO( 49, conf.zebra_draw, CONF_DEF_VALUE, i:0, NULL), 206 CONF_INFO( 50, conf.zebra_mode, CONF_DEF_VALUE, i:ZEBRA_MODE_BLINKED_2, NULL),207 CONF_INFO( 51, conf.zebra_restore_screen, CONF_DEF_VALUE, i:1, NULL),208 CONF_INFO( 52, conf.zebra_restore_osd, CONF_DEF_VALUE, i:1, NULL),209 CONF_INFO( 53, conf.zebra_over, CONF_DEF_VALUE, i:1, NULL),210 CONF_INFO( 54, conf.zebra_under, CONF_DEF_VALUE, i:0, NULL),211 CONF_INFO( 55, conf.zebra_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_RED, COLOR_RED), NULL),212 CONF_INFO( 56, conf.zebra_draw_osd, CONF_DEF_VALUE, i:ZEBRA_DRAW_HISTO, NULL),187 //CONF_INFO( 50, conf.zebra_mode, CONF_DEF_VALUE, i:ZEBRA_MODE_BLINKED_2, NULL), 188 //CONF_INFO( 51, conf.zebra_restore_screen, CONF_DEF_VALUE, i:1, NULL), 189 //CONF_INFO( 52, conf.zebra_restore_osd, CONF_DEF_VALUE, i:1, NULL), 190 //CONF_INFO( 53, conf.zebra_over, CONF_DEF_VALUE, i:1, NULL), 191 //CONF_INFO( 54, conf.zebra_under, CONF_DEF_VALUE, i:0, NULL), 192 //CONF_INFO( 55, conf.zebra_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_RED, COLOR_RED), NULL), 193 //CONF_INFO( 56, conf.zebra_draw_osd, CONF_DEF_VALUE, i:ZEBRA_DRAW_HISTO, NULL), 213 194 CONF_INFO( 57, conf.user_menu_as_root, CONF_DEF_VALUE, i:0, NULL), 214 195 CONF_INFO( 58, conf.zoom_value, CONF_DEF_VALUE, i:ZOOM_SHOW_X, NULL), 215 196 CONF_INFO( 59, conf.use_zoom_mf, CONF_DEF_VALUE, i:0, NULL), 216 197 CONF_INFO( 60, conf.raw_save_first_only, CONF_DEF_VALUE, i:0, NULL), 217 CONF_INFO( 61, conf.reader_wrap_by_words, CONF_DEF_VALUE, i:1, NULL),198 //CONF_INFO( 61, conf.reader_wrap_by_words, CONF_DEF_VALUE, i:1, NULL), 218 199 CONF_INFO( 62, conf.menu_symbol_enable, CONF_DEF_VALUE, i:1, NULL), 219 200 CONF_INFO( 63, conf.alt_mode_button, CONF_DEF_VALUE, i:KEY_PRINT, conf_change_alt_mode_button), … … 223 204 CONF_INFO( 67, conf.alt_prevent_shutdown, CONF_DEF_VALUE, i:ALT_PREVENT_SHUTDOWN_ALT, conf_update_prevent_shutdown), 224 205 CONF_INFO( 68, conf.show_grid_lines, CONF_DEF_VALUE, i:0, NULL), 225 CONF_INFO( 69, conf.grid_lines_file, CONF_CHAR_PTR, ptr:"", conf_change_grid_file),206 //CONF_INFO( 69, conf.grid_lines_file, CONF_CHAR_PTR, ptr:"", NULL), 226 207 CONF_INFO( 70, conf.raw_nr, CONF_DEF_VALUE, i:NOISE_REDUCTION_AUTO_CANON, NULL), 227 CONF_INFO( 71, conf.grid_force_color, CONF_DEF_VALUE, i:0, NULL),228 CONF_INFO( 72, conf.grid_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL),208 //CONF_INFO( 71, conf.grid_force_color, CONF_DEF_VALUE, i:0, NULL), 209 //CONF_INFO( 72, conf.grid_color, CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL), 229 210 230 211 CONF_INFO( 80, conf.dof_subj_dist_as_near_limit,CONF_DEF_VALUE, i:0, NULL), … … 287 268 288 269 CONF_INFO(126, conf.clear_bracket, CONF_DEF_VALUE, i:1, NULL), 289 CONF_INFO(127, conf.zebra_multichannel, CONF_DEF_VALUE, i:0, NULL),270 //CONF_INFO(127, conf.zebra_multichannel, CONF_DEF_VALUE, i:0, NULL), 290 271 291 272 CONF_INFO(128, conf.nd_filter_state, CONF_DEF_VALUE, i:0, NULL), … … 355 336 CONF_INFO(187, conf.edge_overlay_enable, CONF_DEF_VALUE, i:0, NULL), 356 337 CONF_INFO(188, conf.edge_overlay_thresh, CONF_DEF_VALUE, i:60, NULL), 357 CONF_INFO(189, conf.edge_overlay_color, CONF_DEF_VALUE, cl:0x66, NULL),338 //CONF_INFO(189, conf.edge_overlay_color, CONF_DEF_VALUE, cl:0x66, NULL), 358 339 CONF_INFO(190, conf.synch_enable, CONF_DEF_VALUE, i:0, NULL), 359 340 CONF_INFO(191, conf.synch_delay_enable, CONF_DEF_VALUE, i:0, NULL), … … 388 369 CONF_INFO(220, conf.temperature_unit, CONF_DEF_VALUE, i:0, NULL), 389 370 CONF_INFO(221, conf.clear_zoom_override, CONF_DEF_VALUE, i:1, NULL), 390 CONF_INFO(222, conf.edge_overlay_play, CONF_DEF_VALUE, i:0, NULL),391 CONF_INFO(223, conf.edge_overlay_pano, CONF_DEF_VALUE, i:0, NULL),392 CONF_INFO(224, conf.edge_overlay_zoom, CONF_DEF_VALUE, i:1, NULL),371 //CONF_INFO(222, conf.edge_overlay_play, CONF_DEF_VALUE, i:0, NULL), 372 //CONF_INFO(223, conf.edge_overlay_pano, CONF_DEF_VALUE, i:0, NULL), 373 //CONF_INFO(224, conf.edge_overlay_zoom, CONF_DEF_VALUE, i:1, NULL), 393 374 CONF_INFO(225, conf.raw_cache, CONF_DEF_VALUE, i:0, NULL), 394 375 CONF_INFO(226, conf.dng_raw, CONF_DEF_VALUE, i:0, conf_change_dng), … … 407 388 CONF_INFO(239, conf.debug_propcase_page, CONF_DEF_VALUE, i:0, NULL), 408 389 CONF_INFO(240, conf.debug_misc_vals_show, CONF_DEF_VALUE, i:0, NULL), 409 CONF_INFO(241, conf.edge_overlay_filter, CONF_DEF_VALUE, i:0, NULL),410 CONF_INFO(242, conf.edge_overlay_show, CONF_DEF_VALUE, i:0, NULL),411 CONF_INFO(243, conf.edge_overlay_pano_overlap, CONF_DEF_VALUE, i:30, NULL),390 //CONF_INFO(241, conf.edge_overlay_filter, CONF_DEF_VALUE, i:0, NULL), 391 //CONF_INFO(242, conf.edge_overlay_show, CONF_DEF_VALUE, i:0, NULL), 392 //CONF_INFO(243, conf.edge_overlay_pano_overlap, CONF_DEF_VALUE, i:30, NULL), 412 393 413 394 // Touch screen U/I overrides … … 422 403 CONF_INFO(248, conf.remote_switch_type, CONF_DEF_VALUE, i:0, NULL), 423 404 CONF_INFO(249, conf.remote_control_mode, CONF_DEF_VALUE, i:0, NULL), 405 406 // Text Box char map file 407 CONF_INFO(248, conf.charmap_file, CONF_CHAR_PTR, ptr:"", NULL), 424 408 425 409 }; … … 437 421 case 66: conf_change_menu_rbf_file(); break; 438 422 case 67: conf_update_prevent_shutdown(); break; 439 case 69: conf_change_grid_file(); break;440 423 case 101: conf_change_video_bitrate(); break; 441 424 case 183: conf_change_menu_symbol_rbf_file(); break; 442 425 case 194: conf_change_script_file(); break; 426 case 2: 443 427 case 226: conf_change_dng(); break; 444 428 case 235: conf_change_dng_ext(); break; … … 490 474 } 491 475 492 static void conf_change_grid_file() {493 grid_lines_load(conf.grid_lines_file);494 }495 496 476 static void conf_change_video_bitrate() { 497 477 shooting_video_bitrate_change(conf.video_bitrate); … … 500 480 void conf_change_dng(void){ 501 481 #if DNG_SUPPORT 502 if (conf. dng_raw) {482 if (conf.save_raw && conf.dng_raw) { 503 483 if ( !module_dng_load(LIBDNG_OWNED_BY_RAW) ) 504 484 return; … … 578 558 579 559 //------------------------------------------------------------------- 580 void conf_load_defaults() { 560 void config_load_defaults(const ConfInfo *confinfo, int conf_num, void (*info_func)(unsigned short id)) 561 { 581 562 register int i; 582 563 583 for (i=0; i< CONF_NUM; ++i) {584 switch (conf _info[i].type) {564 for (i=0; i<conf_num; ++i) { 565 switch (confinfo[i].type) { 585 566 case CONF_DEF_VALUE: 586 memcpy(conf _info[i].var, &(conf_info[i].i), conf_info[i].size);567 memcpy(confinfo[i].var, &(confinfo[i].i), confinfo[i].size); 587 568 break; 588 569 case CONF_INT_PTR: … … 590 571 case CONF_OSD_POS_PTR: 591 572 case CONF_CHAR_PTR: 592 memcpy(conf _info[i].var, conf_info[i].ptr, conf_info[i].size);573 memcpy(confinfo[i].var, confinfo[i].ptr, confinfo[i].size); 593 574 break; 594 575 } 595 conf_info_func(conf_info[i].id); 596 //if (conf_info[i].func) { 597 // conf_info[i].func(); 598 //} 599 } 576 if (info_func) info_func(confinfo[i].id); 577 } 578 } 579 580 void conf_load_defaults() 581 { 582 config_load_defaults(&conf_info[0], CONF_NUM, conf_info_func); 600 583 } 601 584 … … 609 592 } ConfInfoSave; 610 593 611 void conf_save() { 594 void config_save(const ConfInfo *conf_info, char *filename, int conf_num) 595 { 612 596 static const long t=CONF_MAGICK_VALUE; 613 597 register int i; 614 int fd; 615 char *buf = umalloc(sizeof(t) + CONF_NUM*sizeof(ConfInfoSave) + sizeof(conf)); 616 char *p=buf; 617 618 fd = open(CONF_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0777); 619 if (fd>=0){ 598 599 int size = sizeof(t) + conf_num * sizeof(ConfInfoSave); 600 for (i=0; i<conf_num; i++) size += conf_info[i].size; 601 602 char *buf = umalloc(size); 603 char *p = buf; 604 605 int fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0777); 606 if (fd >= 0) 607 { 620 608 memcpy(p, &t, sizeof(t)); 621 p+=sizeof(t); 622 for (i=0; i<CONF_NUM; ++i) { 609 p += sizeof(t); 610 for (i=0; i<conf_num; ++i) 611 { 623 612 ((ConfInfoSave*)p)->id = conf_info[i].id; 624 613 ((ConfInfoSave*)p)->size = conf_info[i].size; 625 614 p += sizeof(ConfInfoSave); 626 615 memcpy(p, conf_info[i].var, conf_info[i].size); 616 // Clear out unused space after string config item value 617 if ((conf_info[i].size == CONF_STR_LEN) && (strlen(conf_info[i].var) < CONF_STR_LEN)) 618 memset(p+strlen(conf_info[i].var), 0, CONF_STR_LEN-strlen(conf_info[i].var)); 627 619 p += conf_info[i].size; 628 620 } … … 634 626 } 635 627 636 //------------------------------------------------------------------- 637 void conf_restore() { 628 void conf_save() 629 { 630 config_save(&conf_info[0], CONF_FILE, CONF_NUM); 631 } 632 633 //------------------------------------------------------------------- 634 void config_restore(const ConfInfo *confinfo, char *filename, int conf_num, void (*init_defaults)(), void (*info_func)(unsigned short id)) 635 { 638 636 int fd, rcnt, i; 639 637 unsigned short id, size; 640 638 char *buf; 641 int offs ;639 int offs, old_ver; 642 640 struct stat st; 643 641 644 conf_init_defaults(); 645 646 conf_load_defaults(); 647 648 if( stat(CONF_FILE,&st) != 0 || st.st_size < sizeof(int)) 642 if (init_defaults) init_defaults(); 643 config_load_defaults(confinfo, conf_num, info_func); 644 645 if( stat(filename,&st) != 0 || st.st_size < sizeof(int)) 649 646 return; 650 647 … … 652 649 return; 653 650 654 fd = open( CONF_FILE, O_RDONLY, 0777);651 fd = open(filename, O_RDONLY, 0777); 655 652 if( fd < 0 ) { 656 653 ufree(buf); … … 665 662 return; 666 663 } 664 667 665 offs=sizeof(int); 668 666 while (1) { … … 677 675 offs += sizeof(short); 678 676 679 for (i=0; i< CONF_NUM; ++i) {680 if (conf _info[i].id==id && conf_info[i].size==size) {677 for (i=0; i<conf_num; ++i) { 678 if (confinfo[i].id==id && confinfo[i].size==size) { 681 679 if (offs + size <= rcnt) { 682 memcpy(conf_info[i].var, buf+offs, size); 683 conf_info_func(conf_info[i].id); 684 //if (conf_info[i].func) { 685 // conf_info[i].func(); 686 //} 680 memcpy(confinfo[i].var, buf+offs, size); 681 if (info_func) info_func(confinfo[i].id); 687 682 } 688 683 offs += size; … … 690 685 } 691 686 } 692 if (i == CONF_NUM) { // unknown id, just skip data687 if (i == conf_num) { // unknown id, just skip data 693 688 offs += size; 694 689 } … … 697 692 // clear any "clear on restart" values 698 693 clear_values(); 694 } 695 696 void conf_restore() 697 { 698 config_restore(&conf_info[0], CONF_FILE, CONF_NUM, conf_init_defaults, conf_info_func); 699 699 } 700 700 … … 814 814 } 815 815 if( ret!=CONF_EMPTY ) { 816 // if (conf_info[i].func) {817 // conf_info[i].func();818 // }819 816 conf_save(); 820 817 } 821 818 return ret; 822 819 } 820 821 //------------------------------------------------------------------- 823 822 // Common code extracted from raw.c (raw_savefile) and gui_osd.c (gui_osd_draw_raw_info) 824 823 // returns 0 if RAW save is disabled due to mode settings, etc, return 1 if RAW save OK -
trunk/core/curves.c
r1527 r1569 3 3 #include "stdlib.h" 4 4 #include "raw.h" 5 6 //#ifdef OPT_CURVES 7 #if 1 8 5 #include "gui_menu.h" 6 #include "gui_lang.h" 7 8 #include "modules.h" 9 9 #include "module_exportlist.h" 10 10 #include "curves.h" 11 12 char *conf_curve_file;13 int *conf_curve_enable;14 11 15 12 /* … … 106 103 107 104 void curve_init_mode() { 108 switch( *conf_curve_enable) {105 switch(conf.curve_enable) { 109 106 case 1: // custom - ensure alloc and load conf.curve_file 110 curve_load_data(conf _curve_file,CURVE_CUSTOM);107 curve_load_data(conf.curve_file,CURVE_CUSTOM); 111 108 break; 112 109 case 2: // system - ensure alloc and load syscurve … … 116 113 break; 117 114 default: 118 *conf_curve_enable = 0;115 conf.curve_enable = 0; 119 116 case 0: // disabled - free 120 117 curve_free_data(); … … 371 368 short EVbias = shooting_get_ev_correction1(); 372 369 373 switch( *conf_curve_enable) {370 switch(conf.curve_enable) { 374 371 case 0: 375 372 break; … … 385 382 case 2: 386 383 case 3: // +1EV, +2EV 387 if (current_curve_type == CURVE_SYSTEM) curveL_apply( *conf_curve_enable & 1 );384 if (current_curve_type == CURVE_SYSTEM) curveL_apply( conf.curve_enable & 1 ); 388 385 break; 389 386 case 4: // Auto DR … … 401 398 } 402 399 400 401 //------------------------------------------------------------------- 402 const char* gui_conf_curve_enum(int change, int arg) { 403 static const char* modes[]={ "None", "Custom", "+1EV", "+2EV", "Auto DR" }; 404 405 gui_enum_value_change(&conf.curve_enable,change,sizeof(modes)/sizeof(modes[0])); 406 407 if (change) 408 curve_init_mode(); 409 return modes[conf.curve_enable]; 410 } 411 412 static void gui_load_curve_selected(const char *fn) { 413 if (fn) { 414 // TODO we could sanity check here, but curve_set_type should fail gracefullish 415 strcpy(conf.curve_file,fn); 416 if (conf.curve_enable == 1) 417 curve_init_mode(); 418 } 419 } 420 421 void gui_load_curve(int arg) { 422 module_fselect_init(LANG_STR_SELECT_CURVE_FILE, conf.curve_file, CURVE_DIR, gui_load_curve_selected); 423 } 424 425 static CMenuItem curve_submenu_items[] = { 426 MENU_ITEM(0x5f,LANG_MENU_CURVE_ENABLE, MENUITEM_ENUM, gui_conf_curve_enum, 0 ), 427 MENU_ITEM(0x35,LANG_MENU_CURVE_LOAD, MENUITEM_PROC, gui_load_curve, 0 ), 428 MENU_ITEM(0x51,LANG_MENU_BACK, MENUITEM_UP, 0, 0 ), 429 {0} 430 }; 431 static CMenu curve_submenu = {0x85,LANG_MENU_CURVE_PARAM_TITLE, NULL, curve_submenu_items }; 432 403 433 // ========= MODULE INIT ================= 404 434 … … 407 437 408 438 struct libcurves_sym libcurves = { 409 MAKE_API_VERSION(1,0), // apiver: increase major if incomp latible changes made in module,439 MAKE_API_VERSION(1,0), // apiver: increase major if incompatible changes made in module, 410 440 // increase minor if compatible changes made(including extending this struct) 411 441 curve_init_mode, … … 421 451 void* MODULE_EXPORT_LIST[] = { 422 452 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 423 /* 1 */ (void*) 3,453 /* 1 */ (void*)1, 424 454 &libcurves 425 455 }; … … 432 462 // RETURN VALUE: 1 error, 0 ok 433 463 //--------------------------------------------------------- 434 int _module_loader( void** chdk_export_list )464 int _module_loader( unsigned int* chdk_export_list ) 435 465 { 436 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER )466 if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 437 467 return 1; 438 468 439 469 if ( !API_VERSION_MATCH_REQUIREMENT( camera_sensor.api_version, 1, 0 ) ) 440 470 return 1; 441 442 // Safe bind of conf. 443 tConfigVal configVal; 444 CONF_BIND_STR(185, conf_curve_file); 445 CONF_BIND_INT(186, conf_curve_enable ); 471 if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 472 return 1; 446 473 447 474 // Startup initialize … … 466 493 467 494 495 //--------------------------------------------------------- 496 // PURPOSE: Default action for simple modules (direct run) 497 // NOTE: Please comment this function if no default action and this library module 498 //--------------------------------------------------------- 499 int _module_run(int moduleidx, int argn, int* arguments) 500 { 501 module_idx=moduleidx; 502 503 gui_activate_sub_menu(&curve_submenu, module_idx); 504 505 return 0; 506 } 507 508 468 509 /******************** Module Information structure ******************/ 469 510 … … 481 522 482 523 /*************** END OF AUXILARY PART *******************/ 483 484 485 #endif -
trunk/core/curves.h
r1527 r1569 16 16 // This section is for CHDK core 17 17 extern struct libcurves_sym* libcurves; 18 extern struct libcurves_sym* module_curves_load(); // 0fail, addr-ok 18 19 #else 19 20 // This section is for module -
trunk/core/dng.c
r1558 r1569 735 735 736 736 struct libdng_sym libdng = { 737 MAKE_API_VERSION(1,0), // apiver: increase major if incomp latible changes made in module,737 MAKE_API_VERSION(1,0), // apiver: increase major if incompatible changes made in module, 738 738 // increase minor if compatible changes made(including extending this struct) 739 739 … … 752 752 void* MODULE_EXPORT_LIST[] = { 753 753 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 754 /* 1 */ (void*) 3,754 /* 1 */ (void*)1, 755 755 756 756 &libdng … … 758 758 759 759 //-------------------------------------------- 760 int _module_loader( void** chdk_export_list )760 int _module_loader( unsigned int* chdk_export_list ) 761 761 { 762 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER )762 if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 763 763 return 1; 764 764 -
trunk/core/dng.h
r1527 r1569 19 19 // Defines of exported to chdk symbols 20 20 #ifdef THIS_IS_CHDK_CORE 21 // This section is for CHDK core 21 22 22 // This section is for CHDK core 23 // values of semaphore 24 #define LIBDNG_OWNED_BY_RAW 0x1 25 #define LIBDNG_OWNED_BY_CONVERT 0x2 26 #define LIBDNG_OWNED_BY_CREATEBADPIXEL 0x4 27 23 28 extern struct libdng_sym* libdng; 29 extern struct libdng_sym* module_dng_load(int owner); // 0fail, addr-ok 30 extern void module_dng_unload(int owner); 31 24 32 #else 25 33 … … 33 41 extern void write_dng(int fd, char* rawadr, char* altrawadr, unsigned long uncachedbit); 34 42 35 extern void unload_bad_pixels_list_b(void);43 extern void unload_bad_pixels_list_b(void); 36 44 37 45 #endif 38 46 47 extern int module_convert_dng_to_chdk_raw(char* fn); // Return: 0-fail, 1-ok 48 39 49 #endif -
trunk/core/edgeoverlay.c
r1527 r1569 6 6 #include "stdlib.h" 7 7 #include "gui_draw.h" 8 #include "gui_menu.h" 9 #include "gui_lang.h" 8 10 #include "bitvector.h" 11 12 #include "modules.h" 9 13 #include "module_exportlist.h" 10 14 15 //------------------------------------------------------------------- 16 17 typedef struct 18 { 19 color edge_overlay_color; 20 int edge_overlay_filter; 21 int edge_overlay_zoom; // shall zoom be set when *edg file is loaded? 22 int edge_overlay_pano; // whether a full press changes back to live mode 23 int edge_overlay_pano_overlap; // overlap in % in pano mode 24 int edge_overlay_show; // whether to show overlay even when no button is pressed 25 int edge_overlay_play; // whether edge overlay is switched on also for play mode 26 } EdgeConf; 27 28 EdgeConf econf; 29 30 static ConfInfo conf_info[] = { 31 CONF_INFO( 1, econf.edge_overlay_color, CONF_DEF_VALUE, cl:0, NULL), 32 CONF_INFO( 2, econf.edge_overlay_play, CONF_DEF_VALUE, i:0, NULL), 33 CONF_INFO( 3, econf.edge_overlay_pano, CONF_DEF_VALUE, i:0, NULL), 34 CONF_INFO( 4, econf.edge_overlay_zoom, CONF_DEF_VALUE, i:1, NULL), 35 CONF_INFO( 5, econf.edge_overlay_filter, CONF_DEF_VALUE, i:0, NULL), 36 CONF_INFO( 6, econf.edge_overlay_show, CONF_DEF_VALUE, i:0, NULL), 37 CONF_INFO( 7, econf.edge_overlay_pano_overlap, CONF_DEF_VALUE, i:30, NULL), 38 }; 39 40 //------------------------------------------------------------------- 11 41 12 42 // the way we save edge overlays on their own... … … 14 44 #define EDGE_FILE_FORMAT EDGE_FILE_PREFIX "%04d.edg" 15 45 #define EDGE_SLICES 2 16 17 int* conf_edge_overlay_filter;18 color* conf_osd_color;19 int* conf_edge_overlay_zoom;20 int* conf_edge_overlay_thresh;21 color* conf_edge_overlay_color;22 int* conf_edge_overlay_pano;23 int* conf_edge_overlay_pano_overlap;24 int* conf_edge_overlay_show;25 int* conf_edge_overlay_play;26 46 27 47 typedef enum _edge_fsm_state … … 61 81 static void ensure_allocate_imagebuffer() 62 82 { 63 if (edgebuf == NULL)83 if (edgebuf == NULL) 64 84 { 65 85 edgebuf = bv_create(viewport_height * viewport_width, 1); … … 67 87 memset(edgebuf->ptr, 0, edgebuf->ptrLen); 68 88 } 69 if ( *conf_edge_overlay_filter && (smbuf == NULL))89 if (econf.edge_overlay_filter && (smbuf == NULL)) 70 90 { 71 91 smbuf = (unsigned char*)malloc(viewport_byte_width*3); … … 75 95 { 76 96 // Disable filtering if we do not have enough memory for it 77 *conf_edge_overlay_filter = 0;97 econf.edge_overlay_filter = 0; 78 98 } 79 99 } … … 97 117 fsm_state = EDGE_LIVE; 98 118 slice = 0; 119 120 // Clean up state saved in core CHDK 121 module_save_edge(edgebuf, fsm_state); 99 122 } 100 123 … … 146 169 if( !is_buffer_ready() ) 147 170 { 148 draw_string(0, 0, "No overlay to save.", *conf_osd_color);171 draw_string(0, 0, "No overlay to save.", conf.osd_color); 149 172 return; 150 173 } … … 181 204 utime(fn, &t); 182 205 sprintf(msg, "Saved as %s",fn); 183 draw_string(0, 0, msg, *conf_osd_color);206 draw_string(0, 0, msg, conf.osd_color); 184 207 } 185 208 safe_closedir(d); … … 203 226 { 204 227 fsm_state = EDGE_FROZEN; // switch to "edge overlay frozen"-mode 205 if ( *conf_edge_overlay_zoom)228 if (econf.edge_overlay_zoom) 206 229 { 207 230 shooting_set_zoom(zoom); … … 311 334 memset(edgebuf->ptr + slice*compressed_slice, 0, compressed_slice); 312 335 313 if ( *conf_edge_overlay_filter)336 if (econf.edge_overlay_filter) 314 337 { 315 338 // Prefill smbuf with three lines of avergae-filtered data. … … 333 356 shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL); 334 357 335 if ( *conf_edge_overlay_filter)358 if (econf.edge_overlay_filter) 336 359 { 337 360 // We need to shift up our smbuf one line, … … 385 408 conv2 = -conv2; 386 409 387 if (conv1 + conv2 > *conf_edge_overlay_thresh)410 if (conv1 + conv2 > conf.edge_overlay_thresh) 388 411 { 389 412 bv_set(edgebuf, (y-viewport_yoffset-camera_screen.edge_hmargin)*viewport_width + xdiv3, 1); … … 415 438 conv2 = -conv2; 416 439 417 if (conv1 + conv2 > *conf_edge_overlay_thresh)440 if (conv1 + conv2 > conf.edge_overlay_thresh) 418 441 { 419 442 bv_set(edgebuf, (y-viewport_yoffset-camera_screen.edge_hmargin)*viewport_width + xdiv3+1, 1); … … 429 452 // care so much about performance, you can enable it. 430 453 // 431 // if ( *conf_edge_overlay_filter)454 // if (econf.edge_overlay_filter) 432 455 // { 433 456 // // Here we do basic filtering on the detected edges. … … 464 487 // bv_get(edgebuf, (y+1)*viewport_width + (x+1)); 465 488 // 466 // if (! *conf_edge_overlay_show)489 // if (!econf.edge_overlay_show) 467 490 // { 468 491 // if (sum >= 5) // if we have at least 5 neighboring edges … … 492 515 int x_off, y_off; 493 516 494 const color cl = *conf_edge_overlay_color;517 const color cl = econf.edge_overlay_color; 495 518 const int y_slice_min = viewport_yoffset+camera_screen.edge_hmargin+ slice *slice_height; 496 519 const int y_slice_max = viewport_yoffset+camera_screen.edge_hmargin+(slice+1)*slice_height; … … 523 546 const int aspect_correct_x_off = x_off; 524 547 const int bEdge = bv_get(edgebuf, y_edgebuf + x); 525 const int bDraw = bEdge || (draw_get_pixel(aspect_correct_x_off, y_off) == *conf_edge_overlay_color);526 const color cl = bEdge ? *conf_edge_overlay_color : 0;548 const int bDraw = bEdge || (draw_get_pixel(aspect_correct_x_off, y_off) == econf.edge_overlay_color); 549 const color cl = bEdge ? econf.edge_overlay_color : 0; 527 550 if (bEdge || bDraw) 528 551 draw_pixel(aspect_correct_x_off, y_off, cl); … … 582 605 const int x_max = (viewport_width - 2); 583 606 584 switch( *conf_edge_overlay_pano)607 switch(econf.edge_overlay_pano) 585 608 { 586 609 case 0: // pano off … … 589 612 break; 590 613 case 1: // pano from left to right 591 xoffset = -x_max*(100- *conf_edge_overlay_pano_overlap)/100;614 xoffset = -x_max*(100-econf.edge_overlay_pano_overlap)/100; 592 615 break; 593 616 case 2: // pano from top to bottom 594 yoffset = -y_max*(100- *conf_edge_overlay_pano_overlap)/100;617 yoffset = -y_max*(100-econf.edge_overlay_pano_overlap)/100; 595 618 break; 596 619 case 3: // pano from right to left 597 xoffset = x_max*(100- *conf_edge_overlay_pano_overlap)/100;620 xoffset = x_max*(100-econf.edge_overlay_pano_overlap)/100; 598 621 break; 599 622 case 4: // pano from bottom to top 600 yoffset = y_max*(100- *conf_edge_overlay_pano_overlap)/100;623 yoffset = y_max*(100-econf.edge_overlay_pano_overlap)/100; 601 624 break; 602 625 case 5: // free mode … … 636 659 const int bHalfPress = kbd_is_key_pressed(KEY_SHOOT_HALF); 637 660 const int bPlayMode = (mode_get() & MODE_MASK) == MODE_PLAY; 638 const int bPanoramaMode = ( *conf_edge_overlay_pano != 0);639 const int bNeedHalfPress = ( *conf_edge_overlay_show != 1);640 const int bDisplayInPlay = ( *conf_edge_overlay_play == 1);661 const int bPanoramaMode = (econf.edge_overlay_pano != 0); 662 const int bNeedHalfPress = (econf.edge_overlay_show != 1); 663 const int bDisplayInPlay = (econf.edge_overlay_play == 1); 641 664 const int bGuiModeNone = (gui_get_mode() == GUI_MODE_NONE); 642 665 const int bGuiModeAlt = (gui_get_mode() == GUI_MODE_ALT); … … 721 744 // calculations. 722 745 bFullPress |= draw_edge_overlay(); 723 draw_string(0, 0, "Frozen", *conf_osd_color);746 draw_string(0, 0, "Frozen", conf.osd_color); 724 747 } 725 748 … … 755 778 756 779 757 780 //------------------------------------------------------------------- 781 static void gui_load_edge_selected( const char* fn ) { 782 if (fn) 783 load_edge_overlay(fn); 784 } 785 786 void gui_menuproc_edge_save(int arg) { 787 save_edge_overlay(); 788 } 789 790 void gui_menuproc_edge_load(int arg) { 791 module_fselect_init(LANG_MENU_EDGE_LOAD, EDGE_SAVE_DIR, EDGE_SAVE_DIR, gui_load_edge_selected); 792 } 793 794 static const char* gui_edge_pano_modes[] = { "Off", "Right", "Down", "Left", "Up", "Free"}; 795 static CMenuItem edge_overlay_submenu_items[] = { 796 MENU_ITEM(0x5c,LANG_MENU_EDGE_OVERLAY_ENABLE, MENUITEM_BOOL, &conf.edge_overlay_enable, 0 ), 797 MENU_ITEM(0x5c,LANG_MENU_EDGE_FILTER, MENUITEM_BOOL, &econf.edge_overlay_filter, 0 ), 798 MENU_ENUM2(0x5f,LANG_MENU_EDGE_PANO, &econf.edge_overlay_pano, gui_edge_pano_modes ), 799 MENU_ITEM(0x5e,LANG_MENU_EDGE_PANO_OVERLAP, MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &econf.edge_overlay_pano_overlap, MENU_MINMAX(0, 100) ), 800 MENU_ITEM(0x5c,LANG_MENU_EDGE_SHOW, MENUITEM_BOOL, &econf.edge_overlay_show, 0 ), 801 MENU_ITEM(0x5e,LANG_MENU_EDGE_OVERLAY_TRESH, MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.edge_overlay_thresh, MENU_MINMAX(0, 255) ), 802 MENU_ITEM(0x65,LANG_MENU_EDGE_OVERLAY_COLOR, MENUITEM_COLOR_FG, &econf.edge_overlay_color, 0 ), 803 MENU_ITEM(0x5c,LANG_MENU_EDGE_PLAY, MENUITEM_BOOL, &econf.edge_overlay_play, 0 ), //does not work on cams like s-series, which dont have a real "hardware" play/rec switch, need a workaround, probably another button 804 MENU_ITEM(0x33,LANG_MENU_EDGE_SAVE, MENUITEM_PROC, gui_menuproc_edge_save, 0 ), 805 MENU_ITEM(0x5c,LANG_MENU_EDGE_ZOOM, MENUITEM_BOOL, &econf.edge_overlay_zoom, 0 ), 806 MENU_ITEM(0x33,LANG_MENU_EDGE_LOAD, MENUITEM_PROC, gui_menuproc_edge_load, 0 ), 807 MENU_ITEM(0x51,LANG_MENU_BACK, MENUITEM_UP, 0, 0 ), 808 {0} 809 }; 810 static CMenu edge_overlay_submenu = {0x7f,LANG_MENU_EDGE_OVERLAY_TITLE, NULL, edge_overlay_submenu_items }; 758 811 759 812 … … 768 821 769 822 struct libedgeovr_sym libedgeovr = { 770 MAKE_API_VERSION(1,0), // apiver: increase major if incomp latible changes made in module,823 MAKE_API_VERSION(1,0), // apiver: increase major if incompatible changes made in module, 771 824 // increase minor if compatible changes made(including extending this struct) 772 825 773 826 edge_overlay, 774 save_edge_overlay,775 load_edge_overlay776 827 }; 777 828 … … 779 830 void* MODULE_EXPORT_LIST[] = { 780 831 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 781 /* 1 */ (void*) 3,832 /* 1 */ (void*)1, 782 833 783 834 &libedgeovr … … 791 842 // RETURN VALUE: 1 error, 0 ok 792 843 //--------------------------------------------------------- 793 int _module_loader( void** chdk_export_list )794 { 795 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER )844 int _module_loader( unsigned int* chdk_export_list ) 845 { 846 if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 796 847 return 1; 797 848 798 849 if ( !API_VERSION_MATCH_REQUIREMENT( camera_sensor.api_version, 1, 0 ) ) 799 850 return 1; 800 801 802 tConfigVal configVal; 803 CONF_BIND_INT(188, conf_edge_overlay_thresh); 804 CONF_BIND_COLOR(189, conf_edge_overlay_color); 805 CONF_BIND_INT(222, conf_edge_overlay_play); 806 CONF_BIND_INT(223, conf_edge_overlay_pano); 807 CONF_BIND_INT(224, conf_edge_overlay_zoom); 808 CONF_BIND_INT(241, conf_edge_overlay_filter); 809 CONF_BIND_INT(242, conf_edge_overlay_show); 810 CONF_BIND_INT(243, conf_edge_overlay_pano_overlap); 811 CONF_BIND_COLOR( 28, conf_osd_color); 851 if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 852 return 1; 853 854 conf_info[0].cl = MAKE_COLOR(0, COLOR_BLUE); 855 config_restore(&conf_info[0], "A/CHDK/MODULES/CFG/edgeovr.cfg", sizeof(conf_info)/sizeof(conf_info[0]), 0, 0); 856 857 module_restore_edge((void**)&edgebuf, (int*)&fsm_state); 812 858 813 859 return 0; 814 860 } 815 816 861 817 862 … … 822 867 int _module_unloader() 823 868 { 824 // This could be happens only if on-load mistake 825 // CHDK never unload this library (but load only if needed) 826 // Reason: edve_overlay allocate different bufs which should be kept 827 // because even if we turn off edgeovr we could turn on back and 828 // should get same content. 869 // Save state info 870 module_save_edge(edgebuf, fsm_state); 871 872 // Module can be unloaded when menu exits 873 // Edge overlay state is store in core CHDK and will 874 // be restored when module reloads 875 config_save(&conf_info[0], "A/CHDK/MODULES/CFG/edgeovr.cfg", sizeof(conf_info)/sizeof(conf_info[0])); 876 877 // Free filter buffer 878 if (smbuf != NULL) 879 { 880 free(smbuf); 881 smbuf = NULL; 882 } 883 884 return 0; 885 } 886 887 888 //--------------------------------------------------------- 889 // PURPOSE: Default action for simple modules (direct run) 890 // NOTE: Please comment this function if no default action and this library module 891 //--------------------------------------------------------- 892 int _module_run(int moduleidx, int argn, int* arguments) 893 { 894 module_idx=moduleidx; 895 896 gui_activate_sub_menu(&edge_overlay_submenu, module_idx); 897 829 898 return 0; 830 899 } … … 838 907 ANY_PLATFORM_ALLOWED, // Specify platform dependency 839 908 MODULEINFO_FLAG_SYSTEM, // flag 840 (int32_t)"Edge Over alay (dll)",// Module name909 (int32_t)"Edge Overlay (dll)",// Module name 841 910 1, 0, // Module version 842 911 (int32_t)"Implementation one of core modes" -
trunk/core/edgeoverlay.h
r1527 r1569 12 12 int version; 13 13 void (*edge_overlay)(); 14 void (*save_edge_overlay)(void);15 void (*load_edge_overlay)( const char* );16 14 }; 17 18 15 19 16 // Defines of exported to chdk symbols … … 21 18 // This section is for CHDK core 22 19 extern struct libedgeovr_sym* libedgeovr; 20 extern struct libedgeovr_sym* module_edgeovr_load(); // 0fail, addr-ok 23 21 #else 24 22 // This section is for module 25 void edge_overlay(); 26 void save_edge_overlay(void); 27 void load_edge_overlay( const char* ); 23 extern void edge_overlay(); 28 24 #endif 29 25 26 extern void module_restore_edge(void **buf, int *state); 27 extern void module_save_edge(void* buf, int state); 28 30 29 #endif -
trunk/core/gui.c
r1568 r1569 23 23 #include "gui_space.h" 24 24 #include "gui_osd.h" 25 #ifdef OPT_TEXTREADER26 #include "gui_read.h"27 #endif28 #include "gui_grid.h"29 25 #include "histogram.h" 30 26 #include "motion_detector.h" 31 27 #include "raw.h" 32 28 #include "dng.h" 33 #ifdef OPT_CURVES 34 #include "curves.h" 35 #endif 36 #ifdef OPT_EDGEOVERLAY 37 #include "modules.h" 38 #endif 29 #include "modules.h" 39 30 #ifdef OPT_SCRIPTING 40 31 #include "script.h" … … 152 143 static void gui_show_build_info(int arg); 153 144 static void gui_show_memory_info(int arg); 154 void gui_modules_menu_load();145 //void gui_modules_menu_load(); 155 146 156 147 #ifdef OPT_DEBUGGING … … 161 152 #endif 162 153 static void gui_draw_fselect(int arg); 163 #ifdef OPT_TEXTREADER164 static void gui_draw_read(int arg);165 static void gui_draw_read_last(int arg);166 #endif167 154 static void gui_draw_load_menu_rbf(int arg); 168 155 static void gui_draw_load_symbol_rbf(int arg); //AKA 169 #ifdef OPT_TEXTREADER170 static void gui_draw_load_rbf(int arg);171 #endif172 156 #ifdef OPT_CALENDAR 173 157 static void gui_draw_calendar(int arg); 174 158 #endif 159 static void gui_load_charmap(int arg); 175 160 static void gui_draw_load_lang(int arg); 176 161 static void gui_menuproc_mkbootdisk(int arg); … … 179 164 #endif 180 165 static void gui_menuproc_reset(int arg); 181 static void gui_grid_lines_load(int arg);182 166 static void gui_raw_develop(int arg); 183 167 static void gui_menuproc_swap_partitions(int arg); 184 168 static void gui_menuproc_reset_files(int arg); 185 #ifdef OPT_CURVES186 static void gui_load_curve_selected(const char *fn);187 static void gui_load_curve(int arg);188 #endif189 169 static const char* gui_histo_mode_enum(int change, int arg); 190 170 static const char* gui_histo_layout_enum(int change, int arg); … … 213 193 static const char* gui_bad_pixel_enum(int change, int arg); 214 194 static const char* gui_video_af_key_enum(int change, int arg); 215 #ifdef OPT_CURVES216 static const char* gui_conf_curve_enum(int change, int arg);217 #endif218 219 #ifdef OPT_EDGEOVERLAY220 static void gui_menuproc_edge_save(int arg);221 static void gui_menuproc_edge_load(int arg);222 #endif223 195 224 196 #ifdef OPT_SCRIPTING … … 238 210 static void cb_space_mb(); 239 211 static void cb_battery_menu_change(unsigned int item); 240 static void cb_zebra_restore_screen();241 static void cb_zebra_restore_osd();242 212 #if DNG_SUPPORT 243 213 static void cb_change_dng(); … … 328 298 329 299 330 #ifdef OPT_TEXTREADER331 static const char* gui_reader_codepage_cps[] = { "Win1251", "DOS"};332 static CMenuItem reader_submenu_items[] = {333 MENU_ITEM(0x35,LANG_MENU_READ_OPEN_NEW, MENUITEM_PROC, gui_draw_read, 0 ),334 MENU_ITEM(0x35,LANG_MENU_READ_OPEN_LAST, MENUITEM_PROC, gui_draw_read_last, 0 ),335 MENU_ITEM(0x35,LANG_MENU_READ_SELECT_FONT, MENUITEM_PROC, gui_draw_load_rbf, 0 ),336 MENU_ENUM2(0x5f,LANG_MENU_READ_CODEPAGE, &conf.reader_codepage, gui_reader_codepage_cps ),337 MENU_ITEM(0x5c,LANG_MENU_READ_WORD_WRAP, MENUITEM_BOOL, &conf.reader_wrap_by_words, 0 ),338 MENU_ITEM(0x5c,LANG_MENU_READ_AUTOSCROLL, MENUITEM_BOOL, &conf.reader_autoscroll, 0 ),339 MENU_ITEM(0x5f,LANG_MENU_READ_AUTOSCROLL_DELAY, MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.reader_autoscroll_delay, MENU_MINMAX(0, 60) ),340 MENU_ITEM(0x51,LANG_MENU_BACK, MENUITEM_UP, 0, 0 ),341 {0}342 };343 static CMenu reader_submenu = {0x37,LANG_MENU_READ_TITLE, NULL, reader_submenu_items };344 #endif345 346 300 #ifdef OPT_DEBUGGING 347 301 static const char* gui_debug_shortcut_modes[] = { "None", "DmpRAM", "Page", "CmpProps"}; … … 352 306 MENU_ITEM(0x2a,LANG_MENU_DEBUG_TASKLIST_START, MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &debug_tasklist_start, MENU_MINMAX(0, 63) ), 353 307 MENU_ITEM(0x5c,LANG_MENU_DEBUG_SHOW_MISC_VALS, MENUITEM_BOOL, &conf.debug_misc_vals_show, 0 ), 308 MENU_ITEM(0x2a,LANG_MENU_DEBUG_MEMORY_BROWSER, MENUITEM_PROC, gui_menu_run_fltmodule, "memview.flt" ), 309 MENU_ITEM(0x2a,LANG_MENU_DEBUG_BENCHMARK, MENUITEM_PROC, gui_menu_run_fltmodule, "benchm.flt" ), 354 310 MENU_ENUM2(0x5c,LANG_MENU_DEBUG_SHORTCUT_ACTION, &conf.debug_shortcut_action, gui_debug_shortcut_modes ), 355 311 MENU_ITEM(0x5c,LANG_MENU_RAW_TIMER, MENUITEM_BOOL, &conf.raw_timer, 0 ), … … 370 326 static CMenuItem misc_submenu_items[] = { 371 327 MENU_ITEM(0x35,LANG_MENU_MISC_FILE_BROWSER, MENUITEM_PROC, gui_draw_fselect, 0 ), 372 MENU_ITEM(0x65,(int)"Modules", MENUITEM_TEXT, 0, 0 ), 328 MENU_ITEM(0x80,(int)"Module Inspector", MENUITEM_PROC, gui_menu_run_fltmodule, "modinsp.flt" ), 329 #ifdef OPT_CALENDAR 330 MENU_ITEM(0x36,LANG_MENU_MISC_CALENDAR, MENUITEM_PROC, gui_menu_run_fltmodule, "calend.flt" ), 331 #endif 373 332 #ifdef OPT_TEXTREADER 374 MENU_ITEM(0x37,LANG_MENU_MISC_TEXT_READER, MENUITEM_SUBMENU, &reader_submenu, 0 ), 333 MENU_ITEM(0x37,LANG_MENU_MISC_TEXT_READER, MENUITEM_SUBMENU_PROC, gui_menu_run_fltmodule, "txtread.flt" ), 334 #endif 335 #if defined (OPT_GAMES) 336 MENU_ITEM(0x38,LANG_MENU_MISC_GAMES, MENUITEM_SUBMENU_PROC, gui_menu_run_fltmodule, "gamemenu.flt" ), 375 337 #endif 376 338 #if CAM_SWIVEL_SCREEN … … 386 348 #endif 387 349 MENU_ITEM(0x5d,LANG_MENU_MISC_DISABLE_LCD_OFF, MENUITEM_ENUM, gui_alt_power_enum, 0 ), 350 MENU_ITEM(0x65,LANG_MENU_MISC_PALETTE, MENUITEM_PROC, gui_menu_run_fltmodule, "palette.flt" ), 388 351 MENU_ITEM(0x80,LANG_MENU_MISC_BUILD_INFO, MENUITEM_PROC, gui_show_build_info, 0 ), 389 352 MENU_ITEM(0x80,LANG_MENU_MISC_MEMORY_INFO, MENUITEM_PROC, gui_show_memory_info, 0 ), … … 620 583 static CMenu operation_submenu = {0x21,LANG_MENU_OPERATION_PARAM_TITLE, NULL, operation_submenu_items }; 621 584 622 #ifdef OPT_EDGEOVERLAY623 static const char* gui_edge_pano_modes[] = { "Off", "Right", "Down", "Left", "Up", "Free"};624 static CMenuItem edge_overlay_submenu_items[] = {625 MENU_ITEM(0x5c,LANG_MENU_EDGE_OVERLAY_ENABLE, MENUITEM_BOOL, &conf.edge_overlay_enable, 0 ),626 MENU_ITEM(0x5c,LANG_MENU_EDGE_FILTER, MENUITEM_BOOL, &conf.edge_overlay_filter, 0 ),627 MENU_ENUM2(0x5f,LANG_MENU_EDGE_PANO, &conf.edge_overlay_pano, gui_edge_pano_modes ),628 MENU_ITEM(0x5e,LANG_MENU_EDGE_PANO_OVERLAP, MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.edge_overlay_pano_overlap, MENU_MINMAX(0, 100) ),629 MENU_ITEM(0x5c,LANG_MENU_EDGE_SHOW, MENUITEM_BOOL, &conf.edge_overlay_show, 0 ),630 MENU_ITEM(0x5e,LANG_MENU_EDGE_OVERLAY_TRESH, MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.edge_overlay_thresh, MENU_MINMAX(0, 255) ),631 MENU_ITEM(0x65,LANG_MENU_EDGE_OVERLAY_COLOR, MENUITEM_COLOR_FG, &conf.edge_overlay_color, 0 ),632 MENU_ITEM(0x5c,LANG_MENU_EDGE_PLAY, MENUITEM_BOOL, &conf.edge_overlay_play, 0 ), //does not work on cams like s-series, which dont have a real "hardware" play/rec switch, need a workaround, probably another button633 MENU_ITEM(0x33,LANG_MENU_EDGE_SAVE, MENUITEM_PROC, gui_menuproc_edge_save, 0 ),634 MENU_ITEM(0x5c,LANG_MENU_EDGE_ZOOM, MENUITEM_BOOL, &conf.edge_overlay_zoom, 0 ),635 MENU_ITEM(0x33,LANG_MENU_EDGE_LOAD, MENUITEM_PROC, gui_menuproc_edge_load, 0 ),636 MENU_ITEM(0x51,LANG_MENU_BACK, MENUITEM_UP, 0, 0 ),637 {0}638 };639 static CMenu edge_overlay_submenu = {0x7f,LANG_MENU_EDGE_OVERLAY_TITLE, NULL, edge_overlay_submenu_items };640 #endif641 642 static CMenuItem grid_submenu_items[] = {643 MENU_ITEM(0x2f,LANG_MENU_SHOW_GRID, MENUITEM_BOOL, &conf.show_grid_lines, 0 ),644 MENU_ITEM(0x35,LANG_MENU_GRID_LOAD, MENUITEM_PROC, gui_grid_lines_load, 0 ),645 MENU_ITEM(0x0,LANG_MENU_GRID_CURRENT, MENUITEM_SEPARATOR, 0, 0 ),646 MENU_ITEM(0x0,(int)grid_title, MENUITEM_TEXT, 0, 0 ),647 MENU_ITEM(0x0,(int)"", MENUITEM_SEPARATOR, 0, 0 ),648 MENU_ITEM(0x5c,LANG_MENU_GRID_FORCE_COLOR, MENUITEM_BOOL, &conf.grid_force_color, 0 ),649 MENU_ITEM(0x65,LANG_MENU_GRID_COLOR_LINE, MENUITEM_COLOR_FG, &conf.grid_color, 0 ),650 MENU_ITEM(0x65,LANG_MENU_GRID_COLOR_FILL, MENUITEM_COLOR_BG, &conf.grid_color, 0 ),651 MENU_ITEM(0x51,LANG_MENU_BACK, MENUITEM_UP, 0, 0 ),652 {0}653 };654 static CMenu grid_submenu = {0x2f,LANG_MENU_GRID_TITLE, NULL, grid_submenu_items };655 656 585 static CMenuItem visual_submenu_items[] = { 657 586 MENU_ITEM(0x35,LANG_MENU_VIS_LANG, MENUITEM_PROC, gui_draw_load_lang, 0 ), … … 659 588 MENU_ITEM(0x35,LANG_MENU_VIS_MENU_FONT, MENUITEM_PROC, gui_draw_load_menu_rbf, 0 ), 660 589 MENU_ITEM(0x35,LANG_MENU_VIS_MENU_SYMBOL_FONT, MENUITEM_PROC, gui_draw_load_symbol_rbf, 0 ), 590 MENU_ITEM(0x35,LANG_MENU_VIS_CHARMAP, MENUITEM_PROC, gui_load_charmap, 0 ), 661 591 MENU_ITEM(0x80,LANG_MENU_RESET_FILES , MENUITEM_PROC, gui_menuproc_reset_files, 0 ), 662 592 MENU_ITEM(0x0,LANG_MENU_VIS_COLORS, MENUITEM_SEPARATOR, 0, 0 ), … … 669 599 MENU_ITEM(0x65,LANG_MENU_VIS_HISTO_BORDER, MENUITEM_COLOR_FG, &conf.histo_color2, 0 ), 670 600 MENU_ITEM(0x65,LANG_MENU_VIS_HISTO_MARKERS, MENUITEM_COLOR_BG, &conf.histo_color2, 0 ), 671 MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_UNDER, MENUITEM_COLOR_BG, &conf.zebra_color, 0 ),672 MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_OVER, MENUITEM_COLOR_FG, &conf.zebra_color, 0 ),601 //MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_UNDER, MENUITEM_COLOR_BG, &conf.zebra_color, 0 ), // moved to zebra menu 602 //MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_OVER, MENUITEM_COLOR_FG, &conf.zebra_color, 0 ), // moved to zebra menu 673 603 MENU_ITEM(0x65,LANG_MENU_VIS_BATT_ICON, MENUITEM_COLOR_FG, &conf.batt_icon_color, 0 ), 674 604 MENU_ITEM(0x65,LANG_MENU_VIS_SPACE_ICON, MENUITEM_COLOR_FG, &conf.space_color, 0 ), … … 682 612 MENU_ITEM(0x65,LANG_MENU_VIS_MENU_SYMBOL_TEXT, MENUITEM_COLOR_FG, &conf.menu_symbol_color, 0 ), 683 613 MENU_ITEM(0x65,LANG_MENU_VIS_MENU_SYMBOL_BKG, MENUITEM_COLOR_BG, &conf.menu_symbol_color, 0 ), 684 MENU_ITEM(0x65,LANG_MENU_VIS_READER_TEXT, MENUITEM_COLOR_FG, &conf.reader_color, 0 ),685 MENU_ITEM(0x65,LANG_MENU_VIS_READER_BKG, MENUITEM_COLOR_BG, &conf.reader_color, 0 ),614 //MENU_ITEM(0x65,LANG_MENU_VIS_READER_TEXT, MENUITEM_COLOR_FG, &conf.reader_color, 0 ), // moved to text reader menu 615 //MENU_ITEM(0x65,LANG_MENU_VIS_READER_BKG, MENUITEM_COLOR_BG, &conf.reader_color, 0 ), // moved to text reader menu 686 616 MENU_ITEM(0x65,LANG_MENU_VIS_OSD_OVERRIDE, MENUITEM_COLOR_FG, &conf.osd_color_override, 0 ), 687 617 MENU_ITEM(0x65,LANG_MENU_VIS_OSD_OVERRIDE_BKG, MENUITEM_COLOR_BG, &conf.osd_color_override, 0 ), … … 742 672 MENU_ENUM2(0x71,LANG_MENU_USB_SHOW_INFO, &conf.usb_info_enable, gui_show_usb_info_modes ), 743 673 MENU_ITEM(0x72,LANG_MENU_OSD_LAYOUT_EDITOR, MENUITEM_PROC, gui_draw_osd_le, 0 ), 744 MENU_ITEM(0x2f,LANG_MENU_OSD_GRID_PARAMS, MENUITEM_SUBMENU , &grid_submenu, 0),674 MENU_ITEM(0x2f,LANG_MENU_OSD_GRID_PARAMS, MENUITEM_SUBMENU_PROC, gui_menu_run_fltmodule, "grids.flt" ), 745 675 MENU_ITEM(0x22,LANG_MENU_OSD_VALUES, MENUITEM_SUBMENU, &values_submenu, 0 ), 746 676 MENU_ITEM(0x31,LANG_MENU_OSD_DOF_CALC, MENUITEM_SUBMENU, &dof_submenu, 0 ), … … 799 729 static const char* gui_raw_nr_modes[] = { "Auto", "Off", "On"}; 800 730 static CMenuItem raw_submenu_items[] = { 801 MENU_ITEM(0x5c,LANG_MENU_RAW_SAVE, MENUITEM_BOOL , &conf.save_raw, 0),731 MENU_ITEM(0x5c,LANG_MENU_RAW_SAVE, MENUITEM_BOOL | MENUITEM_ARG_CALLBACK, &conf.save_raw, (int)cb_change_dng ), 802 732 MENU_ITEM(0x59,LANG_MENU_OSD_RAW_EXCEPTIONS_PARAMS, MENUITEM_SUBMENU, &raw_exceptions_submenu, 0 ), 803 733 MENU_ENUM2(0x5f,LANG_MENU_RAW_NOISE_REDUCTION, &conf.raw_nr, gui_raw_nr_modes ), … … 823 753 static CMenu raw_submenu = {0x24,LANG_MENU_RAW_TITLE, NULL, raw_submenu_items }; 824 754 825 826 static const char* gui_zebra_mode_modes[] = { "Blink 1", "Blink 2", "Blink 3", "Solid", "Zebra 1", "Zebra 2" };827 static const char* gui_zebra_draw_osd_modes[] = { "Nothing", "Histo", "OSD" };828 static CMenuItem zebra_submenu_items[] = {829 MENU_ITEM(0x5c,LANG_MENU_ZEBRA_DRAW, MENUITEM_BOOL, &conf.zebra_draw, 0 ),830 MENU_ENUM2(0x5f,LANG_MENU_ZEBRA_MODE, &conf.zebra_mode, gui_zebra_mode_modes ),831 MENU_ITEM(0x58,LANG_MENU_ZEBRA_UNDER, MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.zebra_under, MENU_MINMAX(0, 32) ),832 MENU_ITEM(0x57,LANG_MENU_ZEBRA_OVER, MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.zebra_over, MENU_MINMAX(0, 32) ),833 MENU_ITEM(0x28,LANG_MENU_ZEBRA_RESTORE_SCREEN, MENUITEM_BOOL|MENUITEM_ARG_CALLBACK, &conf.zebra_restore_screen, (int)cb_zebra_restore_screen ),834 MENU_ITEM(0x5c,LANG_MENU_ZEBRA_RESTORE_OSD, MENUITEM_BOOL|MENUITEM_ARG_CALLBACK, &conf.zebra_restore_osd, (int)cb_zebra_restore_osd ),835 MENU_ENUM2(0x5f,LANG_MENU_ZEBRA_DRAW_OVER, &conf.zebra_draw_osd, gui_zebra_draw_osd_modes ),836 MENU_ITEM(0x5c,LANG_MENU_ZEBRA_MULTICHANNEL, MENUITEM_BOOL, &conf.zebra_multichannel, 0 ),837 MENU_ITEM(0x51,LANG_MENU_BACK, MENUITEM_UP, 0, 0 ),838 {0}839 };840 static CMenu zebra_submenu = {0x26,LANG_MENU_ZEBRA_TITLE, NULL, zebra_submenu_items };841 842 #ifdef OPT_CURVES843 static CMenuItem curve_submenu_items[] = {844 MENU_ITEM(0x5f,LANG_MENU_CURVE_ENABLE, MENUITEM_ENUM, gui_conf_curve_enum, 0 ),845 MENU_ITEM(0x35,LANG_MENU_CURVE_LOAD, MENUITEM_PROC, gui_load_curve, 0 ),846 MENU_ITEM(0x51,LANG_MENU_BACK, MENUITEM_UP, 0, 0 ),847 {0}848 };849 static CMenu curve_submenu = {0x85,LANG_MENU_CURVE_PARAM_TITLE, NULL, curve_submenu_items };850 #endif851 852 755 static CMenuItem root_menu_items[] = { 853 756 MENU_ITEM(0x21,LANG_MENU_OPERATION_PARAM, MENUITEM_SUBMENU, &operation_submenu, 0 ), … … 855 758 MENU_ITEM(0x24,LANG_MENU_MAIN_RAW_PARAM, MENUITEM_SUBMENU, &raw_submenu, 0 ), 856 759 #ifdef OPT_EDGEOVERLAY 857 MENU_ITEM(0x7f,LANG_MENU_EDGE_OVERLAY, MENUITEM_SUBMENU, &edge_overlay_submenu, 0),760 MENU_ITEM(0x7f,LANG_MENU_EDGE_OVERLAY, MENUITEM_SUBMENU_PROC, gui_menu_run_fltmodule, "edgeovr.flt" ), 858 761 #endif 859 762 #ifdef OPT_CURVES 860 MENU_ITEM(0x85,LANG_MENU_CURVE_PARAM, MENUITEM_SUBMENU , &curve_submenu, 0),763 MENU_ITEM(0x85,LANG_MENU_CURVE_PARAM, MENUITEM_SUBMENU_PROC, gui_menu_run_fltmodule, "curves.flt" ), 861 764 #endif 862 765 MENU_ITEM(0x25,LANG_MENU_MAIN_HISTO_PARAM, MENUITEM_SUBMENU, &histo_submenu, 0 ), 863 MENU_ITEM(0x26,LANG_MENU_MAIN_ZEBRA_PARAM, MENUITEM_SUBMENU , &zebra_submenu, 0),766 MENU_ITEM(0x26,LANG_MENU_MAIN_ZEBRA_PARAM, MENUITEM_SUBMENU_PROC, gui_menu_run_fltmodule, "zebra.flt" ), 864 767 MENU_ITEM(0x22,LANG_MENU_MAIN_OSD_PARAM, MENUITEM_SUBMENU, &osd_submenu, 0 ), 865 768 MENU_ITEM(0x28,LANG_MENU_MAIN_VISUAL_PARAM, MENUITEM_SUBMENU, &visual_submenu, 0 ), … … 994 897 } 995 898 996 void cb_zebra_restore_screen() {997 if (!conf.zebra_restore_screen)998 conf.zebra_restore_osd = 0;999 }1000 1001 void cb_zebra_restore_osd() {1002 if (conf.zebra_restore_osd)1003 conf.zebra_restore_screen = 1;1004 }1005 1006 899 #if DNG_SUPPORT 1007 900 void cb_change_dng(){ … … 1030 923 save memory by eliminating dupe code 1031 924 */ 1032 staticvoid gui_enum_value_change(int *value, int change, unsigned num_items) {925 void gui_enum_value_change(int *value, int change, unsigned num_items) { 1033 926 *value+=change; 1034 927 if (*value<0) … … 1047 940 return items[*menu_item->value]; 1048 941 } 1049 1050 //-------------------------------------------------------------------1051 #ifdef OPT_CURVES1052 const char* gui_conf_curve_enum(int change, int arg) {1053 static const char* modes[]={ "None", "Custom", "+1EV", "+2EV", "Auto DR" };1054 1055 gui_enum_value_change(&conf.curve_enable,change,sizeof(modes)/sizeof(modes[0]));1056 1057 if(change && libcurves && libcurves->curve_init_mode)1058 libcurves->curve_init_mode();1059 return modes[conf.curve_enable];1060 }1061 #endif1062 942 1063 943 #ifdef OPT_SCRIPTING … … 1496 1376 conf.menu_symbol_rbf_file[0] = 0; 1497 1377 conf.menu_rbf_file[0] = 0; 1378 conf.charmap_file[0] = 0; 1498 1379 conf_save(); 1499 1380 gui_mbox_init(LANG_INFORMATION, LANG_MENU_RESTART_CAMERA, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); … … 1621 1502 } 1622 1503 gui_splash = (conf.splash_show)?SPLASH_TIME:0; 1623 1504 user_menu_restore(); 1624 1505 gui_lang_init(); 1625 1506 draw_init(); … … 1629 1510 load_from_file( "A/CHDK/badpixel", make_pixel_list ); 1630 1511 load_from_file( "A/CHDK/badpixel.txt", make_pixel_list ); 1631 #ifdef OPT_CURVES1632 // initialize curves, loading files if required by current mode1633 //curve_init_mode(); // @tsv it will be initialize on first load1634 #endif1635 1512 #if ZOOM_OVERRIDE 1636 1513 // reyalp - need to do this in capt_seq … … 1641 1518 1642 1519 //------------------------------------------------------------------- 1643 void gui_modules_menu_load(int arg){ 1644 1645 misc_submenu_items[1].type=MENUITEM_TEXT; 1646 1647 unsigned int argv[] ={ (unsigned int)MODULES_PATH, 1648 (unsigned int)(&misc_submenu_items[1]) 1649 }; 1650 module_run("modmenu.flt", 0, 2,argv, UNLOAD_IF_ERR ); 1651 } 1652 1653 //------------------------------------------------------------------- 1654 #ifdef OPT_CURVES 1655 static void gui_load_curve_selected(const char *fn) { 1656 if (fn) { 1657 // TODO we could sanity check here, but curve_set_type should fail gracefullish 1658 strcpy(conf.curve_file,fn); 1659 if(conf.curve_enable == 1 && libcurves && libcurves->curve_init_mode) 1660 libcurves->curve_init_mode(); 1661 } 1662 } 1663 1664 //------------------------------------------------------------------- 1665 void gui_load_curve(int arg) { 1666 module_fselect_init(LANG_STR_SELECT_CURVE_FILE, conf.curve_file, CURVE_DIR, gui_load_curve_selected); 1667 } 1668 1669 #endif 1670 1520 //void gui_modules_menu_load(){ 1521 // 1522 // misc_submenu_items[1].type=MENUITEM_TEXT; 1523 // 1524 // unsigned int argv[] ={ (unsigned int)MODULES_PATH, 1525 // (unsigned int)(&misc_submenu_items[1]) 1526 // }; 1527 // module_run("modmenu.flt", 0, 2,argv, UNLOAD_IF_ERR ); 1528 //} 1671 1529 1672 1530 //------------------------------------------------------------------- … … 1783 1641 { 1784 1642 --show_md_grid; 1785 md_draw_grid(); 1643 if (module_mdetect_load()) 1644 libmotiondetect->md_draw_grid(); 1786 1645 } 1787 1646 } … … 1961 1820 } 1962 1821 1963 // Menu button handle dfor Menu mode1822 // Menu button handler for Menu mode 1964 1823 void gui_menu_kbd_process_menu_btn() 1965 1824 { 1825 gui_menu_unload_module_menus(); 1966 1826 #ifdef OPTIONS_AUTOSAVE 1967 1827 conf_save_new_settings_if_changed(); … … 2000 1860 flag_gui_enforce_redraw |= GUI_REDRAWFLAG_ERASEGUARD; 2001 1861 //gui_menu_force_redraw(); 2002 //gui_fselect_force_redraw(); //@tsv2003 1862 #ifdef CAM_TOUCHSCREEN_UI 2004 1863 extern int redraw_buttons; … … 2099 1958 gui_set_mode(&defaultGuiHandler); 2100 1959 2101 // Unload all modules which are marked as safe to unload 1960 // Unload all modules which are marked as safe to unload, or loaded for menus 1961 gui_menu_unload_module_menus(); 2102 1962 module_async_unload_allrunned(0); 2103 1963 … … 2450 2310 return; 2451 2311 2452 if (gui_osd_draw_zebra(conf.zebra_draw && gui_get_mode()==GUI_MODE_NONE && 2312 if (conf.zebra_draw) 2313 if (module_zebra_load()) 2314 if (libzebra->gui_osd_draw_zebra(conf.zebra_draw && gui_get_mode()==GUI_MODE_NONE && 2453 2315 kbd_is_key_pressed(KEY_SHOOT_HALF) && mode_photo && 2454 2316 !state_kbd_script_run)) {// no zebra when script running, to save mem 2455 return; // if zebra drawn, we're done2317 return; // if zebra drawn, we're done 2456 2318 } 2457 2319 #if !CAM_SHOW_OSD_IN_SHOOT_MENU … … 2471 2333 2472 2334 if ((m&MODE_MASK) == MODE_REC && (recreview_hold==0 || conf.show_osd_in_review) ) { 2473 if (conf.show_grid_lines) {2474 gui_grid_draw_osd(1);2475 }2335 if (conf.show_grid_lines) 2336 if (module_grids_load()) 2337 libgrids->gui_grid_draw_osd(1); 2476 2338 if ((gui_get_mode()==GUI_MODE_NONE || gui_get_mode()==GUI_MODE_ALT) && (((kbd_is_key_pressed(KEY_SHOOT_HALF) || (state_kbd_script_run) || (shooting_get_common_focus_mode())) && (mode_photo || (m&MODE_SHOOTING_MASK)==MODE_STITCH )) || ((mode_video || movie_status > 1) && conf.show_values_in_video) )) { 2477 2339 … … 2652 2514 2653 2515 //------------------------------------------------------------------- 2654 static void gui_grid_lines_load_selected(const char *fn) {2655 if (fn)2656 grid_lines_load(fn);2657 }2658 void gui_grid_lines_load(int arg) {2659 module_fselect_init(LANG_STR_SELECT_GRID_FILE, conf.grid_lines_file, "A/CHDK/GRIDS", gui_grid_lines_load_selected);2660 }2661 2662 //-------------------------------------------------------------------2663 #ifdef OPT_TEXTREADER2664 static void gui_draw_read_selected(const char *fn) {2665 if (fn) {2666 if (!rbf_load(conf.reader_rbf_file))2667 rbf_load_from_8x16(current_font);2668 rbf_set_codepage(conf.reader_codepage);2669 2670 unsigned int argv[] ={ (unsigned int)fn };2671 module_run("txtread.flt", 0, sizeof(argv)/sizeof(argv[0]), argv, UNLOAD_IF_ERR);2672 }2673 }2674 2675 void gui_draw_read(int arg) {2676 module_fselect_init_w_mode(LANG_STR_SELECT_TEXT_FILE, conf.reader_file, "A/CHDK/BOOKS", gui_draw_read_selected, 1);2677 void gui_fselect_set_key_redraw(int n);2678 //gui_fselect_set_key_redraw(1); @tsv2679 }2680 2681 void gui_draw_read_last(int arg) {2682 struct stat st;2683 if (stat(conf.reader_file,&st) == 0) {2684 gui_draw_read_selected(conf.reader_file);2685 } else {2686 gui_draw_read(arg);2687 }2688 }2689 #endif2690 2691 //-------------------------------------------------------------------2692 2516 void gui_menuproc_mkbootdisk(int arg) { 2693 2517 mark_filesystem_bootable(); … … 2695 2519 } 2696 2520 2697 #ifdef OPT_EDGEOVERLAY2698 static void gui_load_edge_selected( const char* fn ) {2699 if( fn && module_edgeovr_load())2700 libedgeovr->load_edge_overlay(fn);2701 }2702 2703 void gui_menuproc_edge_save(int arg) {2704 if ( module_edgeovr_load() )2705 libedgeovr->save_edge_overlay();2706 }2707 2708 void gui_menuproc_edge_load(int arg) {2709 module_fselect_init(LANG_MENU_EDGE_LOAD, EDGE_SAVE_DIR, EDGE_SAVE_DIR, gui_load_edge_selected);2710 }2711 #endif2712 2713 //-------------------------------------------------------------------2714 #ifdef OPT_TEXTREADER2715 static void gui_draw_rbf_selected(const char *fn) {2716 if (fn) {2717 strcpy(conf.reader_rbf_file, fn);2718 }2719 }2720 void gui_draw_load_rbf(int arg) {2721 module_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.reader_rbf_file, "A/CHDK/FONTS", gui_draw_rbf_selected);2722 }2723 #endif2724 2521 //------------------------------------------------------------------- 2725 2522 static void gui_draw_menu_rbf_selected(const char *fn) { … … 2758 2555 void gui_draw_load_lang(int arg) { 2759 2556 module_fselect_init(LANG_STR_SELECT_LANG_FILE, conf.lang_file, "A/CHDK/LANG", gui_draw_lang_selected); 2557 } 2558 2559 static void gui_charmap_selected(const char *fn) { 2560 if (fn) 2561 strcpy(conf.charmap_file, fn); 2562 } 2563 static void gui_load_charmap(int arg) { 2564 module_fselect_init(LANG_STR_SELECT_CHARMAP_FILE, conf.charmap_file, "A/CHDK", gui_charmap_selected); 2760 2565 } 2761 2566 -
trunk/core/gui_4wins.c
r1527 r1569 12 12 #include "gui_batt.h" 13 13 #include "gui_mbox.h" 14 #include "gui_4wins.h"15 14 16 15 #include "module_load.h" … … 32 31 #define P1_COLOR MAKE_COLOR(COLOR_HISTO_B_PLAY,COLOR_HISTO_B_PLAY) 33 32 #define P2_COLOR MAKE_COLOR(COLOR_HISTO_G_PLAY,COLOR_HISTO_G_PLAY) 34 #define B G_COLOR MAKE_COLOR(COLOR_GREY,COLOR_GREY)33 #define BK_COLOR MAKE_COLOR(COLOR_GREY,COLOR_GREY) 35 34 #define FIELD_COLOR MAKE_COLOR(COLOR_SPLASH_GREY,COLOR_SPLASH_GREY)//(füllfarbe,rand) 36 #define TEXT_COLOR MAKE_COLOR( BG_COLOR, COLOR_WHITE)35 #define TEXT_COLOR MAKE_COLOR(COLOR_GREY, COLOR_WHITE) 37 36 #define INFO_COLOR MAKE_COLOR(COLOR_SPLASH_GREY, COLOR_SPLASH_GREY) 38 37 #define INFO_TEXT_COLOR MAKE_COLOR(INFO_COLOR, COLOR_WHITE) … … 285 284 static void move_cursor(int in_x_pos) 286 285 { 287 draw_filled_ellipse((XBORDER+((cursor_position)*RECT_SIZE))+15, BORDER+10, 10,10,B G_COLOR);286 draw_filled_ellipse((XBORDER+((cursor_position)*RECT_SIZE))+15, BORDER+10, 10,10,BK_COLOR); 288 287 if(in_game) 289 288 { … … 312 311 srand(time(NULL)); 313 312 314 draw_filled_rect(0, 0, camera_screen.width, camera_screen.height, B G_COLOR); // draw backgraund313 draw_filled_rect(0, 0, camera_screen.width, camera_screen.height, BK_COLOR); // draw backgraund 315 314 draw_filled_rect(XBORDER, BORDER+BORDER_TOP, XBORDER+(7*RECT_SIZE), BORDER+(6*RECT_SIZE)+BORDER_TOP, FIELD_COLOR); 316 315 draw_filled_round_rect(camera_screen.ts_button_border+240, 90, camera_screen.ts_button_border+360-BORDER, 240-10, INFO_COLOR); … … 323 322 { 324 323 field[i][j+1]=0; 325 draw_filled_ellipse(XBORDER+(i*RECT_SIZE)+(RECT_SIZE/2), BORDER+(j*RECT_SIZE)+(RECT_SIZE/2)+BORDER_TOP, 10, 10, B G_COLOR);324 draw_filled_ellipse(XBORDER+(i*RECT_SIZE)+(RECT_SIZE/2), BORDER+(j*RECT_SIZE)+(RECT_SIZE/2)+BORDER_TOP, 10, 10, BK_COLOR); 326 325 } 327 326 } -
trunk/core/gui_batt.c
r1355 r1569 70 70 #else 71 71 72 color cl = (perc<=20)?conf.osd_color_warn: (conf.batt_icon_color&0xFF);72 color cl = (perc<=20)?conf.osd_color_warn:FG_COLOR(conf.batt_icon_color); 73 73 74 74 // battery icon -
trunk/core/gui_calendar.c
r1527 r1569 77 77 draw_filled_rect(cal_x-1, cal_y+FONT_HEIGHT+8, cal_x+cal_w, cal_y+cal_h, CALENDAR_COLOR); 78 78 79 draw_filled_rect(cal_x+cal_w-FONT_WIDTH*4*2, cal_y+FONT_HEIGHT+8+1, cal_x+cal_w-1, cal_y+cal_h-1, MAKE_COLOR( ((WEEKEND_COLOR)>>8), ((WEEKEND_COLOR)>>8)));79 draw_filled_rect(cal_x+cal_w-FONT_WIDTH*4*2, cal_y+FONT_HEIGHT+8+1, cal_x+cal_w-1, cal_y+cal_h-1, MAKE_COLOR(BG_COLOR(WEEKEND_COLOR), BG_COLOR(WEEKEND_COLOR))); 80 80 for (x=cal_x+FONT_WIDTH/2, i=0; i<7; x+=FONT_WIDTH*4, ++i) { 81 81 draw_string(x, cal_y+4+FONT_HEIGHT+4+4, lang_str(days[i]), (i<5)?CALENDAR_COLOR:WEEKEND_COLOR); … … 150 150 x = cal_x + (cal_w-FONT_WIDTH*2-FONT_WIDTH*4-FONT_WIDTH*2-i*FONT_WIDTH)/2; 151 151 y = cal_y + 4; 152 draw_filled_rect(cal_x+FONT_WIDTH, y, cal_x+cal_w-FONT_WIDTH-FONT_WIDTH*4-FONT_WIDTH, y+FONT_HEIGHT, MAKE_COLOR( ((TITLE_COLOR)>>8), ((TITLE_COLOR)>>8)));152 draw_filled_rect(cal_x+FONT_WIDTH, y, cal_x+cal_w-FONT_WIDTH-FONT_WIDTH*4-FONT_WIDTH, y+FONT_HEIGHT, MAKE_COLOR(BG_COLOR(TITLE_COLOR), BG_COLOR(TITLE_COLOR))); 153 153 draw_string(x+FONT_WIDTH, y, lang_str(months[cal_month]), TITLE_COLOR); 154 154 -
trunk/core/gui_debug.c
r1527 r1569 11 11 12 12 extern void gui_module_menu_kbd_process(); 13 int *conf_mem_view_addr_init;14 13 15 14 gui_handler GUI_MODE_DEBUG = … … 106 105 else 107 106 gui_debug_draw_values(8, addr); 108 *conf_mem_view_addr_init = (long)addr;107 conf.mem_view_addr_init = (long)addr; 109 108 110 109 if (debug_cont_update==0) debug_to_draw = 0; … … 189 188 // RETURN VALUE: 1 error, 0 ok 190 189 //--------------------------------------------------------- 191 int _module_loader( void** chdk_export_list )190 int _module_loader( unsigned int* chdk_export_list ) 192 191 { 193 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER )192 if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 194 193 return 1; 195 194 … … 198 197 if ( !API_VERSION_MATCH_REQUIREMENT( camera_info.api_version, 1, 0 ) ) 199 198 return 1; 200 201 tConfigVal configVal; 202 CONF_BIND_INT(195, conf_mem_view_addr_init); 199 if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 200 return 1; 203 201 204 202 return 0; … … 228 226 229 227 if ( argn== 0 ) 230 adr =(char*)( *conf_mem_view_addr_init);228 adr =(char*)(conf.mem_view_addr_init); 231 229 else if ( argn ==1) 232 230 adr = (char*)arguments[0]; -
trunk/core/gui_draw.c
r1527 r1569 203 203 register unsigned int x, y; 204 204 205 cl = cl >> 8;205 cl = BG_COLOR(cl); 206 206 for (y=yMin+1; y<=yMax-1; ++y) 207 207 { … … 240 240 for (ii=0; ii<FONT_WIDTH; ii++) 241 241 { 242 draw_pixel(x+ii ,y+i, (sym[i] & (0x80>>ii))? cl&0xff : cl>>8);242 draw_pixel(x+ii ,y+i, (sym[i] & (0x80>>ii))? FG_COLOR(cl) : BG_COLOR(cl)); 243 243 } 244 244 } … … 392 392 long d2xt = 2*b2, d2yt = 2*a2; 393 393 394 color cl_fill = ((cl >> 8) & 0xff) | (cl & 0xff00);394 color cl_fill = MAKE_COLOR(BG_COLOR(cl), BG_COLOR(cl)); 395 395 396 396 if (b == 0) { -
trunk/core/gui_fselect.c
r1527 r1569 17 17 #include "module_load.h" 18 18 19 /* 20 HISTORY: 1.1 - added tbox usage [CHDK 1.1.1 required] 21 */ 22 19 23 void gui_fselect_kbd_process(); 20 24 void gui_fselect_draw(int enforce_redraw); … … 24 28 25 29 extern int module_idx; 26 27 int *conf_sub_batch_prefix;28 int *conf_sub_batch_ext;29 30 30 31 struct librawop_sym* librawop_p; … … 104 105 #define MPOPUP_DELETE 0x0008 105 106 #define MPOPUP_SELINV 0x0010 106 #define MPOPUP_RAW_ADD 0x0020107 #define MPOPUP_RAW_AVERAGE 0x0040108 107 #define MPOPUP_PURGE 0x0080 109 #define MPOPUP_SUBTRACT 0x0100110 #define MPOPUP_RAW_DEVELOP 0x0200111 #define MPOPUP_DNG_TO_CRW 0x0400112 108 #define MPOPUP_EDITOR 0x0800 113 109 #define MPOPUP_CHDK_REPLACE 0x1000 110 111 #define MPOPUP_RAWOPS 0x0020 112 #define MPOPUP_MORE 0x0040 113 114 114 115 115 static struct mpopup_item popup[]= { … … 119 119 { MPOPUP_DELETE, LANG_POPUP_DELETE }, 120 120 { MPOPUP_SELINV, LANG_POPUP_SELINV }, 121 { MPOPUP_PURGE, LANG_POPUP_PURGE }, 122 { MPOPUP_EDITOR, (int)"Edit" }, 123 { MPOPUP_CHDK_REPLACE, (int)"Set this CHDK" }, 124 { MPOPUP_RAWOPS, (int)"Raw ops ->" }, 125 { MPOPUP_MORE, (int)"More -> " }, 126 { 0, 0 }, 127 }; 128 129 #define MPOPUP_RAW_ADD 0x0020 130 #define MPOPUP_RAW_AVERAGE 0x0040 131 #define MPOPUP_SUBTRACT 0x0100 132 #define MPOPUP_RAW_DEVELOP 0x0200 133 #define MPOPUP_DNG_TO_CRW 0x0400 134 135 static struct mpopup_item popup_rawop[]= { 121 136 { MPOPUP_RAW_ADD, LANG_POPUP_RAW_SUM}, 122 137 { MPOPUP_RAW_AVERAGE, LANG_POPUP_RAW_AVERAGE }, 123 138 { MPOPUP_RAW_DEVELOP, LANG_MENU_RAW_DEVELOP }, 124 { MPOPUP_PURGE, LANG_POPUP_PURGE },125 139 { MPOPUP_SUBTRACT, LANG_POPUP_SUB_FROM_MARKED }, 126 140 { MPOPUP_DNG_TO_CRW, (int)"DNG -> CHDK RAW"}, 127 { MPOPUP_EDITOR, (int)"Edit" }, 128 { MPOPUP_CHDK_REPLACE, (int)"Set this CHDK" }, 141 { 0, 0 }, 142 }; 143 144 #define MPOPUP_MKDIR 0x0001 145 #define MPOPUP_RMDIR 0x0002 146 #define MPOPUP_RENAME 0x0004 147 148 static struct mpopup_item popup_more[]= { 149 { MPOPUP_MKDIR, LANG_POPUP_MKDIR }, 150 { MPOPUP_RMDIR, (int)"Remove dir" }, 151 { MPOPUP_RENAME, LANG_POPUP_RENAME }, 129 152 { 0, 0 }, 130 153 }; … … 396 419 gui_fselect_mode_old = gui_set_mode(&GUI_MODE_FSELECT_MODULE); 397 420 gui_fselect_set_key_redraw(0); 398 }399 400 //-------------------------------------------------------------------401 char* gui_fselect_result() {402 if (selected_file[0])403 return selected_file;404 else405 return NULL;406 421 } 407 422 … … 1003 1018 (strcmp(ptr->name,selected->name)) != 0) { 1004 1019 sprintf(raw_subtract_from,"%s/%s",current_dir,ptr->name); 1005 sprintf(raw_subtract_dest,"%s/%s%s",current_dir,img_prefixes[ *conf_sub_batch_prefix],ptr->name+4);1006 strcpy(raw_subtract_dest + strlen(raw_subtract_dest) - 4,img_exts[ *conf_sub_batch_ext]);1020 sprintf(raw_subtract_dest,"%s/%s%s",current_dir,img_prefixes[conf.sub_batch_prefix],ptr->name+4); 1021 strcpy(raw_subtract_dest + strlen(raw_subtract_dest) - 4,img_exts[conf.sub_batch_ext]); 1007 1022 // don't let users attempt to write one of the files being read 1008 1023 if( strcmp(raw_subtract_dest,raw_subtract_from) != 0 && strcmp(raw_subtract_dest,raw_subtract_sub) != 0) { … … 1063 1078 gui_fselect_read_dir(current_dir); 1064 1079 } 1080 1081 1082 1083 static void fselect_mpopup_rawop_cb(unsigned int actn) { 1084 switch (actn) { 1085 case MPOPUP_RAW_AVERAGE: 1086 raw_operation=RAW_OPERATION_AVERAGE; 1087 process_raw_files(); 1088 break; 1089 case MPOPUP_RAW_ADD: 1090 raw_operation=RAW_OPERATION_SUM; 1091 process_raw_files(); 1092 break; 1093 case MPOPUP_RAW_DEVELOP: 1094 sprintf(buf, "%s/%s", current_dir, selected->name); 1095 gui_mbox_init((int)"", LANG_RAW_DEVELOP_MESSAGE, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 1096 raw_prepare_develop(buf); 1097 break; 1098 case MPOPUP_SUBTRACT: 1099 setup_batch_subtract(); 1100 break; 1101 case MPOPUP_DNG_TO_CRW: 1102 process_dng_to_raw_files(); 1103 break; 1104 } 1105 } 1106 1107 static void mkdir_cb(char* name) 1108 { 1109 if (name) { 1110 sprintf(selected_file,"%s/%s",current_dir,name); 1111 mkdir(selected_file); 1112 gui_fselect_read_dir(current_dir); 1113 gui_fselect_redraw = 2; 1114 } 1115 } 1116 1117 static void rename_cb(char* name) 1118 { 1119 if (name) { 1120 char newname[100]; 1121 sprintf(selected_file, "%s/%s", current_dir, selected->name); 1122 sprintf(newname,"%s/%s",current_dir,name); 1123 rename(selected_file,newname); 1124 gui_fselect_read_dir(current_dir); 1125 gui_fselect_redraw = 2; 1126 } 1127 } 1128 1129 static void fselect_mpopup_more_cb(unsigned int actn) { 1130 1131 switch (actn) { 1132 case MPOPUP_MKDIR: 1133 module_tbox_run( LANG_POPUP_MKDIR, LANG_PROMPT_MKDIR, "", 15, mkdir_cb); 1134 break; 1135 case MPOPUP_RMDIR: 1136 gui_mbox_init( LANG_ERROR, (int)"Not implemented yet", MBOX_FUNC_RESTORE|MBOX_TEXT_LEFT, NULL); 1137 break; 1138 case MPOPUP_RENAME: 1139 module_tbox_run( LANG_POPUP_RENAME, LANG_PROMPT_RENAME, selected->name, 15, rename_cb); 1140 break; 1141 } 1142 gui_fselect_redraw = 2; 1143 } 1144 1145 static int mpopup_rawop_flag; 1146 static int mpopup_more_flag; 1065 1147 1066 1148 //------------------------------------------------------------------- … … 1119 1201 case MPOPUP_CANCEL: 1120 1202 break; 1121 case MPOPUP_RAW_AVERAGE: 1122 raw_operation=RAW_OPERATION_AVERAGE; 1123 process_raw_files(); 1124 break; 1125 case MPOPUP_RAW_ADD: 1126 raw_operation=RAW_OPERATION_SUM; 1127 process_raw_files(); 1128 break; 1129 case MPOPUP_RAW_DEVELOP: 1130 sprintf(buf, "%s/%s", current_dir, selected->name); 1131 gui_mbox_init((int)"", LANG_RAW_DEVELOP_MESSAGE, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 1132 raw_prepare_develop(buf); 1203 1204 case MPOPUP_RAWOPS: 1205 module_mpopup_init( popup_rawop, mpopup_rawop_flag, fselect_mpopup_rawop_cb, 0); 1206 break; 1207 1208 case MPOPUP_MORE: 1209 module_mpopup_init( popup_more, mpopup_more_flag, fselect_mpopup_more_cb, 0); 1133 1210 break; 1211 1134 1212 case MPOPUP_CHDK_REPLACE: 1135 1213 gui_mbox_init((int)"Replacing CHDK", (int)"Do you want to replace current CHDK with this file", … … 1138 1216 case MPOPUP_EDITOR: 1139 1217 gui_mbox_init((int)"Editor", (int)"edit", MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 1140 break;1141 case MPOPUP_SUBTRACT:1142 {1143 setup_batch_subtract();1144 break;1145 }1146 case MPOPUP_DNG_TO_CRW:1147 process_dng_to_raw_files();1148 1218 break; 1149 1219 } … … 1224 1294 if (selected && selected->attr != 0xFF) { 1225 1295 i=MPOPUP_CUT|MPOPUP_COPY|MPOPUP_SELINV; 1296 mpopup_rawop_flag=0; 1226 1297 if (fselect_marked_count() > 0) { 1227 1298 i |= MPOPUP_DELETE; 1228 1299 if ( fselect_marked_count()>1 ) 1229 i|=MPOPUP_RAW_ADD|MPOPUP_RAW_AVERAGE;1300 mpopup_rawop_flag |=MPOPUP_RAW_ADD|MPOPUP_RAW_AVERAGE; 1230 1301 // doesn't make sense to subtract from itself! 1231 1302 if( selected->marked == 0 && fselect_real_marked_count() > 0) 1232 i|= MPOPUP_SUBTRACT;1303 mpopup_rawop_flag |= MPOPUP_SUBTRACT; 1233 1304 } 1305 1306 if ( API_VERSION_MATCH_REQUIREMENT( module_tbox_get_version(), 1, 0 ) ) 1307 i |= MPOPUP_MORE; 1308 1234 1309 if (marked_operation == MARKED_OP_CUT || marked_operation == MARKED_OP_COPY) 1235 1310 i |= MPOPUP_PASTE; … … 1239 1314 i |= MPOPUP_PURGE;//Display PURGE RAW function in popup menu 1240 1315 if(selected->size == hook_raw_size()) 1241 i|= MPOPUP_RAW_DEVELOP;1316 mpopup_rawop_flag |= MPOPUP_RAW_DEVELOP; 1242 1317 1243 1318 if ( module_convert_dng_to_chdk_raw(0) ) // if dng module exist 1244 1319 if((fselect_marked_count()>1)||(selected->size > hook_raw_size())) 1245 i|= MPOPUP_DNG_TO_CRW;1320 mpopup_rawop_flag |= MPOPUP_DNG_TO_CRW; 1246 1321 1247 1322 if (selected->name[9] == 'B' && selected->name[10] == 'I' && selected->name[11] == 'N') //If item is DCIM folder 1248 1323 i |= MPOPUP_CHDK_REPLACE; 1324 1325 if ( mpopup_rawop_flag ) 1326 i |= MPOPUP_RAWOPS; 1327 1328 1329 mpopup_more_flag = MPOPUP_MKDIR; 1330 if (selected->attr & DOS_ATTR_DIRECTORY) 1331 mpopup_more_flag |=MPOPUP_RMDIR; 1332 if ( !(selected->name[0] == '.' && selected->name[1] == '.' && selected->name[2] == 0) ) //If item is not UpDir 1333 mpopup_more_flag |=MPOPUP_RENAME; 1249 1334 1250 1335 module_mpopup_init( popup, i, fselect_mpopup_cb, 0); … … 1324 1409 // RETURN VALUE: 1 error, 0 ok 1325 1410 //--------------------------------------------------------- 1326 int _module_loader( void** chdk_export_list )1411 int _module_loader( unsigned int* chdk_export_list ) 1327 1412 { 1328 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER )1413 if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 1329 1414 return 1; 1330 1415 1331 1416 if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) 1332 1417 return 1; 1333 1334 tConfigVal configVal; 1335 CONF_BIND_INT(209, conf_sub_batch_prefix); 1336 CONF_BIND_INT(210, conf_sub_batch_ext); 1418 if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 1419 return 1; 1337 1420 1338 1421 return 0; … … 1392 1475 0, // flag 1393 1476 -LANG_MENU_MISC_FILE_BROWSER, // Module name 1394 1, 0, // Module version1477 1, 1, // Module version 1395 1478 0 1396 1479 }; -
trunk/core/gui_fselect.h
r1527 r1569 3 3 4 4 //------------------------------------------------------------------- 5 extern void gui_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn)); 6 extern char* gui_fselect_result(); 7 extern void gui_fselect_force_redraw(); 8 extern void finalize_fselect(); 5 extern void module_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn)); 6 extern void module_fselect_init_w_mode(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn), unsigned int key_redraw_mode); 9 7 //------------------------------------------------------------------- 10 8 #endif -
trunk/core/gui_grid.c
r1365 r1569 7 7 #include "gui_draw.h" 8 8 #include "gui_grid.h" 9 9 #include "gui_menu.h" 10 #include "gui_lang.h" 11 12 #include "modules.h" 13 #include "module_exportlist.h" 14 15 //------------------------------------------------------------------- 16 17 typedef struct 18 { 19 color grid_color; 20 char grid_lines_file[100]; 21 int grid_force_color; 22 } GridConf; 23 24 GridConf gconf; 25 26 static ConfInfo conf_info[] = { 27 CONF_INFO( 1, gconf.grid_color, CONF_DEF_VALUE, cl:0, NULL), 28 CONF_INFO( 2, gconf.grid_lines_file, CONF_CHAR_PTR, ptr:"", NULL), 29 CONF_INFO( 3, gconf.grid_force_color, CONF_DEF_VALUE, i:0, NULL), 30 }; 10 31 11 32 //------------------------------------------------------------------- … … 143 164 144 165 grid = grid_default; 145 fd = open(fn, O_RDONLY, 0777);166 fd = safe_open(fn, O_RDONLY, 0777); 146 167 if (fd>=0) { 147 168 int rcnt = read(fd, buf, GRID_BUF_SIZE); … … 154 175 } 155 176 close(fd); 156 strcpy( conf.grid_lines_file, fn);177 strcpy(gconf.grid_lines_file, fn); 157 178 } else { 158 conf.grid_lines_file[0] = 0;179 gconf.grid_lines_file[0] = 0; 159 180 } 160 181 … … 174 195 switch (ptr->type) { 175 196 case GRID_ELEM_LINE: 176 draw_line(ptr->x0, ptr->y0, ptr->x1, ptr->y1, ( conf.grid_force_color)?conf.grid_color:ptr->clf);197 draw_line(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (gconf.grid_force_color)?gconf.grid_color:ptr->clf); 177 198 break; 178 199 case GRID_ELEM_RECT: 179 draw_rect(ptr->x0, ptr->y0, ptr->x1, ptr->y1, ( conf.grid_force_color)?conf.grid_color:ptr->clf);200 draw_rect(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (gconf.grid_force_color)?gconf.grid_color:ptr->clf); 180 201 break; 181 202 case GRID_ELEM_FILLED_RECT: 182 draw_filled_rect(ptr->x0, ptr->y0, ptr->x1, ptr->y1, ( conf.grid_force_color)?conf.grid_color:MAKE_COLOR(ptr->clb, ptr->clf));203 draw_filled_rect(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (gconf.grid_force_color)?gconf.grid_color:MAKE_COLOR(ptr->clb, ptr->clf)); 183 204 break; 184 205 case GRID_ELEM_ELLIPSE: 185 draw_ellipse(ptr->x0, ptr->y0, (unsigned int)(ptr->x1), (unsigned int)(ptr->y1), ( conf.grid_force_color)?conf.grid_color:ptr->clf);206 draw_ellipse(ptr->x0, ptr->y0, (unsigned int)(ptr->x1), (unsigned int)(ptr->y1), (gconf.grid_force_color)?gconf.grid_color:ptr->clf); 186 207 break; 187 208 case GRID_ELEM_FILLED_ELLIPSE: 188 draw_filled_ellipse(ptr->x0, ptr->y0, (unsigned int)(ptr->x1), (unsigned int)(ptr->y1), ( conf.grid_force_color)?conf.grid_color:MAKE_COLOR(ptr->clf, 0));209 draw_filled_ellipse(ptr->x0, ptr->y0, (unsigned int)(ptr->x1), (unsigned int)(ptr->y1), (gconf.grid_force_color)?gconf.grid_color:MAKE_COLOR(ptr->clf, 0)); 189 210 break; 190 211 } … … 195 216 196 217 //------------------------------------------------------------------- 218 219 static void gui_grid_lines_load_selected(const char *fn) { 220 if (fn) 221 grid_lines_load(fn); 222 } 223 void gui_grid_lines_load(int arg) { 224 module_fselect_init(LANG_STR_SELECT_GRID_FILE, gconf.grid_lines_file, "A/CHDK/GRIDS", gui_grid_lines_load_selected); 225 } 226 227 static CMenuItem grid_submenu_items[] = { 228 MENU_ITEM(0x2f,LANG_MENU_SHOW_GRID, MENUITEM_BOOL, &conf.show_grid_lines, 0 ), 229 MENU_ITEM(0x35,LANG_MENU_GRID_LOAD, MENUITEM_PROC, gui_grid_lines_load, 0 ), 230 MENU_ITEM(0x0,LANG_MENU_GRID_CURRENT, MENUITEM_SEPARATOR, 0, 0 ), 231 MENU_ITEM(0x0,(int)grid_title, MENUITEM_TEXT, 0, 0 ), 232 MENU_ITEM(0x0,(int)"", MENUITEM_SEPARATOR, 0, 0 ), 233 MENU_ITEM(0x5c,LANG_MENU_GRID_FORCE_COLOR, MENUITEM_BOOL, &gconf.grid_force_color, 0 ), 234 MENU_ITEM(0x65,LANG_MENU_GRID_COLOR_LINE, MENUITEM_COLOR_FG, &gconf.grid_color, 0 ), 235 MENU_ITEM(0x65,LANG_MENU_GRID_COLOR_FILL, MENUITEM_COLOR_BG, &gconf.grid_color, 0 ), 236 MENU_ITEM(0x51,LANG_MENU_BACK, MENUITEM_UP, 0, 0 ), 237 {0} 238 }; 239 static CMenu grid_submenu = {0x2f,LANG_MENU_GRID_TITLE, NULL, grid_submenu_items }; 240 241 // ========= MODULE INIT ================= 242 243 #include "module_load.h" 244 245 246 struct libgrids_sym libgrids = { 247 MAKE_API_VERSION(1,0), // apiver: increase major if incompatible changes made in module, 248 // increase minor if compatible changes made(including extending this struct) 249 gui_grid_draw_osd 250 }; 251 252 int module_idx=-1; 253 254 /***************** BEGIN OF AUXILARY PART ********************* 255 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 256 **************************************************************/ 257 258 void* MODULE_EXPORT_LIST[] = { 259 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 260 /* 1 */ (void*)1, 261 &libgrids 262 }; 263 264 265 //--------------------------------------------------------- 266 // PURPOSE: Bind module symbols with chdk. 267 // Required function 268 // PARAMETERS: pointer to chdk list of export 269 // RETURN VALUE: 1 error, 0 ok 270 //--------------------------------------------------------- 271 int _module_loader( unsigned int* chdk_export_list ) 272 { 273 if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 274 return 1; 275 276 if ( !API_VERSION_MATCH_REQUIREMENT( camera_sensor.api_version, 1, 0 ) ) 277 return 1; 278 if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 279 return 1; 280 281 conf_info[0].cl = MAKE_COLOR(COLOR_BG, COLOR_FG); 282 config_restore(&conf_info[0], "A/CHDK/MODULES/CFG/grids.cfg", sizeof(conf_info)/sizeof(conf_info[0]), 0, 0); 283 284 grid_lines_load(gconf.grid_lines_file); 285 286 return 0; 287 } 288 289 290 291 //--------------------------------------------------------- 292 // PURPOSE: Finalize module operations (close allocs, etc) 293 // RETURN VALUE: 0-ok, 1-fail 294 //--------------------------------------------------------- 295 int _module_unloader() 296 { 297 config_save(&conf_info[0], "A/CHDK/MODULES/CFG/grids.cfg", sizeof(conf_info)/sizeof(conf_info[0])); 298 grid_lines_free_data(); 299 return 0; 300 } 301 302 303 //--------------------------------------------------------- 304 // PURPOSE: Default action for simple modules (direct run) 305 // NOTE: Please comment this function if no default action and this library module 306 //--------------------------------------------------------- 307 int _module_run(int moduleidx, int argn, int* arguments) 308 { 309 module_idx=moduleidx; 310 311 gui_activate_sub_menu(&grid_submenu, module_idx); 312 313 return 0; 314 } 315 316 317 /******************** Module Information structure ******************/ 318 319 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 320 sizeof(struct ModuleInfo), 321 322 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 323 ANY_PLATFORM_ALLOWED, // Specify platform dependency 324 MODULEINFO_FLAG_SYSTEM, // flag 325 (int32_t)"Grids (dll)", // Module name 326 1, 0, // Module version 327 (int32_t)"Grid Display" 328 }; 329 330 331 /*************** END OF AUXILARY PART *******************/ -
trunk/core/gui_grid.h
r515 r1569 2 2 #define GUI_GRID_H 3 3 4 //------------------------------------------------------------------- 5 extern char grid_title[36]; 4 struct libgrids_sym { 5 int version; 6 7 void (*gui_grid_draw_osd)(int force); 8 }; 6 9 7 10 //------------------------------------------------------------------- 8 extern void gui_grid_draw_osd(int force); 9 extern void grid_lines_load(const char *fn); 11 // Defines of exported to chdk symbols 12 #ifdef THIS_IS_CHDK_CORE 13 // This section is for CHDK core 14 extern struct libgrids_sym* libgrids; 15 extern struct libgrids_sym* module_grids_load(); // 0fail, addr-ok 16 #else 17 // This section is for module 18 extern void gui_grid_draw_osd(int force); 19 extern void grid_lines_load(const char *fn); 20 #endif 21 22 extern struct libgrids_sym* module_grids_load(); // 0fail, addr-ok 23 extern void module_grids_unload(); 10 24 11 25 //------------------------------------------------------------------- -
trunk/core/gui_lang.h
r1568 r1569 594 594 #define LANG_MENU_REMOTE_OPTIONS 473 595 595 596 #define LANG_STR_SELECT_CHARMAP_FILE 474 597 #define LANG_MENU_VIS_CHARMAP 475 598 #define LANG_POPUP_MORE 476 599 #define LANG_POPUP_MKDIR 477 600 #define LANG_POPUP_RENAME 478 601 #define LANG_PROMPT_MKDIR 479 602 #define LANG_PROMPT_RENAME 480 603 596 604 //------------------------------------------------------------------- 597 605 598 #define GUI_LANG_ITEMS 4 73606 #define GUI_LANG_ITEMS 480 599 607 600 608 //------------------------------------------------------------------- -
trunk/core/gui_mastermind.c
r1527 r1569 10 10 #include "gui_batt.h" 11 11 #include "gui_mbox.h" 12 #include "gui_mastermind.h"13 12 14 13 #include "module_load.h" … … 25 24 #define RECT_SIZE 10 26 25 #define COLOR_LIGHT_GRAY MAKE_COLOR(COLOR_SPLASH_GREY,COLOR_SPLASH_GREY) 27 #define B G_COLOR MAKE_COLOR(COLOR_GREY,COLOR_GREY)28 #define TEXT_COLOR MAKE_COLOR( BG_COLOR,COLOR_BLACK)26 #define BK_COLOR MAKE_COLOR(COLOR_GREY,COLOR_GREY) 27 #define TEXT_COLOR MAKE_COLOR(COLOR_GREY,COLOR_BLACK) 29 28 30 29 int curr_x; … … 116 115 curr_y=7; 117 116 118 draw_filled_rect( 0, 0, camera_screen.width-1, camera_screen.height-1, B G_COLOR);117 draw_filled_rect( 0, 0, camera_screen.width-1, camera_screen.height-1, BK_COLOR); 119 118 120 119 for (i=0;i<4;i++) … … 122 121 draw_filled_rect(camera_screen.ts_button_border+BORDER+(2*i*10), BORDER+(2*j*10)+2*j, camera_screen.ts_button_border+BORDER+(2*i*10)+10, BORDER+(2*j*10)+2*j+10 , COLOR_LIGHT_GRAY); 123 122 124 draw_filled_rect(camera_screen.ts_button_border+10, BORDER+(2*j*10)+2*j, camera_screen.ts_button_border+150,BORDER+(2*j*10)+2*j+1, MAKE_COLOR( BG_COLOR,COLOR_WHITE));125 draw_filled_rect(camera_screen.ts_button_border+148, 10, camera_screen.ts_button_border+149,230, MAKE_COLOR( BG_COLOR,COLOR_WHITE));126 draw_filled_rect(camera_screen.ts_button_border+151, 10, camera_screen.ts_button_border+152,230, MAKE_COLOR( BG_COLOR,COLOR_WHITE));123 draw_filled_rect(camera_screen.ts_button_border+10, BORDER+(2*j*10)+2*j, camera_screen.ts_button_border+150,BORDER+(2*j*10)+2*j+1, MAKE_COLOR(COLOR_GREY,COLOR_WHITE)); 124 draw_filled_rect(camera_screen.ts_button_border+148, 10, camera_screen.ts_button_border+149,230, MAKE_COLOR(COLOR_GREY,COLOR_WHITE)); 125 draw_filled_rect(camera_screen.ts_button_border+151, 10, camera_screen.ts_button_border+152,230, MAKE_COLOR(COLOR_GREY,COLOR_WHITE)); 127 126 128 127 for (i=0; i<6;i++) … … 233 232 static struct tm *ttm; 234 233 235 draw_txt_string(camera_screen.ts_button_border/FONT_WIDTH+15, 0, lang_str(LANG_MENU_GAMES_MASTERMIND), MAKE_COLOR( BG_COLOR, COLOR_WHITE));234 draw_txt_string(camera_screen.ts_button_border/FONT_WIDTH+15, 0, lang_str(LANG_MENU_GAMES_MASTERMIND), MAKE_COLOR(COLOR_GREY, COLOR_WHITE)); 236 235 237 236 t = time(NULL); -
trunk/core/gui_menu.c
r1527 r1569 9 9 #include "gui_draw.h" 10 10 #include "modules.h" 11 #include "module_load.h" 11 12 #include "gui_menu.h" 12 13 #include "gui_lang.h" … … 20 21 int curpos; 21 22 int toppos; 23 int module_idx; 22 24 } CMenuStacked; 23 25 … … 46 48 47 49 //------------------------------------------------------------------- 50 // Unload any module based sub-menus 51 void gui_menu_unload_module_menus() 52 { 53 // Unload any module menus 54 while (gui_menu_stack_ptr > 0) 55 { 56 gui_menu_stack_ptr--; 57 if (gui_menu_stack[gui_menu_stack_ptr].module_idx >= 0) 58 module_unload_idx(gui_menu_stack[gui_menu_stack_ptr].module_idx); 59 } 60 } 61 62 //------------------------------------------------------------------- 48 63 void gui_menu_init(CMenu *menu_ptr) { 49 64 50 static char first_call=1;51 52 65 if (menu_ptr) { 53 if ( first_call ) {54 extern void gui_modules_menu_load();55 extern void user_menu_restore();56 57 gui_modules_menu_load();58 user_menu_restore();59 first_call=0;60 }61 62 66 if (conf.menu_select_first_entry) 63 67 gui_menu_set_curr_menu(menu_ptr, 0, 0); … … 105 109 static void gui_menu_color_selected(color clr) 106 110 { 107 *item_color = (unsigned char)(clr&0xFF);111 *item_color = FG_COLOR(clr); 108 112 gui_menu_erase_and_redraw(); 109 113 } … … 115 119 { 116 120 gui_menu_stack_ptr--; 121 if (gui_menu_stack[gui_menu_stack_ptr].module_idx >= 0) 122 module_unload_idx(gui_menu_stack[gui_menu_stack_ptr].module_idx); 117 123 gui_menu_set_curr_menu(gui_menu_stack[gui_menu_stack_ptr].menu, gui_menu_stack[gui_menu_stack_ptr].toppos, gui_menu_stack[gui_menu_stack_ptr].curpos); 118 124 gui_menu_erase_and_redraw(); … … 306 312 307 313 // Open a sub-menu 308 static void select_sub_menu()314 void gui_activate_sub_menu(CMenu *sub_menu, int module_idx) 309 315 { 310 316 // push current menu on stack … … 312 318 gui_menu_stack[gui_menu_stack_ptr].curpos = gui_menu_curr_item; 313 319 gui_menu_stack[gui_menu_stack_ptr].toppos = gui_menu_top_item; 320 gui_menu_stack[gui_menu_stack_ptr].module_idx = module_idx; 314 321 315 322 // Select first item in menu, (or none) 316 323 if (conf.menu_select_first_entry) 317 324 { 318 gui_menu_set_curr_menu( (CMenu*)(curr_menu->menu[gui_menu_curr_item].value), 0, 0);325 gui_menu_set_curr_menu(sub_menu, 0, 0); 319 326 if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_TEXT || (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_SEPARATOR) 320 327 { … … 324 331 } 325 332 else 326 gui_menu_set_curr_menu( (CMenu*)(curr_menu->menu[gui_menu_curr_item].value), 0, -1);333 gui_menu_set_curr_menu(sub_menu, 0, -1); 327 334 328 335 gui_menu_stack_ptr++; … … 337 344 // Force full redraw 338 345 gui_menu_erase_and_redraw(); 346 } 347 348 // Open a sub-menu 349 static void select_sub_menu() 350 { 351 gui_activate_sub_menu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), -1); 339 352 } 340 353 … … 505 518 update_bool_value(); 506 519 break; 520 case MENUITEM_SUBMENU_PROC: 507 521 case MENUITEM_PROC: 508 522 if (curr_menu->menu[gui_menu_curr_item].value) … … 526 540 case MENUITEM_COLOR_BG: 527 541 item_color=((unsigned char*)(curr_menu->menu[gui_menu_curr_item].value)) + (((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?1:0); 528 module_palette_run(PALETTE_MODE_SELECT, (*item_color)&0xFF, gui_menu_color_selected);542 module_palette_run(PALETTE_MODE_SELECT, FG_COLOR(*item_color), gui_menu_color_selected); 529 543 gui_menu_redraw=2; 530 544 break; … … 608 622 // Draw menu scroll bar if needed, and title bar 609 623 void gui_menu_draw_initial() { 610 color cl =conf.menu_title_color>>8;624 color cl = BG_COLOR(conf.menu_title_color); 611 625 612 626 count = gui_menu_rows(); … … 617 631 wplus = 8; 618 632 // scrollbar background 619 draw_filled_rect((x+w), y, (x+w)+wplus, y+num_lines*rbf_font_height()-1, MAKE_COLOR( (conf.menu_color>>8)&0xFF, (conf.menu_color>>8)&0xFF));633 draw_filled_rect((x+w), y, (x+w)+wplus, y+num_lines*rbf_font_height()-1, MAKE_COLOR(BG_COLOR(conf.menu_color), BG_COLOR(conf.menu_color))); 620 634 } 621 635 else … … 708 722 * when the cursor highlights a line. 709 723 */ 710 cl_symbol = (gui_menu_curr_item==imenu)?MAKE_COLOR( (cl>>8)&0xFF,(conf.menu_symbol_color)&0xFF):conf.menu_symbol_color; //color 8Bit=Hintergrund 8Bit=Vordergrund724 cl_symbol = (gui_menu_curr_item==imenu)?MAKE_COLOR(BG_COLOR(cl),FG_COLOR(conf.menu_symbol_color)):conf.menu_symbol_color; //color 8Bit=Hintergrund 8Bit=Vordergrund 711 725 712 726 xx = x; … … 721 735 gui_menu_draw_value(tbuf, len_int); 722 736 break; 737 case MENUITEM_SUBMENU_PROC: 723 738 case MENUITEM_SUBMENU: 724 739 sprintf(tbuf, "%s%s", lang_str(curr_menu->menu[imenu].text),(conf.menu_symbol_enable)?"":" ->"); … … 746 761 if (xx > (x + len_space)) 747 762 { 748 draw_filled_rect(x+len_space, yy, xx-1, yy+rbf_font_height()/2-1, MAKE_COLOR( cl>>8, cl>>8));763 draw_filled_rect(x+len_space, yy, xx-1, yy+rbf_font_height()/2-1, MAKE_COLOR(BG_COLOR(cl), BG_COLOR(cl))); 749 764 draw_line(x+len_space, yy+rbf_font_height()/2, xx-1, yy+rbf_font_height()/2, cl); 750 draw_filled_rect(x+len_space, yy+rbf_font_height()/2+1, xx-1, yy+rbf_font_height()-1, MAKE_COLOR( cl>>8, cl>>8));765 draw_filled_rect(x+len_space, yy+rbf_font_height()/2+1, xx-1, yy+rbf_font_height()-1, MAKE_COLOR(BG_COLOR(cl), BG_COLOR(cl))); 751 766 } 752 767 else … … 759 774 if (xx < (x+w-len_space)) 760 775 { 761 draw_filled_rect(xx, yy, x+w-len_space-1, yy+rbf_font_height()/2-1, MAKE_COLOR( cl>>8, cl>>8));776 draw_filled_rect(xx, yy, x+w-len_space-1, yy+rbf_font_height()/2-1, MAKE_COLOR(BG_COLOR(cl), BG_COLOR(cl))); 762 777 draw_line(xx, yy+rbf_font_height()/2, x+w-1-len_space, yy+rbf_font_height()/2, cl); 763 draw_filled_rect(xx, yy+rbf_font_height()/2+1, x+w-len_space-1, yy+rbf_font_height()-1, MAKE_COLOR( cl>>8, cl>>8));778 draw_filled_rect(xx, yy+rbf_font_height()/2+1, x+w-len_space-1, yy+rbf_font_height()-1, MAKE_COLOR(BG_COLOR(cl), BG_COLOR(cl))); 764 779 } 765 780 … … 771 786 xx+=rbf_draw_string_len(xx, yy, w-len_space-symbol_width, lang_str(curr_menu->menu[imenu].text), cl); 772 787 draw_filled_round_rect(x+w-1-cl_rect-2-len_space, yy+2, x+w-1-2-len_space, yy+rbf_font_height()-1-2, 773 MAKE_COLOR(((*(curr_menu->menu[imenu].value))>>(((curr_menu->menu[imenu].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)? 8:0))&0xFF,774 ((*(curr_menu->menu[imenu].value))>>(((curr_menu->menu[imenu].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)? 8:0))&0xFF));788 MAKE_COLOR(((*(curr_menu->menu[imenu].value))>>(((curr_menu->menu[imenu].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?16:0))&0xFFFF, 789 ((*(curr_menu->menu[imenu].value))>>(((curr_menu->menu[imenu].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?16:0))&0xFFFF)); 775 790 break; 776 791 case MENUITEM_ENUM: -
trunk/core/gui_menu.h
r1505 r1569 15 15 #define MENUITEM_COLOR_FG 10 16 16 #define MENUITEM_ENUM2 11 17 #define MENUITEM_SUBMENU_PROC 12 17 18 18 19 // Flags, which describe limits of F_INT value … … 63 64 extern void gui_menu_init(CMenu *menu_ptr); 64 65 extern void gui_menu_kbd_process(); 66 extern void gui_menu_kbd_process_menu_btn(); 65 67 extern void gui_menu_draw(int enforce_redraw); 66 68 extern void mod_user_menu(CMenuItem curr_menu_item, int* gui_menu_add_item, int mod); 67 69 extern void gui_menu_force_redraw(); 70 extern void gui_activate_sub_menu(CMenu *sub_menu, int module_idx); 71 extern void gui_menu_unload_module_menus(); 68 72 //------------------------------------------------------------------- 69 73 -
trunk/core/gui_mpopup.c
r1527 r1569 13 13 extern int module_idx; 14 14 15 /* 16 History: 1.1 - make possible call next mpopup in callback [multilevel mpopups] 17 */ 18 15 19 void gui_mpopup_kbd_process(); 16 20 void gui_mpopup_draw(int enforce_redraw); … … 34 38 static coord mpopup_actions_x, mpopup_actions_y; // top-left coord of window 35 39 static unsigned int mpopup_actions_w; // width of window 36 static void (*mpopup_on_select)(unsigned int btn); 40 41 typedef void (*mpopup_on_select_t)(unsigned int btn); 42 static mpopup_on_select_t mpopup_on_select; 37 43 38 44 //------------------------------------------------------------------- … … 112 118 { 113 119 gui_set_mode(gui_mpopup_mode_old); 114 if (mpopup_on_select) 115 mpopup_on_select(action); 120 121 mpopup_on_select_t on_select = mpopup_on_select; // this could be reinited in callback 122 116 123 mpopup_on_select=0; 124 if (on_select) 125 on_select(action); 117 126 } 118 127 … … 136 145 kbd_reset_autoclicked_key(); 137 146 exit_mpopup(MPOPUP_CANCEL); 147 if ( mpopup_on_select==0 ) // exit if not re-inited 138 148 module_async_unload(module_idx); 139 149 break; … … 141 151 kbd_reset_autoclicked_key(); 142 152 exit_mpopup(actions[mpopup_actions[mpopup_actions_active]].flag); 153 if ( mpopup_on_select==0 ) // exit if not re-inited 143 154 module_async_unload(module_idx); 144 155 break; … … 168 179 // RETURN VALUE: 1 error, 0 ok 169 180 //--------------------------------------------------------- 170 int _module_loader( void** chdk_export_list )171 { 172 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER )181 int _module_loader( unsigned int* chdk_export_list ) 182 { 183 if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 173 184 return 1; 174 185 … … 231 242 MODULEINFO_FLAG_SYSTEM, // flag 232 243 (int32_t)"Popup menu module", // Module name 233 1, 0, // Module version244 1, 1, // Module version 234 245 0 235 246 }; -
trunk/core/gui_mpopup.h
r1527 r1569 12 12 13 13 //------------------------------------------------------------------- 14 extern void gui_mpopup_init(struct mpopup_item* popup_actions, const unsigned int flags, void (*on_select)(unsigned int actn), int mode);14 extern void module_mpopup_init(struct mpopup_item* popup_actions, const unsigned int flags, void (*on_select)(unsigned int actn), int mode); 15 15 16 16 //------------------------------------------------------------------- -
trunk/core/gui_osd.c
r1527 r1569 15 15 #include "gui_grid.h" 16 16 #include "gui_osd.h" 17 #include "modules.h" 17 18 18 19 //------------------------------------------------------------------- … … 60 61 static int step; 61 62 62 63 #if defined (CAM_ZEBRA_NOBUF) && !defined(CAM_ZEBRA_ASPECT_ADJUST)64 // old sx20 #ifdefs were roughly equivalent of both65 #error "defined (CAM_ZEBRA_NOBUF) && !defined(CAM_ZEBRA_ASPECT_ADJUST). Remove this if you've verified it will work!"66 #endif67 68 #ifdef CAM_ZEBRA_ASPECT_ADJUST69 // TODO should just not save anything at all instead of 1 px. Also, this shouldn't be tied to aspect correct70 #define ZEBRA_CANONOSD_BORDER_RESTORE 171 #define ZFIX_TOP 172 #define ZFIX_BOTTOM 173 #else74 // Width (in pixels) of half-shoot Canon OSD area of the screen buffer, for restore during75 // Zebra draw, to limit RAM usage of zebra. Only these border areas are stored in RAM.76 // Only top and bottom are restored, not left&right.77 #define ZEBRA_CANONOSD_BORDER_RESTORE 178 #define ZFIX_TOP 2979 #define ZFIX_BOTTOM 3080 #endif81 82 static unsigned char *img_buf, *scr_buf;83 #if ZEBRA_CANONOSD_BORDER_RESTORE84 static unsigned char *cur_buf_top, *cur_buf_bot;85 #else86 static unsigned char *cur_buf;87 #endif88 static int cur_buf_size;89 static int timer = 0;90 static unsigned char *buf = NULL;91 92 #ifdef CAM_ZEBRA_ASPECT_ADJUST93 static int buffer_size;94 #endif95 96 63 static DOF_TYPE dof; 97 64 static EXPO_TYPE expo; … … 191 158 static void gui_osd_draw_single_histo(int hist, coord x, coord y, int small) { 192 159 register unsigned int i, v, threshold; 193 register color cl, cl_over, cl_bg =conf.histo_color>>8;160 register color cl, cl_over, cl_bg = BG_COLOR(conf.histo_color); 194 161 coord w=HISTO_WIDTH, h=HISTO_HEIGHT; 195 162 … … 218 185 for (v=1; v<h-1; ++v) 219 186 draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl:cl_bg); 220 cl_over = (threshold==h && conf.show_overexp)? conf.histo_color2>>8:cl;187 cl_over = (threshold==h && conf.show_overexp)?BG_COLOR(conf.histo_color2):cl; 221 188 for (; v<h; ++v) 222 189 draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl_over:cl_bg); … … 228 195 for (v=1; v<h-3; ++v) 229 196 draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl:cl_bg); 230 cl_over = (threshold==h && conf.show_overexp)? conf.histo_color2>>8:cl;197 cl_over = (threshold==h && conf.show_overexp)?BG_COLOR(conf.histo_color2):cl; 231 198 for (; v<h; ++v) 232 199 draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl_over:cl_bg); … … 234 201 } 235 202 236 draw_rect(x, y, x+1+w, y+h, conf.histo_color2&0xFF);203 draw_rect(x, y, x+1+w, y+h, FG_COLOR(conf.histo_color2)); 237 204 //Vertical Lines 238 if (conf.histo_show_ev_grid) for (i=1;i<=4;i++) draw_line(x+(1+w)*i/5, y, x+(1+w)*i/5, y+h, conf.histo_color2&0xFF); 239 } 240 241 //------------------------------------------------------------------- 242 // free and NULL zebra buffers. free(NULL) is always OK. 243 static void gui_osd_zebra_free() { 244 #if !defined (CAM_ZEBRA_NOBUF) 245 free(buf); 246 #endif 247 buf=NULL; 248 #if ZEBRA_CANONOSD_BORDER_RESTORE 249 free(cur_buf_top); 250 cur_buf_top=NULL; 251 free(cur_buf_bot); 252 cur_buf_bot=NULL; 253 #else 254 free(cur_buf); 255 cur_buf=NULL; 256 #endif 257 } 258 // prepare zebra resources, or free them 259 // returns 1 if zebra should be drawn 260 static int gui_osd_zebra_init(int show) { 261 unsigned i; 262 263 if(show) 264 { 265 if (!buf) 266 { 267 timer = 0; 268 #if defined (CAM_ZEBRA_NOBUF) 269 buffer_size=camera_screen.buffer_size-ZEBRA_HMARGIN0*camera_screen.buffer_width; 270 buf=vid_get_bitmap_fb(); 271 #elif defined (CAM_ZEBRA_ASPECT_ADJUST) 272 buffer_size=camera_screen.buffer_size-ZEBRA_HMARGIN0*camera_screen.buffer_width; 273 buf = malloc(buffer_size); 274 //~ if (!buf) draw_txt_string(0, 14, "Warn: No space to allocate zebra buffer: restart camera", MAKE_COLOR(COLOR_ALT_BG, COLOR_FG)); 275 if (!buf) 276 buf=vid_get_bitmap_fb(); //without new buffer: directly into screen buffer: we got some flickering in OSD and histogram but it's usable 277 //~ msleep(50); 278 #else 279 buf = malloc(camera_screen.buffer_size); 280 #endif 281 scr_buf = vid_get_bitmap_fb(); 282 #if ZEBRA_CANONOSD_BORDER_RESTORE 283 cur_buf_top = malloc(camera_screen.buffer_width * ZFIX_TOP); 284 cur_buf_bot = malloc(camera_screen.buffer_width * ZFIX_BOTTOM); 285 #if defined (CAM_ZEBRA_ASPECT_ADJUST) 286 if (cur_buf_top) memset(cur_buf_top,0,camera_screen.buffer_width * ZFIX_TOP); 287 if (cur_buf_bot) memset(cur_buf_bot,0,camera_screen.buffer_width * ZFIX_BOTTOM); 288 #endif 289 #else 290 cur_buf = malloc(camera_screen.buffer_size); 291 #endif 292 // cleanup and disable zebra if any mallocs failed 293 if(!buf || 294 #if ZEBRA_CANONOSD_BORDER_RESTORE 295 !cur_buf_top || 296 !cur_buf_bot 297 #else 298 !cur_buf 299 #endif 300 ) { 301 gui_osd_zebra_free(); 302 } 303 #if CAM_HAS_VARIABLE_ASPECT 304 else // in variable aspect, the borders would never be cleared 305 memset(buf,0,camera_screen.buffer_size); 306 #endif 307 } 308 } 309 else { 310 if(buf) // if zebra was previously on, restore 311 draw_restore(); 312 313 gui_osd_zebra_free(); 314 } 315 return (buf != NULL); 316 } 317 318 //------------------------------------------------------------------- 319 static void draw_pixel_buffered(unsigned int offset, color cl) { 320 // shouldn't this be checked on all cams ? 321 #if defined CAM_ZEBRA_ASPECT_ADJUST 322 if (offset < buffer_size) 323 buf[offset] = cl; 324 #else 325 buf[offset] = cl; 326 #endif 327 } 328 329 //------------------------------------------------------------------- 330 int draw_guard_pixel() { 331 unsigned char* buffer1 = vid_get_bitmap_fb()+camera_screen.buffer_size/2; 332 unsigned char* buffer2 = buffer1+camera_screen.buffer_size; 333 int has_disappeared=0; 334 335 if(*buffer1!=COLOR_GREEN) has_disappeared=1; 336 if(*buffer2!=COLOR_GREEN) has_disappeared=2; 337 *buffer1 = *buffer2 = COLOR_GREEN; 338 return has_disappeared; 339 } 340 341 //------------------------------------------------------------------- 342 #if ZEBRA_CANONOSD_BORDER_RESTORE 343 unsigned char get_cur_buf(unsigned int idx) { 344 unsigned int a; 345 346 a=camera_screen.buffer_size - camera_screen.buffer_width * ZFIX_BOTTOM; 347 348 if (idx < camera_screen.buffer_width * ZFIX_TOP) return(cur_buf_top[idx]); 349 if (idx >= a && idx < camera_screen.buffer_size) return(cur_buf_bot[idx - a]); 350 return (COLOR_TRANSPARENT); 351 } 352 #endif 353 //------------------------------------------------------------------- 354 static void gui_osd_draw_zebra_osd() { 355 switch (conf.zebra_draw_osd) { 356 case ZEBRA_DRAW_NONE: 357 break; 358 case ZEBRA_DRAW_OSD: 359 if (conf.show_osd) { 360 draw_set_draw_proc(draw_pixel_buffered); 361 if ((mode_get()&MODE_MASK) == MODE_REC) { 362 if (conf.show_dof != DOF_DONT_SHOW) gui_osd_calc_dof(); 363 if (conf.show_grid_lines) { 364 gui_grid_draw_osd(1); 365 } 366 if (conf.show_dof == DOF_SHOW_IN_DOF) { 367 gui_osd_draw_dof(); 368 } 369 if (conf.show_state) { 370 gui_osd_draw_state(); 371 } 372 if (conf.show_remaining_raw) { 373 gui_osd_draw_raw_info(); 374 } 375 if (conf.show_values) { 376 gui_osd_draw_values(); 377 } 378 } 379 gui_batt_draw_osd(); 380 gui_space_draw_osd(); 381 if (conf.show_clock) { 382 gui_osd_draw_clock(0,0,0); 383 } 384 if (conf.show_temp>0) { 385 gui_osd_draw_temp(); 386 } 387 draw_set_draw_proc(NULL); 388 } 389 /* no break here */ 390 case ZEBRA_DRAW_HISTO: 391 default: 392 if (conf.show_histo) { 393 draw_set_draw_proc(draw_pixel_buffered); 394 gui_osd_draw_histo(); 395 draw_set_draw_proc(NULL); 396 } 397 break; 398 } 399 } 400 401 // reyalp - TODO this should be rewritten so there is one generic zebra func for all cameras 402 #if defined(CAM_ZEBRA_ASPECT_ADJUST) 403 //nandoide sept-2009 404 // viewport is 360x240 and screen buffer 960x270, we need to expand the x coordinate 405 //reyalp - applies to other cameras where the real bitmap width is is different from what lib.c reports. Also used on some other cameras ... 406 int gui_osd_draw_zebra(int show) { 407 unsigned int v, s, x, y, f, over; 408 color cl_under=conf.zebra_color>>8, cl_over=conf.zebra_color&0xFF; 409 static int need_restore=0; 410 int viewport_height; 411 int viewport_width; 412 int viewport_image_offset; // for when viewport memory buffer is wider than viewport 413 int viewport_row_offset; // for when viewport memory buffer is wider than viewport 414 int viewport_xoffset; // used when image size != viewport size 415 int viewport_yoffset; // used when image size != viewport size 416 int mrec = ((mode_get()&MODE_MASK) == MODE_REC); 417 int zebra_drawn=0; 418 color cls[] = { 419 COLOR_TRANSPARENT, 420 (mrec)?COLOR_HISTO_B:COLOR_HISTO_B_PLAY, 421 (mrec)?COLOR_HISTO_G:COLOR_HISTO_G_PLAY, 422 (mrec)?COLOR_HISTO_BG:COLOR_HISTO_BG_PLAY, 423 (mrec)?COLOR_HISTO_R:COLOR_HISTO_R_PLAY, 424 (mrec)?COLOR_HISTO_RB:COLOR_HISTO_RB_PLAY, 425 (mrec)?COLOR_HISTO_RG:COLOR_HISTO_RG_PLAY, 426 COLOR_BLACK 427 }; 428 429 if (!gui_osd_zebra_init(show)) 430 return 0; 431 432 if(timer==0) { 433 draw_guard_pixel(); 434 timer=1; 435 return 0; 436 } 437 if(timer==1) { 438 int ready; 439 static int n=0; 440 if (!mrec) ready=1; 441 else get_property_case(PROPCASE_SHOOTING, &ready, 4); 442 n=draw_guard_pixel(); // will be 0 in PLAY mode, should be 1 or 2 in REC mode. 443 if(!ready) return 0; 444 } 445 ++timer; 446 // Try to get the best viewport buffer. In playmode its the _d one, in 447 // record mode we try to get the fast live one first 448 if (!mrec) { 449 img_buf = vid_get_viewport_fb_d(); 450 } 451 else { 452 img_buf = vid_get_viewport_live_fb(); 453 if( !img_buf ) { 454 img_buf = vid_get_viewport_fb(); 455 } 456 } 457 viewport_height = vid_get_viewport_height(); 458 viewport_width = vid_get_viewport_width(); 459 viewport_image_offset = vid_get_viewport_image_offset(); 460 viewport_row_offset = vid_get_viewport_row_offset(); 461 viewport_xoffset = vid_get_viewport_xoffset(); 462 viewport_yoffset = vid_get_viewport_yoffset(); 463 switch (conf.zebra_mode) { 464 case ZEBRA_MODE_ZEBRA_1: 465 f = 4; 466 break; 467 case ZEBRA_MODE_ZEBRA_2: 468 f = 8; 469 break; 470 case ZEBRA_MODE_SOLID: 471 f = 1; 472 break; 473 case ZEBRA_MODE_BLINKED_1: 474 f = timer&1; 475 break; 476 case ZEBRA_MODE_BLINKED_3: 477 f = timer&4; 478 break; 479 case ZEBRA_MODE_BLINKED_2: 480 default: 481 f = timer&2; 482 break; 483 } 484 // if not in no-zebra phase of blink mode zebra, draw zebra to buf[] 485 if (f) { 486 if (viewport_yoffset > 0) { // clear top & bottom areas of buffer if image height if smaller than viewport 487 memset(buf, COLOR_TRANSPARENT, viewport_yoffset*camera_screen.buffer_width); 488 memset(buf+(viewport_yoffset+viewport_height)*camera_screen.buffer_width, COLOR_TRANSPARENT, viewport_yoffset*camera_screen.buffer_width); 489 } 490 int step_x, step_v, sy, sx; 491 over = 255-conf.zebra_over; 492 if (conf.zebra_multichannel) {step_x=2; step_v=6;} else {step_x=1; step_v=3;} 493 for (y=viewport_yoffset, v=viewport_image_offset; y<viewport_yoffset+viewport_height; ++y) { 494 sy=y*camera_screen.buffer_width; 495 sx=viewport_xoffset; 496 if (viewport_xoffset > 0) { // clear left & right areas of buffer if image width if smaller than viewport 497 memset(buf+sy, COLOR_TRANSPARENT, sx*2); 498 memset(buf+sy+(sx+viewport_width)*2, COLOR_TRANSPARENT, sx*2); 499 } 500 for (x=viewport_xoffset; x<viewport_xoffset+viewport_width; x+=step_x, sx+=step_x, v+=step_v) { 501 register int yy, uu, vv; 502 int sel; 503 yy = img_buf[v+1]; 504 s=sy+sx*2; 505 if (conf.zebra_multichannel) { 506 uu = (signed char)img_buf[v]; 507 vv = (signed char)img_buf[v+2]; 508 sel=0; 509 if (!((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) { 510 if (clip8(((yy<<12) + vv*5743 + 2048)>>12)>over) sel = 4; // R 511 if (clip8(((yy<<12) - uu*1411 - vv*2925 + 2048)>>12)>over) sel |= 2; // G 512 if (clip8(((yy<<12) + uu*7258 + 2048)>>12)>over) sel |= 1; // B 513 } 514 buf[s]=buf[s+1]=cls[sel]; 515 buf[s+2]=buf[s+3]=cls[sel]; 516 } 517 else if (((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) buf[s]=buf[s+1]=COLOR_TRANSPARENT; 518 else buf[s]=buf[s+1]=(yy>over)?cl_over:(yy<conf.zebra_under)?cl_under:COLOR_TRANSPARENT; 519 if (buf[s] != COLOR_TRANSPARENT && !zebra_drawn) zebra_drawn = 1; 520 #if ZEBRA_CANONOSD_BORDER_RESTORE 521 if(get_cur_buf(s)!=COLOR_TRANSPARENT) buf[s]=get_cur_buf(s); 522 if(conf.zebra_multichannel && get_cur_buf(s+1)!=COLOR_TRANSPARENT) buf[s+1]=get_cur_buf(s+1); 523 #else 524 if(cur_buf[s]!=COLOR_TRANSPARENT) buf[s]=cur_buf[s]; 525 if(conf.zebra_multichannel && cur_buf[s+1]!=COLOR_TRANSPARENT) buf[s+1]=cur_buf[s+1]; 526 #endif 527 528 if (mrec) { 529 } 530 } 531 // adjust for cases where buffer is wider than viewport (e.g. on G12) 532 v += viewport_row_offset; 533 } 534 if (!zebra_drawn) f=0; 535 } 536 // if blink mode is in no-zebra phase OR if there was no over/underexposed pixels to draw zebra on 537 if (!f) { 538 // if zebra was drawn during previous call of this function 539 if (need_restore) { 540 if (conf.zebra_restore_screen || conf.zebra_restore_osd) { 541 draw_restore(); 542 } else { // clear buf[] of zebra, only leave Canon OSD 543 if (mrec) { // REC mode 544 //~ #if ZEBRA_CANONOSD_BORDER_RESTORE 545 //~ // copy rescued Canon OSD to buf[] top/bottom parts and fill center with transparent color: 546 //~ memcpy(buf, cur_buf_top, camera_screen.buffer_width * ZFIX_TOP); 547 //~ memcpy(buf + camera_screen.buffer_size - camera_screen.buffer_width * ZFIX_BOTTOM, cur_buf_bot, camera_screen.buffer_width * ZFIX_BOTTOM); 548 //~ for (s = camera_screen.buffer_width*ZFIX_TOP; s < camera_screen.buffer_size-camera_screen.buffer_width*ZFIX_BOTTOM; s++) { 549 //~ buf[s]=COLOR_TRANSPARENT; 550 //~ } 551 //~ #else 552 //~ // copy from a complete Canon OSD rescue screen dump 553 //~ memcpy(buf, cur_buf, camera_screen.buffer_size); 554 //~ #endif 555 } else { // Not REC mode 556 // No Canon OSD restore, fill buf[] with transparent color: 557 memset(buf, COLOR_TRANSPARENT, buffer_size); 558 } 559 // draw CHDK osd and histogram to buf[] (if enabled in config) 560 gui_osd_draw_zebra_osd(); 561 // copy buf[] to both display buffers 562 563 if (buf!=scr_buf) 564 memcpy(scr_buf, buf, buffer_size); 565 memcpy(scr_buf+camera_screen.buffer_size, buf, buffer_size); 566 } 567 need_restore=0; 568 } 569 return !(conf.zebra_restore_screen && conf.zebra_restore_osd); 570 // if zebra was drawn 571 } else { 572 // draw CHDK osd and histogram to buf[] over zebra (if enabled in config) 573 gui_osd_draw_zebra_osd(); 574 // copy buf[] to both display buffers 575 if (buf!=scr_buf) 576 memcpy(scr_buf, buf, buffer_size); 577 memcpy(scr_buf+camera_screen.buffer_size, buf, buffer_size); 578 579 need_restore=1; 580 return 1; 581 } 582 return 0; 583 } 584 #else 585 //------------------------------------------------------------------- 586 int gui_osd_draw_zebra(int show) { 587 unsigned int v, s, x, y, f, over; 588 color cl_under=conf.zebra_color>>8, cl_over=conf.zebra_color&0xFF; 589 static int need_restore=0; 590 int viewport_height; 591 int mrec = ((mode_get()&MODE_MASK) == MODE_REC); 592 int zebra_drawn=0; 593 color cls[] = { 594 COLOR_TRANSPARENT, 595 (mrec)?COLOR_HISTO_B:COLOR_HISTO_B_PLAY, 596 (mrec)?COLOR_HISTO_G:COLOR_HISTO_G_PLAY, 597 (mrec)?COLOR_HISTO_BG:COLOR_HISTO_BG_PLAY, 598 (mrec)?COLOR_HISTO_R:COLOR_HISTO_R_PLAY, 599 (mrec)?COLOR_HISTO_RB:COLOR_HISTO_RB_PLAY, 600 (mrec)?COLOR_HISTO_RG:COLOR_HISTO_RG_PLAY, 601 COLOR_BLACK 602 }; 603 604 unsigned bWide = 1; // if wide (16:9) or standard (4:3) aspect ratio (but 1 in cameras that only have 4:3) 605 unsigned aspOffset = 0; // offset to add to x-coord (or buffer address) when drawing zebra 606 607 #if CAM_HAS_VARIABLE_ASPECT 608 if (shooting_get_prop(PROPCASE_ASPECT_RATIO) == 0) // standard requires x-shift to overlay drawing 609 { 610 bWide = 0; 611 //aspOffset = (camera_screen.width - (camera_screen.width * 12 / 16)) / 2; // = actual calculation, simplified below 612 aspOffset = camera_screen.width / 8; // half of the difference in width between equal height 16:9 and 4:3 screens, = black bar width 613 } 614 #endif 615 616 if (!gui_osd_zebra_init(show)) 617 return 0; 618 619 if(timer==0) { 620 draw_guard_pixel(); 621 timer=1; 622 return 0; 623 } 624 if(timer==1) { 625 int ready; 626 static int n=0; 627 if (!mrec) ready=1; 628 else get_property_case(PROPCASE_SHOOTING, &ready, 4); 629 n=draw_guard_pixel(); // will be 0 in PLAY mode, should be 1 or 2 in REC mode. 630 if(!ready) return 0; 631 #if ZEBRA_CANONOSD_BORDER_RESTORE 632 // rescue Canon OSD from scr_buf to cur_buf_top and _bot: 633 if (n==1) { 634 memcpy(cur_buf_top, scr_buf, camera_screen.buffer_width*ZFIX_TOP); 635 memcpy(cur_buf_bot, scr_buf + camera_screen.buffer_size - camera_screen.buffer_width*ZFIX_BOTTOM, camera_screen.buffer_width*ZFIX_BOTTOM); 636 } 637 else { 638 memcpy(cur_buf_top, scr_buf + camera_screen.buffer_size, camera_screen.buffer_width*ZFIX_TOP); 639 memcpy(cur_buf_bot, scr_buf + 2*camera_screen.buffer_size - camera_screen.buffer_width*ZFIX_BOTTOM, camera_screen.buffer_width*ZFIX_BOTTOM); 640 } 641 #else 642 // rescue Canon OSD from cur_buf 643 if(n==1) memcpy(cur_buf, scr_buf, camera_screen.buffer_size); 644 else memcpy(cur_buf, scr_buf+camera_screen.buffer_size, camera_screen.buffer_size); 645 #endif 646 } 647 ++timer; 648 // Try to get the best viewport buffer. In playmode its the _d one, in 649 // record mode we try to get the fast live one first 650 if (!mrec) { 651 img_buf = vid_get_viewport_fb_d(); 652 } 653 else { 654 img_buf = vid_get_viewport_live_fb(); 655 if( !img_buf ) { 656 img_buf = vid_get_viewport_fb(); 657 } 658 } 659 viewport_height = vid_get_viewport_height(); 660 switch (conf.zebra_mode) { 661 case ZEBRA_MODE_ZEBRA_1: 662 f = 4; 663 break; 664 case ZEBRA_MODE_ZEBRA_2: 665 f = 8; 666 break; 667 case ZEBRA_MODE_SOLID: 668 f = 1; 669 break; 670 case ZEBRA_MODE_BLINKED_1: 671 f = timer&1; 672 break; 673 case ZEBRA_MODE_BLINKED_3: 674 f = timer&4; 675 break; 676 case ZEBRA_MODE_BLINKED_2: 677 default: 678 f = timer&2; 679 break; 680 } 681 // if not in no-zebra phase of blink mode zebra, draw zebra to buf[] 682 if (f) { 683 int step_x, step_v; 684 over = 255-conf.zebra_over; 685 if (conf.zebra_multichannel) {step_x=2; step_v=6;} else {step_x=1; step_v=3;} 686 s = aspOffset; 687 for (y=1, v=0; y<=viewport_height; ++y) { 688 for (x=0; x<camera_screen.width; x+=step_x, s+=step_x, v+=step_v) { 689 register int yy, uu, vv; 690 int sel; 691 692 if (!bWide && (x + aspOffset >= camera_screen.width - aspOffset)) continue; // do not draw "outside screen" 693 694 yy = img_buf[v+1]; 695 if (conf.zebra_multichannel) { 696 uu = (signed char)img_buf[v]; 697 vv = (signed char)img_buf[v+2]; 698 sel=0; 699 if (!((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) { 700 if (clip8(((yy<<12) + vv*5743 + 2048)>>12)>over) sel = 4; // R 701 if (clip8(((yy<<12) - uu*1411 - vv*2925 + 2048)>>12)>over) sel |= 2; // G 702 if (clip8(((yy<<12) + uu*7258 + 2048)>>12)>over) sel |= 1; // B 703 } 704 buf[s]=buf[s+1]=cls[sel]; 705 } 706 else if (((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) buf[s]=COLOR_TRANSPARENT; 707 else buf[s]=(yy>over)?cl_over:(yy<conf.zebra_under)?cl_under:COLOR_TRANSPARENT; 708 if (buf[s] != COLOR_TRANSPARENT && !zebra_drawn) zebra_drawn = 1; 709 if (mrec) { 710 // draw Canon OSD to buf[] if in REC mode 711 #if ZEBRA_CANONOSD_BORDER_RESTORE 712 if(get_cur_buf(s)!=COLOR_TRANSPARENT) buf[s]=get_cur_buf(s); 713 if(conf.zebra_multichannel && get_cur_buf(s+1)!=COLOR_TRANSPARENT) buf[s+1]=get_cur_buf(s+1); 714 #else 715 if(cur_buf[s]!=COLOR_TRANSPARENT) buf[s]=cur_buf[s]; 716 if(conf.zebra_multichannel && cur_buf[s+1]!=COLOR_TRANSPARENT) buf[s+1]=cur_buf[s+1]; 717 #endif 718 } 719 } 720 s+=camera_screen.buffer_width-camera_screen.width; 721 if (y*camera_screen.height/viewport_height == (s+camera_screen.buffer_width)/camera_screen.buffer_width) { 722 memcpy(buf+s, buf+s-camera_screen.buffer_width, camera_screen.buffer_width); 723 s+=camera_screen.buffer_width; 724 } 725 } 726 if (!zebra_drawn) f=0; 727 } 728 // if blink mode is in no-zebra phase OR if there was no over/underexposed pixels to draw zebra on 729 if (!f) { 730 // if zebra was drawn during previous call of this function 731 if (need_restore) { 732 if (conf.zebra_restore_screen || conf.zebra_restore_osd) { 733 draw_restore(); 734 } else { // clear buf[] of zebra, only leave Canon OSD 735 if (mrec) { // REC mode 736 #if ZEBRA_CANONOSD_BORDER_RESTORE 737 // copy rescued Canon OSD to buf[] top/bottom parts and fill center with transparent color: 738 memcpy(buf, cur_buf_top, camera_screen.buffer_width * ZFIX_TOP); 739 memcpy(buf + camera_screen.buffer_size - camera_screen.buffer_width * ZFIX_BOTTOM, cur_buf_bot, camera_screen.buffer_width * ZFIX_BOTTOM); 740 for (s = camera_screen.buffer_width*ZFIX_TOP; s < camera_screen.buffer_size-camera_screen.buffer_width*ZFIX_BOTTOM; s++) { 741 buf[s]=COLOR_TRANSPARENT; 742 } 743 #else 744 // copy from a complete Canon OSD rescue screen dump 745 memcpy(buf, cur_buf, camera_screen.buffer_size); 746 #endif 747 } else { // Not REC mode 748 // No Canon OSD restore, fill buf[] with transparent color: 749 memset(buf, COLOR_TRANSPARENT, camera_screen.buffer_size); 750 } 751 // draw CHDK osd and histogram to buf[] (if enabled in config) 752 gui_osd_draw_zebra_osd(); 753 // copy buf[] to both display buffers 754 memcpy(scr_buf, buf, camera_screen.buffer_size); 755 memcpy(scr_buf+camera_screen.buffer_size, buf, camera_screen.buffer_size); 756 } 757 need_restore=0; 758 } 759 return !(conf.zebra_restore_screen && conf.zebra_restore_osd); 760 // if zebra was drawn 761 } else { 762 // draw CHDK osd and histogram to buf[] over zebra (if enabled in config) 763 gui_osd_draw_zebra_osd(); 764 // copy buf[] to both display buffers 765 memcpy(scr_buf, buf, camera_screen.buffer_size); 766 memcpy(scr_buf+camera_screen.buffer_size, buf, camera_screen.buffer_size); 767 768 need_restore=1; 769 return 1; 770 } 771 return 0; 772 } 773 #endif 205 if (conf.histo_show_ev_grid) for (i=1;i<=4;i++) draw_line(x+(1+w)*i/5, y, x+(1+w)*i/5, y+h, FG_COLOR(conf.histo_color2)); 206 } 207 774 208 //------------------------------------------------------------------- 775 209 static void gui_osd_draw_blended_histo(coord x, coord y) { … … 777 211 int m = ((mode_get()&MODE_MASK) == MODE_REC); 778 212 color cls[] = { 779 conf.histo_color>>8,213 BG_COLOR(conf.histo_color), 780 214 (m)?COLOR_HISTO_B:COLOR_HISTO_B_PLAY, 781 215 (m)?COLOR_HISTO_G:COLOR_HISTO_G_PLAY, … … 803 237 } 804 238 805 draw_rect(x, y, x+1+HISTO_WIDTH, y+HISTO_HEIGHT, conf.histo_color2&0xFF);239 draw_rect(x, y, x+1+HISTO_WIDTH, y+HISTO_HEIGHT, FG_COLOR(conf.histo_color2)); 806 240 //Vertical lines 807 if (conf.histo_show_ev_grid) for (i=1;i<=4;i++) draw_line(x+(1+HISTO_WIDTH)*i/5, y, x+(1+HISTO_WIDTH)*i/5, y+HISTO_HEIGHT, conf.histo_color2&0xFF);241 if (conf.histo_show_ev_grid) for (i=1;i<=4;i++) draw_line(x+(1+HISTO_WIDTH)*i/5, y, x+(1+HISTO_WIDTH)*i/5, y+HISTO_HEIGHT, FG_COLOR(conf.histo_color2)); 808 242 809 243 } … … 853 287 if (conf.histo_layout != OSD_HISTO_LAYOUT_R_G_B) { 854 288 if (under_exposed && conf.show_overexp) { 855 draw_filled_ellipse(conf.histo_pos.x+5, conf.histo_pos.y+5, 3, 3, MAKE_COLOR( conf.histo_color2>>8, conf.histo_color2>>8));289 draw_filled_ellipse(conf.histo_pos.x+5, conf.histo_pos.y+5, 3, 3, MAKE_COLOR(BG_COLOR(conf.histo_color2), BG_COLOR(conf.histo_color2))); 856 290 } 857 291 858 292 if (over_exposed && conf.show_overexp) { 859 draw_filled_ellipse(conf.histo_pos.x+HISTO_WIDTH-5, conf.histo_pos.y+5, 3, 3, MAKE_COLOR( conf.histo_color2>>8, conf.histo_color2>>8));293 draw_filled_ellipse(conf.histo_pos.x+HISTO_WIDTH-5, conf.histo_pos.y+5, 3, 3, MAKE_COLOR(BG_COLOR(conf.histo_color2), BG_COLOR(conf.histo_color2))); 860 294 } 861 295 } … … 1515 949 int i, deltax; 1516 950 1517 draw_filled_rect(x0,y0,x0+70,y0+24, visible? ((conf.osd_color&0xFF00))|(conf.osd_color>>8): COLOR_TRANSPARENT);951 draw_filled_rect(x0,y0,x0+70,y0+24, visible? MAKE_COLOR(BG_COLOR(conf.osd_color),BG_COLOR(conf.osd_color)): COLOR_TRANSPARENT); 1518 952 1519 953 if (!visible) { return; } -
trunk/core/gui_osd.h
r1527 r1569 12 12 #define OSD_HISTO_LAYOUT_BLEND 6 13 13 #define OSD_HISTO_LAYOUT_BLEND_Y 7 14 15 #define ZEBRA_DRAW_NONE 016 #define ZEBRA_DRAW_HISTO 117 #define ZEBRA_DRAW_OSD 218 14 19 15 #define ZOOM_SHOW_X 0 -
trunk/core/gui_palette.c
r1527 r1569 96 96 for (y=DISP_TOP; y<DISP_BOTTOM; y+=CELL_SIZE) 97 97 { 98 for (x=DISP_LEFT; x<DISP_RIGHT; x+=CELL_SIZE, c+= 0x0100)98 for (x=DISP_LEFT; x<DISP_RIGHT; x+=CELL_SIZE, c+=MAKE_COLOR(1,0)) 99 99 { 100 100 draw_filled_rect(xl+x, y, xl+x+CELL_SIZE, y+CELL_SIZE, c); … … 146 146 // RETURN VALUE: 1 error, 0 ok 147 147 //--------------------------------------------------------- 148 int _module_loader( void** chdk_export_list )148 int _module_loader( unsigned int* chdk_export_list ) 149 149 { 150 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER )150 if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 151 151 return 1; 152 152 if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) … … 185 185 186 186 if ( argn==3 ) 187 gui_palette_init( arguments[0], (color)arguments[1], (void*)arguments[2]);187 gui_palette_init( arguments[0], (color)arguments[1], (void*)arguments[2]); 188 188 else 189 189 gui_palette_init( PALETTE_MODE_DEFAULT, 0x00, NULL ); -
trunk/core/gui_palette.h
r1527 r1569 10 10 11 11 //------------------------------------------------------------------- 12 extern void gui_palette_init(int mode, color st_color, void (*on_select)(color clr));12 extern void module_palette_run(int mode, color st_color, void (*on_select)(color clr)); 13 13 14 14 //------------------------------------------------------------------- -
trunk/core/gui_read.c
r1527 r1569 9 9 #include "gui_batt.h" 10 10 #include "gui_read.h" 11 12 11 #include "gui_menu.h" 12 #include "gui_lang.h" 13 14 #include "modules.h" 13 15 #include "module_load.h" 16 17 //------------------------------------------------------------------- 18 19 typedef struct 20 { 21 color reader_color; 22 char reader_file[100]; 23 int reader_pos; 24 int reader_autoscroll; 25 int reader_autoscroll_delay; 26 char reader_rbf_file[100]; 27 int reader_codepage; 28 int reader_wrap_by_words; 29 } ReadConf; 30 31 ReadConf rconf; 32 33 static ConfInfo conf_info[] = { 34 CONF_INFO( 1, rconf.reader_color, CONF_DEF_VALUE, cl:0, NULL), 35 CONF_INFO( 2, rconf.reader_file, CONF_CHAR_PTR, ptr:"A/CHDK/BOOKS/README.TXT", NULL), 36 CONF_INFO( 3, rconf.reader_pos, CONF_DEF_VALUE, i:0, NULL), 37 CONF_INFO( 4, rconf.reader_autoscroll, CONF_DEF_VALUE, i:0, NULL), 38 CONF_INFO( 5, rconf.reader_autoscroll_delay,CONF_DEF_VALUE, i:5, NULL), 39 CONF_INFO( 6, rconf.reader_rbf_file, CONF_CHAR_PTR, ptr:"", NULL), 40 CONF_INFO( 7, rconf.reader_codepage, CONF_DEF_VALUE, i:FONT_CP_WIN, NULL), 41 CONF_INFO( 8, rconf.reader_wrap_by_words, CONF_DEF_VALUE, i:1, NULL), 42 }; 43 44 //------------------------------------------------------------------- 14 45 15 46 extern void gui_read_kbd_process_menu_btn(); … … 17 48 void gui_read_draw(int enforce_redraw); 18 49 void gui_read_kbd_leave(); 19 20 int *conf_reader_autoscroll;21 int *conf_reader_autoscroll_delay;22 int *conf_reader_pos;23 int *conf_reader_wrap_by_words;24 color *conf_reader_color;25 char *conf_reader_file;26 char *conf_menu_rbf_file;27 50 28 51 gui_handler GUI_MODE_READ = … … 63 86 //------------------------------------------------------------------- 64 87 static void gui_read_draw_scroll_indicator() { 65 draw_txt_char((camera_screen.width-camera_screen.ts_button_border)/FONT_WIDTH-2, 0, ( *conf_reader_autoscroll)?((pause)?'\x05':'\x04'):'\x03', MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline88 draw_txt_char((camera_screen.width-camera_screen.ts_button_border)/FONT_WIDTH-2, 0, (rconf.reader_autoscroll)?((pause)?'\x05':'\x04'):'\x03', MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline 66 89 } 67 90 … … 70 93 static struct STD_stat st; 71 94 read_file = safe_open(file, O_RDONLY, 0777); 72 if (strcmp(file, conf_reader_file)!=0) {73 *conf_reader_pos = 0;74 strcpy( conf_reader_file, file);95 if (strcmp(file, rconf.reader_file)!=0) { 96 rconf.reader_pos = 0; 97 strcpy(rconf.reader_file, file); 75 98 } 76 99 read_on_screen = 0; 77 100 read_file_size = (read_file>=0 && safe_stat((char*)file, &st)==0)?st.st_size:0; 78 if (read_file_size<= *conf_reader_pos) {79 *conf_reader_pos = 0;101 if (read_file_size<=rconf.reader_pos) { 102 rconf.reader_pos = 0; 80 103 } 81 104 pause = 0; … … 88 111 89 112 reader_is_active=1; 90 gui_set_mode(&GUI_MODE_READ);113 //gui_set_mode(&GUI_MODE_READ); 91 114 92 115 draw_filled_rect(0, 0, camera_screen.width-1, y-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 93 draw_filled_rect(0, y, camera_screen.width-1, camera_screen.height-1, MAKE_COLOR( (*conf_reader_color>>8)&0xFF, (*conf_reader_color>>8)&0xFF));116 draw_filled_rect(0, y, camera_screen.width-1, camera_screen.height-1, MAKE_COLOR(BG_COLOR(rconf.reader_color), BG_COLOR(rconf.reader_color))); 94 117 95 118 gui_read_draw_scroll_indicator(); … … 101 124 //------------------------------------------------------------------- 102 125 static void read_goto_next_line() { 103 draw_filled_rect(xx, yy, x+w-1, yy+rbf_font_height()-1, MAKE_COLOR( *conf_reader_color>>8, *conf_reader_color>>8));126 draw_filled_rect(xx, yy, x+w-1, yy+rbf_font_height()-1, MAKE_COLOR(BG_COLOR(rconf.reader_color), BG_COLOR(rconf.reader_color))); 104 127 xx = x; 105 128 yy += rbf_font_height(); … … 113 136 //------------------------------------------------------------------- 114 137 void gui_read_draw(int enforce_redraw) { 115 if ( *conf_reader_autoscroll && !pause && get_tick_count()-last_time >= *conf_reader_autoscroll_delay*1000 && (*conf_reader_pos+read_on_screen)<read_file_size) {116 *conf_reader_pos += read_on_screen;138 if (rconf.reader_autoscroll && !pause && get_tick_count()-last_time >= rconf.reader_autoscroll_delay*1000 && (rconf.reader_pos+read_on_screen)<read_file_size) { 139 rconf.reader_pos += read_on_screen; 117 140 read_to_draw = 1; 118 141 } … … 122 145 xx=x; yy=y; 123 146 124 lseek(read_file, *conf_reader_pos, SEEK_SET);147 lseek(read_file, rconf.reader_pos, SEEK_SET); 125 148 read_on_screen=0; 126 149 … … 130 153 read_goto_next_line(); 131 154 if (yy < y+h) 132 draw_filled_rect(x, yy, x+w-1, y+h-1, MAKE_COLOR( *conf_reader_color>>8, *conf_reader_color>>8));155 draw_filled_rect(x, yy, x+w-1, y+h-1, MAKE_COLOR(BG_COLOR(rconf.reader_color), BG_COLOR(rconf.reader_color))); 133 156 break; 134 157 } … … 147 170 // no break here 148 171 default: 149 if ( *conf_reader_wrap_by_words) {172 if (rconf.reader_wrap_by_words) { 150 173 if (buffer[i] == ' ') { 151 174 new_word = 1; … … 177 200 continue; 178 201 } 179 xx+=rbf_draw_char(xx, yy, buffer[i], *conf_reader_color);202 xx+=rbf_draw_char(xx, yy, buffer[i], rconf.reader_color); 180 203 break; 181 204 } … … 189 212 } 190 213 191 sprintf(buffer, "(%3d%%) %d/%d ", (read_file_size)?( *conf_reader_pos*100/read_file_size):0, *conf_reader_pos, read_file_size);214 sprintf(buffer, "(%3d%%) %d/%d ", (read_file_size)?(rconf.reader_pos*100/read_file_size):0, rconf.reader_pos, read_file_size); 192 215 buffer[camera_screen.width/FONT_WIDTH]=0; 193 216 draw_txt_string((camera_screen.ts_button_border/FONT_WIDTH), 0, buffer, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline … … 198 221 n=i*read_on_screen/read_file_size; // bar height 199 222 if (n<20) n=20; 200 i=(i-n)* *conf_reader_pos/read_file_size; // top pos223 i=(i-n)*rconf.reader_pos/read_file_size; // top pos 201 224 draw_filled_rect(x+w+6+2, y+1, x+w+6+6, y+1+i, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 202 225 draw_filled_rect(x+w+6+2, y+i+n, x+w+6+6, y+h-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); … … 221 244 case KEY_UP: 222 245 case KEY_LEFT: 223 if ( *conf_reader_pos>0) {224 *conf_reader_pos -= 45*15;225 if ( *conf_reader_pos<0) *conf_reader_pos=0;246 if (rconf.reader_pos>0) { 247 rconf.reader_pos -= 45*15; 248 if (rconf.reader_pos<0) rconf.reader_pos=0; 226 249 read_to_draw = 1; 227 250 } … … 232 255 case KEY_RIGHT: 233 256 case KEY_SHOOT_HALF: 234 if (( *conf_reader_pos+read_on_screen)<read_file_size) {235 *conf_reader_pos += read_on_screen;257 if ((rconf.reader_pos+read_on_screen)<read_file_size) { 258 rconf.reader_pos += read_on_screen; 236 259 read_to_draw = 1; 237 260 } … … 250 273 } 251 274 252 extern int module_idx;253 254 275 //------------------------------------------------------------------- 255 276 // Menu button handled for text reader … … 258 279 gui_read_kbd_process(); 259 280 gui_default_kbd_process_menu_btn(); 260 module_async_unload(module_idx);261 281 } 262 282 … … 267 287 268 288 reader_is_active = 0; 269 if (!rbf_load(conf _menu_rbf_file))289 if (!rbf_load(conf.menu_rbf_file)) 270 290 rbf_load_from_8x16(current_font); 271 291 rbf_set_codepage(FONT_CP_WIN); … … 276 296 } 277 297 298 //------------------------------------------------------------------- 299 static void gui_draw_read_selected(const char *fn) { 300 if (fn) { 301 if (!rbf_load(rconf.reader_rbf_file)) 302 rbf_load_from_8x16(current_font); 303 rbf_set_codepage(rconf.reader_codepage); 304 gui_set_mode(&GUI_MODE_READ); 305 gui_read_init(fn); 306 307 //unsigned int argv[] ={ (unsigned int)fn }; 308 //module_run("txtread.flt", 0, sizeof(argv)/sizeof(argv[0]), argv, UNLOAD_IF_ERR); 309 } 310 } 311 312 void gui_draw_read(int arg) { 313 module_fselect_init_w_mode(LANG_STR_SELECT_TEXT_FILE, rconf.reader_file, "A/CHDK/BOOKS", gui_draw_read_selected, 1); 314 void gui_fselect_set_key_redraw(int n); 315 //gui_fselect_set_key_redraw(1); @tsv 316 } 317 318 void gui_draw_read_last(int arg) { 319 struct STD_stat st; 320 if (safe_stat(rconf.reader_file,&st) == 0) { 321 gui_draw_read_selected(rconf.reader_file); 322 } else { 323 gui_draw_read(arg); 324 } 325 } 326 327 static void gui_draw_rbf_selected(const char *fn) { 328 if (fn) { 329 strcpy(rconf.reader_rbf_file, fn); 330 } 331 } 332 333 void gui_draw_load_rbf(int arg) { 334 module_fselect_init(LANG_STR_SELECT_FONT_FILE, rconf.reader_rbf_file, "A/CHDK/FONTS", gui_draw_rbf_selected); 335 } 336 337 static const char* gui_reader_codepage_cps[] = { "Win1251", "DOS"}; 338 static CMenuItem reader_submenu_items[] = { 339 MENU_ITEM(0x35,LANG_MENU_READ_OPEN_NEW, MENUITEM_PROC, gui_draw_read, 0 ), 340 MENU_ITEM(0x35,LANG_MENU_READ_OPEN_LAST, MENUITEM_PROC, gui_draw_read_last, 0 ), 341 MENU_ITEM(0x35,LANG_MENU_READ_SELECT_FONT, MENUITEM_PROC, gui_draw_load_rbf, 0 ), 342 MENU_ENUM2(0x5f,LANG_MENU_READ_CODEPAGE, &rconf.reader_codepage, gui_reader_codepage_cps ), 343 MENU_ITEM(0x5c,LANG_MENU_READ_WORD_WRAP, MENUITEM_BOOL, &rconf.reader_wrap_by_words, 0 ), 344 MENU_ITEM(0x5c,LANG_MENU_READ_AUTOSCROLL, MENUITEM_BOOL, &rconf.reader_autoscroll, 0 ), 345 MENU_ITEM(0x5f,LANG_MENU_READ_AUTOSCROLL_DELAY, MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &rconf.reader_autoscroll_delay, MENU_MINMAX(0, 60) ), 346 MENU_ITEM(0x65,LANG_MENU_VIS_READER_TEXT, MENUITEM_COLOR_FG, &rconf.reader_color, 0 ), 347 MENU_ITEM(0x65,LANG_MENU_VIS_READER_BKG, MENUITEM_COLOR_BG, &rconf.reader_color, 0 ), 348 MENU_ITEM(0x51,LANG_MENU_BACK, MENUITEM_UP, 0, 0 ), 349 {0} 350 }; 351 static CMenu reader_submenu = {0x37,LANG_MENU_READ_TITLE, NULL, reader_submenu_items }; 352 278 353 // ========= MODULE INIT ================= 279 354 #include "module_load.h" … … 296 371 // RETURN VALUE: 1 error, 0 ok 297 372 //--------------------------------------------------------- 298 int _module_loader( void** chdk_export_list )299 { 300 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER )373 int _module_loader( unsigned int* chdk_export_list ) 374 { 375 if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 301 376 return 1; 377 302 378 if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) 303 379 return 1; 304 305 tConfigVal configVal; 306 CONF_BIND_COLOR( 31, conf_reader_color ); 307 CONF_BIND_STR( 38, conf_reader_file ); 308 CONF_BIND_INT( 39, conf_reader_pos ); 309 CONF_BIND_INT( 43, conf_reader_autoscroll ); 310 CONF_BIND_INT( 44, conf_reader_autoscroll_delay ); 311 CONF_BIND_INT( 61, conf_reader_wrap_by_words ); 312 CONF_BIND_STR( 66, conf_menu_rbf_file ); 380 if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 381 return 1; 382 383 conf_info[0].cl = MAKE_COLOR(COLOR_GREY, COLOR_WHITE); 384 config_restore(&conf_info[0], "A/CHDK/MODULES/CFG/txtread.cfg", sizeof(conf_info)/sizeof(conf_info[0]), 0, 0); 313 385 314 386 return 0; … … 323 395 int _module_unloader() 324 396 { 325 // We should make "leave sequence" to restore font settings 326 gui_read_kbd_leave(); 327 328 GUI_MODE_READ.magicnum = 0; //sanity clean to prevent accidentaly assign/restore guimode to unloaded module 329 330 return 0; 397 config_save(&conf_info[0], "A/CHDK/MODULES/CFG/txtread.cfg", sizeof(conf_info)/sizeof(conf_info[0])); 398 399 GUI_MODE_READ.magicnum = 0; //sanity clean to prevent accidentaly assign/restore guimode to unloaded module 400 401 return 0; 331 402 } 332 403 … … 340 411 module_idx=moduleidx; 341 412 342 if ( argn!=1 || arguments[0]==0) { 343 module_async_unload(moduleidx); 344 return 1; 345 } 346 347 char* fn=(char*)arguments[0]; 348 gui_read_init(fn); 413 gui_activate_sub_menu(&reader_submenu, module_idx); 349 414 350 415 return 0; -
trunk/core/gui_reversi.c
r1527 r1569 9 9 #include "gui_batt.h" 10 10 #include "gui_mbox.h" 11 #include "gui_reversi.h"12 11 13 12 #include "module_load.h" -
trunk/core/gui_snake.c
r1527 r1569 429 429 } 430 430 431 int basic_module_init() { 432 return gui_snake_init(); 433 } 434 431 435 extern int module_idx; 432 436 void gui_module_menu_kbd_process() { 433 437 gui_default_kbd_process_menu_btn(); 434 438 module_async_unload(module_idx); 435 }436 437 438 // ========= MODULE INIT =================439 #include "module_load.h"440 int module_idx=-1;441 442 /***************** BEGIN OF AUXILARY PART *********************443 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION444 **************************************************************/445 446 void* MODULE_EXPORT_LIST[] = {447 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER,448 /* 1 */ (void*)0449 };450 451 452 //---------------------------------------------------------453 // PURPOSE: Bind module symbols with chdk.454 // Required function455 // PARAMETERS: pointer to chdk list of export456 // RETURN VALUE: 1 error, 0 ok457 //---------------------------------------------------------458 int _module_loader( void** chdk_export_list )459 {460 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER )461 return 1;462 if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) )463 return 1;464 465 return 0;466 }467 468 469 470 //---------------------------------------------------------471 // PURPOSE: Finalize module operations (close allocs, etc)472 // RETURN VALUE: 0-ok, 1-fail473 //---------------------------------------------------------474 int _module_unloader()475 {476 return 0;477 }478 479 480 //---------------------------------------------------------481 // PURPOSE: Default action for simple modules (direct run)482 // NOTE: Please comment this function if no default action and this library module483 //---------------------------------------------------------484 int _module_run(int moduleidx, int argn, int* arguments)485 {486 module_idx=moduleidx;487 488 int rv = gui_snake_init();489 if ( ! rv )490 module_async_unload(moduleidx); // fail to init - "unload me"491 492 return 0;493 439 } 494 440 -
trunk/core/gui_sokoban.c
r1527 r1569 10 10 #include "gui_batt.h" 11 11 #include "gui_mbox.h" 12 #include "gui_sokoban.h"13 12 14 13 #include "module_load.h" 14 15 //------------------------------------------------------------------- 16 17 typedef struct 18 { 19 int sokoban_level; 20 } SokobanConf; 21 22 SokobanConf sconf; 23 24 static const ConfInfo conf_info[] = { 25 CONF_INFO( 1, sconf.sokoban_level, CONF_DEF_VALUE, i:0, NULL), 26 }; 15 27 16 28 void gui_module_menu_kbd_process(); … … 18 30 void gui_sokoban_draw(int enforce_redraw); 19 31 20 int *conf_sokoban_level;21 22 32 gui_handler GUI_MODE_SOKOBAN = 23 33 /*GUI_MODE_SOKOBAN*/ { GUI_MODE_MODULE, gui_sokoban_draw, gui_sokoban_kbd_process, gui_module_menu_kbd_process, GUI_MODE_FLAG_NODRAWRESTORE, GUI_MODE_MAGICNUM }; 24 25 34 26 35 //------------------------------------------------------------------- … … 209 218 210 219 free(buf); 211 *conf_sokoban_level = lvl;220 sconf.sokoban_level = lvl; 212 221 moves = 0; 213 222 sokoban_undo_reset(); … … 227 236 //------------------------------------------------------------------- 228 237 static void sokoban_next_level() { 229 if (++ *conf_sokoban_level >= num_levels) *conf_sokoban_level = 0;230 sokoban_set_level( *conf_sokoban_level);238 if (++sconf.sokoban_level >= num_levels) sconf.sokoban_level = 0; 239 sokoban_set_level(sconf.sokoban_level); 231 240 need_redraw_all = 1; 232 241 } … … 325 334 return 0; 326 335 } 327 else if( *conf_sokoban_level >= num_levels) {328 *conf_sokoban_level = 0;336 else if(sconf.sokoban_level >= num_levels) { 337 sconf.sokoban_level = 0; 329 338 } 330 339 cell_size = camera_screen.height/FIELD_HEIGHT; 331 sokoban_set_level( *conf_sokoban_level);340 sokoban_set_level(sconf.sokoban_level); 332 341 // if the file is no longer readable, set_level will set this 333 342 if(!num_levels) { … … 374 383 case KEY_ERASE: 375 384 case KEY_DISPLAY: 376 sokoban_set_level( *conf_sokoban_level);385 sokoban_set_level(sconf.sokoban_level); 377 386 need_redraw_all = 1; 378 387 break; … … 425 434 draw_line(camera_screen.ts_button_border+cell_size*FIELD_WIDTH+1, 0, camera_screen.ts_button_border+cell_size*FIELD_WIDTH+1, camera_screen.height-1, COLOR_BLACK); 426 435 427 sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_LEVEL), *conf_sokoban_level+1);436 sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_LEVEL), sconf.sokoban_level+1); 428 437 draw_string(camera_screen.ts_button_border+cell_size*FIELD_WIDTH+2, 8, str, MAKE_COLOR(SCREEN_COLOR, COLOR_WHITE)); 429 438 sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_MOVES), moves); … … 451 460 452 461 // ========= MODULE INIT ================= 453 #include "module_load.h" 462 454 463 int module_idx=-1; 455 464 … … 470 479 // RETURN VALUE: 1 error, 0 ok 471 480 //--------------------------------------------------------- 472 int _module_loader( void** chdk_export_list )481 int _module_loader( unsigned int* chdk_export_list ) 473 482 { 474 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER )483 if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 475 484 return 1; 485 476 486 if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) 477 487 return 1; 478 488 479 // Safe bind of conf. 480 tConfigVal configVal; 481 CONF_BIND_INT(40, conf_sokoban_level ); 489 config_restore(&conf_info[0], "A/CHDK/MODULES/CFG/sokoban.cfg", sizeof(conf_info)/sizeof(conf_info[0]), 0, 0); 482 490 483 491 return 0; 484 492 } 485 486 493 487 494 … … 492 499 int _module_unloader() 493 500 { 494 return 0; 501 config_save(&conf_info[0], "A/CHDK/MODULES/CFG/sokoban.cfg", sizeof(conf_info)/sizeof(conf_info[0])); 502 return 0; 495 503 } 496 504 … … 504 512 module_idx=moduleidx; 505 513 506 int rv = gui_sokoban_init(); 514 int rv = 0; 515 if ((mode_get()&MODE_MASK) != MODE_PLAY) { 516 gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE, 517 MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, 0); 518 } else { 519 rv = gui_sokoban_init(); 520 } 507 521 if ( ! rv ) 508 522 module_async_unload(moduleidx); // fail to init - "unload me" -
trunk/core/gui_tetris.c
r1527 r1569 687 687 } 688 688 689 int basic_module_init() { 690 gui_set_mode(&GUI_MODE_TETRIS); 691 gui_tetris_init(); 692 return 1; 693 } 694 689 695 void gui_tetris_draw(){ 690 696 gameUpdate(game); … … 730 736 } 731 737 732 // ========= MODULE INIT =================733 #include "module_load.h"734 int module_idx=-1;735 736 /***************** BEGIN OF AUXILARY PART *********************737 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION738 **************************************************************/739 740 void* MODULE_EXPORT_LIST[] = {741 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER,742 /* 1 */ (void*)0743 };744 745 746 //---------------------------------------------------------747 // PURPOSE: Bind module symbols with chdk.748 // Required function749 // PARAMETERS: pointer to chdk list of export750 // RETURN VALUE: 1 error, 0 ok751 //---------------------------------------------------------752 int _module_loader( void** chdk_export_list )753 {754 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER )755 return 1;756 757 if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) )758 return 1;759 760 return 0;761 }762 763 764 765 //---------------------------------------------------------766 // PURPOSE: Finalize module operations (close allocs, etc)767 // RETURN VALUE: 0-ok, 1-fail768 //---------------------------------------------------------769 int _module_unloader()770 {771 GUI_MODE_TETRIS.magicnum = 0; //sanity clean to prevent accidentaly assign/restore guimode to unloaded module772 773 deleteGame(game);774 775 return 0;776 }777 778 779 //---------------------------------------------------------780 // PURPOSE: Default action for simple modules (direct run)781 // NOTE: Please comment this function if no default action and this library module782 //---------------------------------------------------------783 int _module_run(int moduleidx, int argn, int* arguments)784 {785 module_idx=moduleidx;786 787 gui_set_mode(&GUI_MODE_TETRIS);788 gui_tetris_init();789 790 return 0;791 }792 793 794 738 /******************** Module Information structure ******************/ 795 739 -
trunk/core/luascript.c
r1527 r1569 14 14 #include "console.h" 15 15 #include "action_stack.h" 16 #include "motion_detector.h"17 16 #include "ptp.h" 18 17 #include "core.h" … … 779 778 static int luaCB_md_get_cell_diff( lua_State* L ) 780 779 { 781 lua_pushnumber( L, md_get_cell_diff(luaL_checknumber(L,1), 782 luaL_checknumber(L,2))); 783 return 1; 780 if (module_mdetect_load()) 781 lua_pushnumber( L, libmotiondetect->md_get_cell_diff(luaL_checknumber(L,1), luaL_checknumber(L,2))); 782 else 783 lua_pushnumber( L, 0 ); 784 return 1; 784 785 } 785 786 … … 803 804 int pixels_step = (luaL_optnumber(L,15,6)); 804 805 int msecs_before_trigger = (luaL_optnumber(L,16,0)); 805 if (md_init_motion_detector(806 if (module_mdetect_load() && libmotiondetect->md_init_motion_detector( 806 807 columns, rows, pixel_measure_mode, detection_timeout, 807 808 measure_interval, threshold, draw_grid, … … 825 826 kbd_reset_autoclicked_key(); 826 827 828 // Push selected file as script return value 827 829 lua_pushstring( Lt, (fn && fn[0])? fn : NULL ); 828 829 830 } 830 831 -
trunk/core/main.c
r1527 r1569 128 128 } 129 129 130 int core_get_free_memory() { 130 int core_get_free_memory() 131 { 132 cam_meminfo camera_meminfo; 133 131 134 #if defined(OPT_EXMEM_MALLOC) && !defined(OPT_EXMEM_TESTING) 132 135 // If using the exmem / suba memory allocation system then don't need 133 136 // to try allocating memory to find out how much is available 134 137 // Call function to scan free list for the largest free block available. 135 cam_meminfo camera_meminfo;136 138 GetExMemInfo(&camera_meminfo); 139 #else 140 // Call function to fill memory info structure and return size of largest free block 141 // If implemented this will use firmware function, otherwise it will calculate largest 142 // free block 143 GetMemInfo(&camera_meminfo); 144 #endif 145 137 146 return camera_meminfo.free_block_max_size; 138 #elif defined(CAM_FIRMWARE_MEMINFO)139 // Call firmware function to fill memory info structure and return size of largest free block140 cam_meminfo camera_meminfo;141 GetMemInfo(&camera_meminfo);142 return camera_meminfo.free_block_max_size;143 #else144 int size, l_size, d;145 char* ptr;146 147 size = 16;148 while (1) {149 ptr= malloc(size);150 if (ptr) {151 free(ptr);152 size <<= 1;153 } else154 break;155 }156 157 l_size = size;158 size >>= 1;159 d=1024;160 while (d) {161 ptr = malloc(size);162 if (ptr) {163 free(ptr);164 d = l_size-size;165 if (d<0) d=-d;166 l_size = size;167 size += d>>1;168 } else {169 d = size-l_size;170 if (d<0) d=-d;171 l_size = size;172 size -= d>>1;173 }174 175 }176 return size-1;177 #endif178 147 } 179 148 … … 226 195 mkdir("A/CHDK/BOOKS"); 227 196 mkdir("A/CHDK/MODULES"); 197 mkdir("A/CHDK/MODULES/CFG"); 228 198 mkdir("A/CHDK/GRIDS"); 229 199 #ifdef OPT_CURVES … … 271 241 272 242 #ifdef OPT_EDGEOVERLAY 273 if( conf.edge_overlay_thresh && conf.edge_overlay_enable) {243 if(((gui_get_mode()==GUI_MODE_NONE) || (gui_get_mode()==GUI_MODE_ALT)) && conf.edge_overlay_thresh && conf.edge_overlay_enable) { 274 244 275 245 // We need to skip first tick because stability -
trunk/core/module_exportlist.c
r1527 r1569 15 15 #include "gui_draw.h" 16 16 #include "gui_batt.h" 17 #include "gui_space.h" 17 18 #include "gui_menu.h" 18 19 #include "gui_osd.h" … … 21 22 #include "conf.h" 22 23 #include "raw.h" 23 #include "bitvector.h"24 24 #include "font.h" 25 25 … … 40 40 41 41 42 43 42 // ** SECTION 1: DEFINE UNDECLARED EXPORTED ITEMS 44 45 #ifndef CAM_FIRMWARE_MEMINFO46 #define GetMemInfo 047 #endif48 43 49 44 … … 82 77 char COLOR__EXPORTEDSYM_HISTO_RG_PLAY = COLOR_HISTO_RG_PLAY ; 83 78 84 85 79 /* EXPORTED_DEFINES_END */ 86 80 81 87 82 // ** SECTION 3: LIST OF EXPORTED SYMBOLS (pointer to function/variable) 88 // 1. DO NOT CHANGE ORDER AND DO NOT DELETE EXISTED ENTRIES 89 // 2. VARIABLE conf SHOULDN'T EXIST IN THE LIST TO KEEP ISOLATION. USE set|get_chdk_conf|get_chdk_conf_ptr INSTEAD 90 // STOPLIST: conf, open, opendir, closedir, rewinddir, readdir, stat 91 92 void* CHDK_EXPORT_LIST[] = { 93 (void*)EXPORTLIST_MAGIC_NUMBER, 94 (void*)EXPORTLIST_LAST_IDX, 83 // STOPLIST: open, opendir, closedir, rewinddir, readdir, stat 84 85 // This section is parsed by the makeexport.c program to generate the 86 // symbol hash table loaded later (from module_hashlist.h) 87 // Symbols to be exported should be on seperate lines, blank lines and '//' style comments are allowed 88 89 #if 0 90 { 95 91 module_async_unload, 96 92 module_set_flags, 97 conf_getValue,98 93 module_run, 94 module_get_adr, 95 module_async_unload_allrunned, 96 module_rawop_load, 97 module_rawop_unload, 98 module_mpopup_init, 99 module_convert_dng_to_chdk_raw, 100 module_fselect_init, 101 module_fselect_init_w_mode, 102 module_grids_load, 103 module_find_symbol_address, 104 module_restore_edge, 105 module_save_edge, 106 107 &altGuiHandler, 108 &camera_info, 109 &camera_screen, 110 &camera_sensor, 111 &gui_version, 112 &conf, 99 113 100 114 malloc, … … 102 116 umalloc, 103 117 ufree, 104 safe_open, 118 105 119 write, 106 120 lseek, 121 safe_open, 107 122 close, 108 123 read, 109 124 remove, 110 125 rename, 126 safe_stat, 127 safe_opendir, 128 safe_readdir, 129 safe_closedir, 130 mkdir, 131 111 132 fopen, 112 133 fclose, … … 114 135 fread, 115 136 fwrite, 116 safe_stat,117 safe_opendir,118 safe_readdir,119 safe_closedir,120 137 121 138 get_tick_count, … … 125 142 rand, 126 143 srand, 144 qsort, 145 msleep, 127 146 128 147 lang_str, … … 134 153 strchr, 135 154 strcmp, 155 strtol, 156 strrchr, 157 strncpy, 136 158 memcpy, 159 memset, 137 160 138 161 draw_txt_string, … … 144 167 draw_line, 145 168 draw_char, 169 draw_get_pixel, 170 draw_pixel, 171 draw_restore, 172 draw_txt_char, 173 draw_rect_thick, 174 draw_filled_rect_thick, 175 draw_rect_shadow, 176 draw_ellipse, 177 draw_clear, 178 draw_set_draw_proc, 146 179 147 180 gui_get_mode, 148 181 gui_set_mode, 149 182 gui_default_kbd_process_menu_btn, 150 151 vid_get_viewport_fb,152 vid_get_viewport_height,153 vid_get_bitmap_fb,154 hook_raw_image_addr,155 hook_raw_size,156 kbd_get_autoclicked_key,157 158 183 get_batt_perc, 159 184 gui_osd_draw_clock, 160 185 gui_mbox_init, 161 162 // for rawop.flt163 GetFreeCardSpaceKb,164 debug_led,165 186 gui_browser_progress_show, 166 167 // for edgeovr.flt 187 gui_activate_sub_menu, 188 gui_enum_value_change, 189 gui_force_restore, 190 gui_menu_run_fltmodule, 191 192 gui_osd_calc_dof, 193 gui_osd_draw_dof, 194 gui_batt_draw_osd, 195 gui_space_draw_osd, 196 gui_osd_draw_state, 197 gui_osd_draw_raw_info, 198 gui_osd_draw_values, 199 gui_osd_draw_temp, 200 gui_osd_draw_histo, 201 202 vid_get_bitmap_fb, 203 vid_get_viewport_fb, 204 vid_get_viewport_fb_d, 205 vid_get_viewport_live_fb, 206 vid_get_viewport_height, 168 207 vid_get_viewport_width, 169 208 vid_get_viewport_byte_width, 170 209 vid_get_viewport_xoffset, 171 210 vid_get_viewport_yoffset, 211 vid_get_viewport_image_offset, 212 vid_get_viewport_row_offset, 172 213 vid_get_viewport_yscale, 173 vid_get_viewport_fb_d, 214 215 get_raw_image_addr, 216 hook_raw_image_addr, 217 hook_raw_size, 218 raw_prepare_develop, 219 220 kbd_get_autoclicked_key, 174 221 kbd_is_key_pressed, 175 bv_create, 176 bv_get, 177 bv_set, 178 bv_free, 179 draw_get_pixel, 180 draw_pixel, 181 draw_restore, 182 memset, 222 kbd_key_press, 223 kbd_get_clicked_key, 224 kbd_reset_autoclicked_key, 225 get_jogdial_direction, 226 227 // for rawop.flt 228 GetFreeCardSpaceKb, 229 debug_led, 230 183 231 mode_get, 184 232 shooting_get_zoom, … … 186 234 187 235 // for txtread.flt 188 draw_txt_char,236 current_font, 189 237 rbf_char_width, 190 238 rbf_font_height, 191 239 rbf_draw_char, 192 240 rbf_load, 193 current_font,194 241 rbf_load_from_8x16, 195 242 rbf_set_codepage, 196 get_jogdial_direction, 197 198 // for palette.flt 199 draw_rect_thick, 200 draw_filled_rect_thick, 243 rbf_draw_string_len, 244 rbf_draw_menu_header, 201 245 202 246 // for modinsp.flt 203 module_get_adr,204 module_async_unload_allrunned,205 247 GetMemInfo, 248 GetExMemInfo, 206 249 207 250 // for fselect.flt 208 module_rawop_load,209 module_rawop_unload,210 module_mpopup_init,211 qsort,212 251 img_prefixes, 213 252 img_exts, 214 strrchr,215 strncpy,216 msleep,217 253 GetTotalCardSpaceKb, 218 module_convert_dng_to_chdk_raw,219 raw_prepare_develop,220 221 // curves.flt222 get_raw_image_addr,223 shooting_get_ev_correction1,224 225 // mpopup.flt226 draw_rect_shadow,227 kbd_get_clicked_key,228 kbd_reset_autoclicked_key,229 254 230 255 // tetris.flt 231 256 TurnOnBackLight, 232 257 TurnOffBackLight, 233 mkdir, 234 235 // modlist.flt 258 259 // modmenu.flt 236 260 load_from_file, 237 rbf_draw_string_len, 238 rbf_draw_menu_header, 239 gui_force_restore, 240 241 // modmenu.flt 242 gui_menu_run_fltmodule, 261 262 action_stack_create, 263 action_pop, 264 action_push, 265 action_push_delay, 266 action_push_release, 267 action_stack_standard, 268 console_clear, 269 console_add_line, 270 271 shooting_set_tv96_direct, 272 shooting_get_iso_market, 273 shooting_get_ev_correction1, 274 275 get_focal_length, 276 get_effective_focal_length, 277 get_parameter_data, 278 get_property_case, 279 280 &shutter_open_time, 281 &state_shooting_progress, 282 get_raw_pixel, 283 patch_bad_pixel, 284 285 pow_calc, 286 pow_calc_2, 243 287 244 288 // export palette … … 272 316 &COLOR__EXPORTEDSYM_HISTO_RG_PLAY, 273 317 274 // profile.flt 275 find_mnu, 276 lang_strhash31, 277 278 action_stack_create, 279 action_pop, 280 action_push, 281 action_push_delay, 282 action_stack_standard, 283 console_clear, 284 console_add_line, 285 shooting_set_tv96_direct, 286 shooting_get_iso_market, 287 get_focal_length, 288 get_effective_focal_length, 289 get_parameter_data, 290 get_property_case, 291 &shutter_open_time, 292 get_raw_pixel, 293 &state_shooting_progress, 294 patch_bad_pixel, 295 296 pow_calc, 297 pow_calc_2, 298 299 &camera_info, 300 &camera_screen, 301 &camera_sensor, 302 &altGuiHandler, 303 &gui_version, 304 0 318 module_tbox_get_version, 319 module_tbox_run, 320 321 config_save, 322 config_restore, 323 } 324 #endif 325 326 // Symbol hash table for resolving exported symbol references 327 sym_hash symbol_hash_table[] = 328 { 329 { EXPORTLIST_MAGIC_NUMBER, (void*)EXPORTLIST_LAST_IDX }, 330 #include "module_hashlist.h" 305 331 }; -
trunk/core/module_load.c
r1527 r1569 21 21 //********************************************************/ 22 22 23 extern void* CHDK_EXPORT_LIST[];24 25 23 #define MAX_NUM_LOADED_MODULES 10 26 24 #define BUFFER_FOR_READ_SIZE 4096 … … 81 79 // =1- if correspondend module ask to unload it on exit from main menu 82 80 static unsigned char module_flags[MAX_NUM_LOADED_MODULES]; 83 84 81 85 82 //----------------------------------------------- … … 157 154 } 158 155 156 // Find symbol address in array from hash id 157 void* module_find_symbol_address(uint32_t importid) 158 { 159 // binary search (first entry is magic number & entry count) 160 int min = 1, max = EXPORTLIST_LAST_IDX; 161 do 162 { 163 int mid = (min + max) >> 1; 164 if (importid == symbol_hash_table[mid].hash) 165 return symbol_hash_table[mid].address; 166 else if (importid > symbol_hash_table[mid].hash) 167 min = mid + 1; 168 else 169 max = mid - 1; 170 } while (min <= max); 171 return 0; 172 } 173 159 174 static int module_do_imports( struct flat_hdr* flat, void* relocbuf, uint32_t import_count ) 160 175 { 161 176 int i; 162 uint32_t importidx;177 void* importaddress; 163 178 uint32_t* ptr; 164 179 unsigned char* buf = (unsigned char*)flat; … … 168 183 { 169 184 ptr = (uint32_t*)( buf + ((import_record_t*)relocbuf)->offs ); 170 importidx = ((import_record_t*)relocbuf)->importidx; 171 172 //@tsv todo: if (*relocbuf>=flat->reloc_start) error_out_of_bound 173 // No such symbol to import 174 if ( importidx<2 || importidx>EXPORTLIST_LAST_IDX ) 175 return 0; 176 177 // Empty symbol - module could only if import such symbol manually 178 if ( CHDK_EXPORT_LIST[importidx]==0 ) 179 return 0; 180 181 *ptr += (uint32_t)CHDK_EXPORT_LIST[importidx]; 185 importaddress = module_find_symbol_address(((import_record_t*)relocbuf)->importidx); 186 187 if (importaddress == 0) return 0; 188 189 *ptr += (int)importaddress; //(uint32_t)CHDK_EXPORT_LIST[importidx]; 182 190 relocbuf = ((import_record_t*)relocbuf)+1; 183 191 } … … 256 264 // RETURN: -1 - failed, >=0 =idx of module 257 265 //----------------------------------------------- 258 int module_load( char* name, _module_ loader_t callback)266 int module_load( char* name, _module_bind_t callback) 259 267 { 260 268 int idx; … … 277 285 // reset possible unload request 278 286 module_unload_request[idx]=0; 287 if ( callback ) 288 callback( (void**) modules[idx]->_module_exportlist ); 279 289 return idx; 280 290 } … … 381 391 382 392 if ( modules[idx]->_module_loader ) { 383 uint32_t x = ((_module_loader_t) modules[idx]->_module_loader )( CHDK_EXPORT_LIST);384 bind_err = bind_err || x; //( (_module_loader_t) modules[idx]->_module_loader )(CHDK_EXPORT_LIST));393 uint32_t x = ((_module_loader_t) modules[idx]->_module_loader )((unsigned int*)&symbol_hash_table[0]); 394 bind_err = bind_err || x; 385 395 } 386 396 … … 402 412 // RETURN VALUE: passed from module. -1 if something was failed 403 413 //----------------------------------------------- 404 int module_run(char* name, _module_ loader_t callback, int argn, void* args, enum ModuleUnloadMode unload_after)414 int module_run(char* name, _module_bind_t callback, int argn, void* args, enum ModuleUnloadMode unload_after) 405 415 { 406 416 int rv = -1; … … 432 442 433 443 //----------------------------------------------- 434 void module_unload(char* name) 435 { 436 int idx; 444 void module_unload_idx(int idx) 445 { 437 446 _module_loader_t callback; 438 439 idx = module_find(name);440 447 441 448 if ( idx>=0 ) { … … 457 464 } 458 465 466 void module_unload(char* name) 467 { 468 module_unload_idx(module_find(name)); 469 } 459 470 460 471 //----------------------------------------------- -
trunk/core/module_load.h
r1527 r1569 15 15 16 16 17 // Struct for symbol hash table entries 18 typedef struct 19 { 20 uint32_t hash; 21 void *address; 22 } sym_hash; 23 24 // Hashed Symbol table for exported symbols 25 extern sym_hash symbol_hash_table[]; 26 27 17 28 // Base typedefs 18 29 //------------------- … … 20 31 #define EXPORTLIST_MAGIC_NUMBER 0x43215678 21 32 22 typedef int (*_module_loader_t)( void** chdk_export_list ); 33 typedef int (*_module_bind_t)( void** chdk_export_list ); 34 typedef int (*_module_loader_t)( unsigned int* chdk_export_list ); 23 35 typedef int (*_module_unloader_t)(); 24 36 typedef int (*_module_run_t)(int moduleidx, int argn, int* arguments); … … 37 49 int module_check_is_exist(char* name); 38 50 int module_find(char * name ); 39 int module_load( char* name, _module_ loader_t callback);40 int module_run(char* name, _module_ loader_t callback, int argn, void* args, enum ModuleUnloadMode unload_after);51 int module_load( char* name, _module_bind_t callback); 52 int module_run(char* name, _module_bind_t callback, int argn, void* args, enum ModuleUnloadMode unload_after); 41 53 void module_unload(char* name); 54 void module_unload_idx(int module_idx); 55 void* module_find_symbol_address(uint32_t importid); 42 56 43 57 // Flag for modules which couldn't be safely autounloaded (lua, basic,..) … … 54 68 void module_tick_unloader(); 55 69 56 // In-module binding to conf.57 //---------------------------58 #define CONF_BIND_INT(idConf,var) if ( conf_getValue(idConf, &configVal) == CONF_VALUE ) { var = configVal.pInt; } else { return 1;}59 #define CONF_BIND_COLOR(idConf,var) if ( conf_getValue(idConf, &configVal) == CONF_VALUE ) { var = (color*)configVal.pInt; } else { return 1;}60 #define CONF_BIND_STR(idConf,var) if ( conf_getValue(idConf, &configVal) == CONF_CHAR_PTR ) { var = (char*)configVal.str; } else { return 1;}61 62 70 // API versions check 63 71 //--------------------------- -
trunk/core/modules.c
r1527 r1569 14 14 #include "gui_draw.h" 15 15 #include "dng.h" 16 #include "lang.h" 17 18 /************* GENERIC ******/ 19 20 static int bind_module_generic( void** export_list, void** lib, int count, int major, int minor ) 21 { 22 *lib = 0; 23 24 // Unbind 25 if ( !export_list ) { 26 return 0; 27 } 28 29 // Bind 30 if ( (unsigned int)export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 31 return 1; 32 if ( (unsigned int)export_list[1] < count ) 33 return 1; 34 35 *lib = (void*)export_list[2]; 36 37 if ( !*lib ) 38 return 1; 39 if ( (major > 0) && !API_VERSION_MATCH_REQUIREMENT( *((int*)(*lib)), major, minor ) ) { 40 *lib=0; 41 return 1; 42 } 43 44 return 0; 45 } 46 47 // Return: 0-fail, addr-ok 48 static void* module_load_generic(void **lib, char *name, int (*callback)(void**), int flags) 49 { 50 if (*lib == 0) 51 { 52 int module_idx = module_load(name, callback); 53 if ( module_idx < 0 ) 54 module_unload(name); 55 else 56 { 57 if (flags) 58 module_set_flags(module_idx, flags); 59 } 60 } 61 62 return *lib; 63 } 16 64 17 65 /************* DYNAMIC LIBRARY RAWOPERATION ******/ … … 28 76 struct librawop_sym* librawop; 29 77 78 void module_rawop_unload() 79 { 80 if (librawop) 81 { 82 module_unload(MODULE_NAME_RAWOP); 83 librawop = 0; 84 } 85 } 86 30 87 static int bind_module_rawop( void** export_list ) 31 88 { 32 // Unbind 33 if ( !export_list ) { 34 librawop=0; 35 return 0; 36 } 37 38 // Bind 39 if ( (unsigned int)export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 40 return 1; 41 if ( (unsigned int)export_list[1] <3 ) 42 return 1; 43 44 librawop = export_list[2]; 45 46 if ( !librawop ) 47 return 1; 48 49 /* NO API VERSION CHECK HERE - EACH MODULE CHECK THIS AGAINST ITS REQUIREMENT 50 if ( !API_VERSION_MATCH_REQUIREMENT( librawop->version, 1, 0 ) ) { 51 librawop=0; 52 return 1; 53 } 54 */ 55 56 return 0; 57 } 58 59 void module_rawop_unload() 60 { 61 if (librawop==0) 62 return; 63 64 module_unload(MODULE_NAME_RAWOP); 65 } 66 89 return bind_module_generic(export_list, (void**)&librawop, 1, 0, 0); 90 } 67 91 68 92 // Return: 0-fail, otherwise - bind list 69 93 struct librawop_sym* module_rawop_load() 70 94 { 71 static int module_idx=-1; 72 73 if (librawop) 74 return librawop; 75 76 module_idx=module_load(MODULE_NAME_RAWOP, bind_module_rawop ); 77 if ( module_idx<0 ) 78 module_unload(MODULE_NAME_RAWOP); 79 80 return librawop; 81 } 82 95 return module_load_generic((void**)&librawop, MODULE_NAME_RAWOP, bind_module_rawop, 0); 96 } 83 97 84 98 85 99 /************* DYNAMIC LIBRARY EDGE OVERLAY ******/ 86 100 101 #ifdef OPT_EDGEOVERLAY 102 87 103 #define MODULE_NAME_EDGEOVR "edgeovr.flt" 88 104 105 // Storage and interface for edge overlay 'image' buffer. 106 // This is so the previous overlay can survive if the module gets unloaded 107 static void* saved_edgebuf = 0; 108 static int saved_edgestate = 0; 109 void module_restore_edge(void **buf, int *state) { *buf = saved_edgebuf; *state = saved_edgestate; } 110 void module_save_edge(void* buf, int state) { saved_edgebuf = buf; saved_edgestate = state; } 111 89 112 struct libedgeovr_sym* libedgeovr; 90 113 91 114 static int bind_module_edgeovr( void** export_list ) 92 115 { 93 // Unbind 94 if ( !export_list ) { 95 libedgeovr =0; 96 return 0; 97 } 98 99 // Bind 100 if ( (unsigned int)export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 101 return 1; 102 if ( (unsigned int)export_list[1] <3 ) 103 return 1; 104 105 libedgeovr = export_list[2]; 106 if ( !libedgeovr ) 107 return 1; 108 if ( !API_VERSION_MATCH_REQUIREMENT( libedgeovr->version, 1, 0 ) ) { 109 libedgeovr=0; 110 return 1; 111 } 112 113 return 0; 116 return bind_module_generic(export_list, (void**)&libedgeovr, 1, 1, 0); 114 117 } 115 118 … … 117 120 struct libedgeovr_sym* module_edgeovr_load() 118 121 { 119 if (libedgeovr) 120 return libedgeovr; 121 122 // This flag is because edgeovr called each tick 123 // If module loading failed, then do not try to load it until reboot 124 // (otherwise we will try to load module each tick) 125 static int flag_load_fail = 0; 126 static int module_idx=-1; 127 128 if ( flag_load_fail==0 ) 129 { 130 module_idx=module_load(MODULE_NAME_EDGEOVR, bind_module_edgeovr ); 131 if ( module_idx<0 ) { 132 flag_load_fail = 1; 133 module_unload(MODULE_NAME_EDGEOVR); 134 } 135 else { 136 // This library never unloaded once it is loaded 137 // Reason - it should keep its data during whole session 138 module_set_flags(module_idx, MODULE_FLAG_DISABLE_AUTOUNLOAD); 139 } 140 } 141 142 return libedgeovr; 122 // This flag is because edgeovr called each tick 123 // If module loading failed, then do not try to load it until reboot 124 // (otherwise we will try to load module each tick) 125 static int flag_load_fail = 0; 126 127 if ( flag_load_fail==0 ) 128 { 129 module_load_generic((void**)&libedgeovr, MODULE_NAME_EDGEOVR, bind_module_edgeovr, MODULE_FLAG_DISABLE_AUTOUNLOAD); 130 131 if (libedgeovr == 0) 132 flag_load_fail = 1; 133 } 134 135 return libedgeovr; 143 136 } 144 137 … … 147 140 // void module_edgeovr_unload() {} 148 141 142 #endif 143 144 145 /************* DYNAMIC LIBRARY MOTION DETECT ******/ 146 147 #define MODULE_NAME_MDETECT "mdetect.flt" 148 149 struct libmotiondetect_sym* libmotiondetect; 150 151 static int bind_module_motiondetect( void** export_list ) 152 { 153 return bind_module_generic(export_list, (void**)&libmotiondetect, 1, 1, 0); 154 } 155 156 // Return: 0-fail, 1-ok 157 struct libmotiondetect_sym* module_mdetect_load() 158 { 159 return module_load_generic((void**)&libmotiondetect, MODULE_NAME_MDETECT, bind_module_motiondetect, MODULE_FLAG_DISABLE_AUTOUNLOAD); 160 } 161 162 163 /************* DYNAMIC LIBRARY ZEBRA ******/ 164 165 #define MODULE_NAME_ZEBRA "zebra.flt" 166 167 struct libzebra_sym* libzebra; 168 169 static int bind_module_zebra( void** export_list ) 170 { 171 return bind_module_generic(export_list, (void**)&libzebra, 1, 1, 0); 172 } 173 174 // Return: 0-fail, 1-ok 175 struct libzebra_sym* module_zebra_load() 176 { 177 return module_load_generic((void**)&libzebra, MODULE_NAME_ZEBRA, bind_module_zebra, MODULE_FLAG_DISABLE_AUTOUNLOAD); 178 } 179 149 180 150 181 /************* DYNAMIC LIBRARY CURVES ******/ 151 182 183 #if defined(OPT_CURVES) 184 152 185 #define MODULE_NAME_CURVES "curves.flt" 153 186 … … 156 189 static int bind_module_curves( void** export_list ) 157 190 { 158 // Unbind 159 if ( !export_list ) { 160 libcurves=0; 161 return 0; 162 } 163 164 // Bind 165 if ( (unsigned int)export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 166 return 1; 167 if ( (unsigned int)export_list[1] <3 ) 168 return 1; 169 170 libcurves = export_list[2]; 171 172 if ( !libcurves ) 173 return 1; 174 if ( !API_VERSION_MATCH_REQUIREMENT( libcurves->version, 1, 0 ) ) { 175 librawop=0; 176 return 1; 177 } 178 179 return 0; 191 return bind_module_generic(export_list, (void**)&libcurves, 1, 1, 0); 180 192 } 181 193 … … 183 195 struct libcurves_sym* module_curves_load() 184 196 { 185 if (libcurves) 186 return libcurves; 187 188 static int module_idx=-1; 189 190 module_idx=module_load(MODULE_NAME_CURVES, bind_module_curves ); 191 if ( module_idx<0 ) 192 module_unload(MODULE_NAME_CURVES); 193 else { 194 // This library never unloaded once it is loaded 195 // Reason - changing mode mode from LUA stored inside module only 196 module_set_flags(module_idx, MODULE_FLAG_DISABLE_AUTOUNLOAD); 197 198 // Initialize - in module 199 // curve_init_mode(); 200 } 201 202 return libcurves; 197 return module_load_generic((void**)&libcurves, MODULE_NAME_CURVES, bind_module_curves, 0); 198 } 199 200 #endif 201 202 203 /************* DYNAMIC LIBRARY GRIDS ******/ 204 205 #define MODULE_NAME_GRIDS "grids.flt" 206 207 struct libgrids_sym* libgrids; 208 209 static int bind_module_grids( void** export_list ) 210 { 211 return bind_module_generic(export_list, (void**)&libgrids, 1, 1, 0); 212 } 213 214 // Return: 0-fail, addr-ok 215 struct libgrids_sym* module_grids_load() 216 { 217 return module_load_generic((void**)&libgrids, MODULE_NAME_GRIDS, bind_module_grids, 0); 203 218 } 204 219 … … 246 261 } 247 262 248 249 250 263 /************* MODULE DNG ******/ 251 264 … … 256 269 257 270 struct libdng_sym* libdng; 258 259 #if DNG_SUPPORT260 static int bind_module_dng( void** export_list )261 {262 // Unbind263 if ( !export_list ) {264 libdng=0;265 return 0;266 }267 268 // Bind269 if ( (unsigned int)export_list[0] != EXPORTLIST_MAGIC_NUMBER )270 return 1;271 if ( (unsigned int)export_list[1] < 3 )272 return 1;273 274 libdng = export_list[2];275 if ( libdng==0 )276 return 1;277 278 if ( !API_VERSION_MATCH_REQUIREMENT( libdng->version, 1, 0 ) ) {279 libdng=0;280 return 1;281 }282 283 return 0;284 }285 #endif286 271 287 272 void module_dng_unload(int owner) … … 291 276 return; 292 277 293 module_dng_semaphore &=~owner;278 module_dng_semaphore &= ~owner; 294 279 if (module_dng_semaphore) 295 280 return; … … 299 284 } 300 285 286 static int bind_module_dng( void** export_list ) 287 { 288 return bind_module_generic(export_list, (void**)&libdng, 1, 1, 0); 289 } 301 290 302 291 // Return: 0-fail, otherwise - bind list … … 304 293 { 305 294 #if DNG_SUPPORT 306 static int module_idx=-1; 307 308 module_dng_semaphore|=owner; 309 if (libdng) 310 return libdng; 311 312 module_idx=module_load(MODULE_NAME_DNG, bind_module_dng ); 313 if ( module_idx<0 ) { 314 module_unload(MODULE_NAME_DNG); 315 module_dng_semaphore=0; 316 } 317 else { 318 // This module could be unloaded only manualy (because store badpixel) 319 module_set_flags(module_idx, MODULE_FLAG_DISABLE_AUTOUNLOAD); 320 } 321 322 return libdng; 295 module_dng_semaphore |= owner; 296 297 module_load_generic((void**)&libdng, MODULE_NAME_DNG, bind_module_dng, MODULE_FLAG_DISABLE_AUTOUNLOAD); 298 299 if (libdng == 0) 300 module_dng_semaphore=0; 301 302 return libdng; 323 303 #else 324 return 0;304 return 0; 325 305 #endif 326 306 } … … 344 324 #endif 345 325 } 326 327 328 /************* MODULE TBOX ******/ 329 330 static char* tbox_file_buffer = 0; 331 static char* tbox_file_buffer_default = "_tbox.flt"; 332 static int tbox_file_buffer_size = 0; 333 static char* charmap_buffer = 0; 334 static int charmap_buffer_size = 0; 335 336 // Auxilary function - Parse loaded keymap, ask module for its API version 337 // Input values: tbox_file_buffer, tbox_file_buffer_size 338 // Return value: 0-error, otherwise API version 339 //----------------------------------------------------- 340 static int module_tbox_charmap_preprocess() 341 { 342 charmap_buffer = 0; 343 charmap_buffer_size = 0; 344 345 //-- input checks 346 if ( tbox_file_buffer==0 || tbox_file_buffer_size<=0 ) 347 return 0; 348 349 int i, ver; 350 351 //-- Parse: split to lines 352 for( i=0; i<tbox_file_buffer_size; i++ ) 353 if ( tbox_file_buffer[i] == 0x0d || tbox_file_buffer[i] == 0x0a) 354 tbox_file_buffer[i]=0; 355 356 //-- First line is name of tbox module 357 i = strlen(tbox_file_buffer); // size 358 if ( i==0 ) 359 return 0; 360 361 // tbox "run scenario #1" - argc=1, argv=0 - mean "say your API version" 362 ver = module_run(tbox_file_buffer, 0, 1,0, UNLOAD_ALWAYS ); 363 364 // if mistake on load 365 if ( ver<=0 ) 366 return 0; 367 368 charmap_buffer=tbox_file_buffer+i+1; 369 charmap_buffer_size= tbox_file_buffer_size - (i+1); 370 371 return ver; 372 } 373 374 // Check version and existance and tbox api version 375 // return: 0 if no module exists at all, otherwise version of API of current tbox module 376 //----------------------------------------------------- 377 int module_tbox_get_version() 378 { 379 static int last_loaded_tbox_hash = 0; 380 static int cur_tbox_api_version = 0; 381 382 // -- If keymap is loaded and not changed - return stored value 383 384 if ( lang_strhash31((int)conf.charmap_file) == last_loaded_tbox_hash ) 385 return cur_tbox_api_version; 386 387 // -- Free resources 388 389 last_loaded_tbox_hash = 0; 390 if ( tbox_file_buffer && tbox_file_buffer!=tbox_file_buffer_default ) 391 ufree( tbox_file_buffer ); 392 393 // -- Try to load keymap file 394 395 tbox_file_buffer = load_file( conf.charmap_file, &tbox_file_buffer_size ); 396 397 // Check is module available, otherwise try default one 398 399 cur_tbox_api_version = module_tbox_charmap_preprocess(); 400 401 402 // if keymap wrong/module can't be loaded - try default 403 if ( cur_tbox_api_version==0 ) { 404 if ( tbox_file_buffer ) 405 ufree(tbox_file_buffer); 406 407 tbox_file_buffer = tbox_file_buffer_default; 408 tbox_file_buffer_size = strlen(tbox_file_buffer); 409 cur_tbox_api_version = module_tbox_charmap_preprocess(); 410 } 411 412 if ( cur_tbox_api_version ) 413 last_loaded_tbox_hash = lang_strhash31((int)conf.charmap_file); 414 415 return cur_tbox_api_version; 416 } 417 418 419 //----------------------------------------------------- 420 void module_tbox_run( int title, int msg, char* defaultvalue, unsigned int maxsize, void (*on_select)(char* newstr)) 421 { 422 int ver = module_tbox_get_version(); 423 424 if ( API_VERSION_MATCH_REQUIREMENT( ver, 1, 0 ) ) { 425 426 // Main "run scenario" - 7 argument, raise textbox 427 unsigned int argv[] = { (int)charmap_buffer, 428 charmap_buffer_size, 429 title, 430 msg, 431 (unsigned int)defaultvalue, 432 maxsize, 433 (unsigned int)on_select, 434 }; 435 module_run(tbox_file_buffer, 0, sizeof(argv)/sizeof(argv[0]), argv, UNLOAD_IF_ERR); 436 437 } 438 } -
trunk/core/modules.h
r1527 r1569 6 6 #include "raw_merge.h" 7 7 8 struct librawop_sym* module_rawop_load(); // 0fail, addr-ok9 void module_rawop_unload();10 11 12 8 // MODULE "EDGE OVERLAY" 13 9 //-------------------------- 14 10 #include "edgeoverlay.h" 15 11 16 struct libedgeovr_sym* module_edgeovr_load(); // 0fail, addr-ok 12 // MODULE "ZEBRA OVERLAY" 13 //-------------------------- 14 #include "zebra.h" 17 15 18 16 // MODULE "CURVES" … … 20 18 #include "curves.h" 21 19 22 struct libcurves_sym* module_curves_load(); // 0fail, addr-ok 20 // MODULE "MOTION DETECT" 21 //-------------------------- 22 #include "motion_detector.h" 23 24 // MODULE "GRIDS" 25 //-------------------------- 26 #include "gui_grid.h" 23 27 24 28 // MODULE "PALETTE" 25 29 //-------------------------- 26 30 #include "gui_palette.h" 27 void module_palette_run(int mode, color st_color, void (*on_select)(color clr));28 31 29 32 // MODULE "FILE SELECTOR" 30 33 //-------------------------- 31 void module_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn)); 32 void module_fselect_init_w_mode(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn), unsigned int key_redraw_mode); 34 #include "gui_fselect.h" 33 35 34 36 // MODULE "MPOPUP" 35 37 //-------------------------- 36 38 #include "gui_mpopup.h" 37 void module_mpopup_init(struct mpopup_item* popup_actions, const unsigned int flags, void (*on_select)(unsigned int actn), int mode);38 39 39 40 40 // MODULE "DNG" … … 42 42 #include "dng.h" 43 43 44 // values of semaphore 45 #define LIBDNG_OWNED_BY_RAW 0x1 46 #define LIBDNG_OWNED_BY_CONVERT 0x2 47 #define LIBDNG_OWNED_BY_CREATEBADPIXEL 0x4 48 49 struct libdng_sym* module_dng_load(int owner); // 0fail, addr-ok 50 void module_dng_unload(int owner); 51 52 int module_convert_dng_to_chdk_raw(char* fn); // Return: 0-fail, 1-ok 53 54 44 // MODULE "TBOX" 45 //-------------------------- 46 int module_tbox_get_version(); 47 void module_tbox_run( int title, int msg, char* defaultvalue, unsigned int maxsize, void (*on_select)(char* newstr)); 55 48 56 49 #endif -
trunk/core/modules/Makefile
r1558 r1569 18 18 19 19 OBJS=../gui_calendar.o ../gui_bench.o ../gui_4wins.o ../gui_mastermind.o ../gui_reversi.o \ 20 ../gui_sokoban.o ../gui_read.o ../gui_debug.o ../gui_tetris.o ../gui_snake.o ../ dng.o ../gps.o20 ../gui_sokoban.o ../gui_read.o ../gui_debug.o ../gui_tetris.o ../gui_snake.o ../gui_games.o ../dng.o ../gps.o 21 21 22 22 23 23 CFLAGS+=-DOPT_GENERIC_MODULES 24 OPT_OBJS= ../gui_fselect.o ../nothumb.o ../gui_mpopup.o ../curves.o ../edgeoverlay.o ../ gui_palette.o25 OPT_FLT= fselect.flt edgeovr.flt curves.flt mpopup.flt palette.flt 24 OPT_OBJS= ../gui_fselect.o ../nothumb.o ../gui_mpopup.o ../curves.o ../edgeoverlay.o ../bitvector.o ../gui_palette.o ../gui_grid.o ../motion_detector.o ../zebra.o 25 OPT_FLT= fselect.flt edgeovr.flt curves.flt mpopup.flt palette.flt grids.flt mdetect.flt zebra.flt 26 26 27 27 28 28 all: exportlist ../flt.h \ 29 29 _dng.flt benchm.flt calend.flt 4wins.flt mastmind.flt reversi.flt sokoban.flt _rawop10.flt _rawop12.flt \ 30 txtread.flt memview.flt modinsp.flt tetris.flt snake.flt modmenu.flt $(OPT_FLT)30 txtread.flt memview.flt modinsp.flt tetris.flt snake.flt gamemenu.flt modmenu.flt _tbox.flt $(OPT_FLT) 31 31 32 32 %.o: %.c … … 49 49 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 50 50 51 _tbox.elf: ../gui_tbox.o 52 @echo \-\> $@ 53 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 54 51 55 benchm.elf: simple_module.o ../gui_bench.o 52 56 @echo \-\> $@ … … 65 69 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 66 70 67 tetris.elf: ../gui_tetris.o71 tetris.elf: simple_game.o ../gui_tetris.o 68 72 @echo \-\> $@ 69 73 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 70 74 71 snake.elf: ../gui_snake.o75 snake.elf: simple_game.o ../gui_snake.o 72 76 @echo \-\> $@ 73 77 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 74 78 75 79 sokoban.elf: ../gui_sokoban.o