This source file includes following definitions.
- dummy_void
- dummy_int
- module_load_rawop
- default_raw_merge_start
- default_raw_subtract
- module_restore_edge
- module_save_edge
- module_edgeovr_load
- default_edge_overlay
- default_load_edge_overlay
- default_md_init_motion_detector
- script_lang_id
- module_set_script_lang
- default_script_start
- default_script_start_file
- default_gui_osd_draw_zebra
- default_histogram_process
- default_gui_osd_draw_histo
- module_curves_load
- default_curve_init_mode
- default_curve_set_mode
- default_curve_set_file
- default_gui_grid_draw_osd
- default_grid_lines_load
- default_show_palette
- default_show_popup
- default_file_select
- default_create_badpixel_bin
- default_capture_data_for_exif
- default_load_bad_pixels_list_b
- default_convert_dng_to_chdk_raw
- default_load_dng_to_rawbuffer
- default_textbox_init
- default_hexbox_init
- default_read_file
- default_shot_histogram_set
- default_shot_histogram_get_range
1
2
3
4
5
6
7
8
9 #include "camera_info.h"
10 #include "console.h"
11 #include "conf.h"
12 #include "modules.h"
13 #include "module_load.h"
14 #include "shooting.h"
15 #include "ctype.h"
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89 static void dummy_void() {}
90 static int dummy_int() { return 0; }
91
92
93
94
95
96
97 extern librawop_sym default_librawop;
98
99 module_handler_t h_rawop =
100 {
101 (base_interface_t**)&librawop,
102 &default_librawop.base,
103 RAW_MERGE_VERSION,
104 "_rawop.flt"
105 };
106
107 static int module_load_rawop()
108 {
109 return module_load(&h_rawop);
110 }
111
112
113 static int default_raw_merge_start(int action)
114 {
115
116 if (module_load_rawop())
117 return librawop->raw_merge_start(action);
118
119
120 return 0;
121 }
122 static int default_raw_subtract(const char *fromName, const char *fromDir, const char *subName, const char *subDir)
123 {
124
125 if (module_load_rawop())
126 return librawop->raw_subtract(fromName, fromDir, subName, subDir);
127
128
129 return 0;
130 }
131
132
133 librawop_sym default_librawop =
134 {
135 { 0,0,0,0,0 },
136 default_raw_merge_start,
137 dummy_int,
138 dummy_void,
139 default_raw_subtract
140 };
141
142
143 librawop_sym* librawop = &default_librawop;
144
145
146
147
148
149
150 static void* saved_edgebuf = 0;
151 static int saved_edgestate = 0;
152
153 int module_restore_edge(void **buf) { *buf = saved_edgebuf; return saved_edgestate; }
154 void module_save_edge(void* buf, int state) { saved_edgebuf = buf; saved_edgestate = state; }
155
156 #define MODULE_NAME_EDGEOVR "edgeovr.flt"
157
158
159 extern libedgeovr_sym default_libedgeovr;
160
161 module_handler_t h_edgeovr =
162 {
163 (base_interface_t**)&libedgeovr,
164 &default_libedgeovr.base,
165 EDGEOVERLAY_VERSION,
166 MODULE_NAME_EDGEOVR
167 };
168
169
170 static int module_edgeovr_load()
171 {
172
173
174
175 static int flag_load_fail = 0;
176
177 if ( flag_load_fail==0 )
178 if (!module_load(&h_edgeovr))
179 flag_load_fail = 1;
180
181 return flag_load_fail == 0;
182 }
183
184
185 static void default_edge_overlay()
186 {
187
188 if (module_edgeovr_load())
189 libedgeovr->edge_overlay();
190 }
191 static void default_load_edge_overlay(const char* fn)
192 {
193
194 if (module_edgeovr_load())
195 libedgeovr->load_edge_overlay(fn);
196 }
197
198
199 libedgeovr_sym default_libedgeovr =
200 {
201 { 0,0,0,0,0 },
202 default_edge_overlay,
203 default_load_edge_overlay,
204 dummy_void,
205 };
206
207
208 libedgeovr_sym* libedgeovr = &default_libedgeovr;
209
210
211
212 #define MODULE_NAME_MDETECT "mdetect.flt"
213
214
215 extern libmotiondetect_sym default_libmotiondetect;
216
217 module_handler_t h_motiondetect =
218 {
219 (base_interface_t**)&libmotiondetect,
220 &default_libmotiondetect.base,
221 MOTION_DETECTOR_VERSION,
222 MODULE_NAME_MDETECT
223 };
224
225
226 static int default_md_init_motion_detector(
227 int columns, int rows, int pixel_measure_mode, int detection_timeout, int measure_interval, int threshold, int draw_grid,
228 int clipping_region_mode, int clipping_region_column1, int clipping_region_row1, int clipping_region_column2, int clipping_region_row2,
229 int parameters, int pixels_step, int msecs_before_trigger)
230 {
231
232 if (module_load(&h_motiondetect))
233 return libmotiondetect->md_init_motion_detector(
234 columns, rows, pixel_measure_mode, detection_timeout, measure_interval, threshold, draw_grid,
235 clipping_region_mode, clipping_region_column1, clipping_region_row1, clipping_region_column2, clipping_region_row2,
236 parameters, pixels_step, msecs_before_trigger);
237
238
239 return 0;
240 }
241
242
243 libmotiondetect_sym default_libmotiondetect =
244 {
245 { 0,0,0,0,0 },
246 dummy_void,
247 default_md_init_motion_detector,
248 dummy_int,
249 dummy_void,
250 dummy_int
251 };
252
253
254 libmotiondetect_sym* libmotiondetect = &default_libmotiondetect;
255
256
257
258 #define MODULE_NAME_UNK "unknown"
259 #define MODULE_NAME_LUA "lua.flt"
260 #define MODULE_NAME_UBASIC "ubasic.flt"
261
262
263 extern libscriptapi_sym default_libscriptapi;
264
265 module_handler_t h_script =
266 {
267 (base_interface_t**)&libscriptapi,
268 &default_libscriptapi.base,
269 SCRIPT_API_VERSION,
270 MODULE_NAME_UNK
271 };
272
273
274 #define SCRIPT_LANG_NONE 0
275 #define SCRIPT_LANG_UBASIC 1
276 #define SCRIPT_LANG_LUA 2
277
278 static int current_lang_id = SCRIPT_LANG_NONE;
279
280 static int script_lang_id(const char* script_file)
281 {
282 if ((script_file == 0) || (script_file[0] == 0))
283 return SCRIPT_LANG_LUA;
284
285 char *ext = strrchr(script_file,'.');
286
287 if (ext && (strlen(ext) == 4) && (toupper(ext[1]) == 'L') && (toupper(ext[2]) == 'U') && (toupper(ext[3]) == 'A'))
288 return SCRIPT_LANG_LUA;
289
290 return SCRIPT_LANG_UBASIC;
291 }
292
293 void module_set_script_lang(const char* script_file)
294 {
295 char* lang_names[] = { MODULE_NAME_UNK, MODULE_NAME_UBASIC, MODULE_NAME_LUA };
296
297 int lang_id = script_lang_id(script_file);
298
299 if (lang_id != current_lang_id)
300 {
301 module_unload(h_script.name);
302 current_lang_id = lang_id;
303 h_script.name = lang_names[lang_id];
304 }
305 }
306
307
308 static int default_script_start(char const* script, int is_ptp)
309 {
310
311 if (module_load(&h_script))
312 return libscriptapi->script_start(script, is_ptp);
313
314
315 return 0;
316 }
317 static int default_script_start_file(char const* filename)
318 {
319
320 if (module_load(&h_script))
321 return libscriptapi->script_start_file(filename);
322
323
324 return 0;
325 }
326
327
328 libscriptapi_sym default_libscriptapi =
329 {
330 { 0,0,0,0,0 },
331 default_script_start,
332 default_script_start_file,
333 dummy_int,
334 dummy_void,
335 dummy_void,
336 dummy_void,
337 dummy_int,
338 dummy_void,
339 };
340
341
342 libscriptapi_sym* libscriptapi = &default_libscriptapi;
343
344
345
346 #define MODULE_NAME_ZEBRA "zebra.flt"
347
348
349 extern libzebra_sym default_libzebra;
350
351 module_handler_t h_zebra =
352 {
353 (base_interface_t**)&libzebra,
354 &default_libzebra.base,
355 ZEBRA_VERSION,
356 MODULE_NAME_ZEBRA
357 };
358
359
360 static int default_gui_osd_draw_zebra(int show)
361 {
362
363 if (module_load(&h_zebra))
364 return libzebra->gui_osd_draw_zebra(show);
365
366
367 return 0;
368 }
369
370
371 libzebra_sym default_libzebra =
372 {
373 { 0,0,0,0,0 },
374 default_gui_osd_draw_zebra
375 };
376
377
378 libzebra_sym* libzebra = &default_libzebra;
379
380
381
382 #define MODULE_NAME_HISTO "histo.flt"
383
384
385 extern libhisto_sym default_libhisto;
386
387 module_handler_t h_histo =
388 {
389 (base_interface_t**)&libhisto,
390 &default_libhisto.base,
391 HISTO_VERSION,
392 MODULE_NAME_HISTO
393 };
394
395
396 static void default_histogram_process()
397 {
398
399 if (module_load(&h_histo))
400 libhisto->histogram_process();
401 }
402
403
404 static void default_gui_osd_draw_histo(int is_osd_edit)
405 {
406 if (is_osd_edit ||
407 ((camera_info.state.mode_play || !camera_info.state.mode_video) &&
408 (
409 ((conf.show_histo==SHOW_HISTO_HALF) && camera_info.state.is_shutter_half_press) ||
410 ((conf.show_histo==SHOW_HISTO_REC) && camera_info.state.mode_rec && (recreview_hold==0)) ||
411 ((conf.show_histo==SHOW_HISTO_ALWAYS) && (recreview_hold==0))
412 )
413 )
414 )
415 {
416
417 if (module_load(&h_histo))
418 libhisto->gui_osd_draw_histo(is_osd_edit);
419 }
420 }
421
422
423 libhisto_sym default_libhisto =
424 {
425 { 0,0,0,0,0 },
426 default_histogram_process,
427 default_gui_osd_draw_histo
428 };
429
430
431 libhisto_sym* libhisto = &default_libhisto;
432
433
434
435 #define MODULE_NAME_CURVES "curves.flt"
436
437
438 extern libcurves_sym default_libcurves;
439
440 module_handler_t h_curves =
441 {
442 (base_interface_t**)&libcurves,
443 &default_libcurves.base,
444 CURVES_VERSION,
445 MODULE_NAME_CURVES
446 };
447
448
449 static int module_curves_load()
450 {
451 if (camera_sensor.bits_per_pixel == 10)
452 return module_load(&h_curves);
453 return 0;
454 }
455
456
457 static void default_curve_init_mode()
458 {
459
460 if (module_curves_load())
461 libcurves->curve_init_mode();
462 }
463 static void default_curve_set_mode()
464 {
465
466 if (module_curves_load())
467 libcurves->curve_set_mode();
468 }
469 static void default_curve_set_file()
470 {
471
472 if (module_curves_load())
473 libcurves->curve_set_file();
474 }
475
476
477 libcurves_sym default_libcurves =
478 {
479 { 0,0,0,0,0 },
480 default_curve_init_mode,
481 dummy_void,
482 default_curve_set_mode,
483 default_curve_set_file
484 };
485
486
487 libcurves_sym* libcurves = &default_libcurves;
488
489
490
491 #define MODULE_NAME_GRIDS "grids.flt"
492
493
494 extern libgrids_sym default_libgrids;
495
496 module_handler_t h_grids =
497 {
498 (base_interface_t**)&libgrids,
499 &default_libgrids.base,
500 GUI_GRID_VERSION,
501 MODULE_NAME_GRIDS
502 };
503
504
505 static void default_gui_grid_draw_osd(int force)
506 {
507
508 if (conf.show_grid_lines)
509 if (module_load(&h_grids))
510 libgrids->gui_grid_draw_osd(force);
511 }
512 static void default_grid_lines_load(const char *fn)
513 {
514
515 if (module_load(&h_grids))
516 libgrids->grid_lines_load(fn);
517 }
518
519
520 libgrids_sym default_libgrids =
521 {
522 { 0,0,0,0,0 },
523 default_gui_grid_draw_osd,
524 default_grid_lines_load
525 };
526
527
528 libgrids_sym* libgrids = &default_libgrids;
529
530
531
532
533 #define MODULE_NAME_PALETTE "palette.flt"
534
535
536 extern libpalette_sym default_libpalette;
537
538 module_handler_t h_palette =
539 {
540 (base_interface_t**)&libpalette,
541 &default_libpalette.base,
542 GUI_PALETTE_VERSION,
543 MODULE_NAME_PALETTE
544 };
545
546
547 static void default_show_palette(int mode, chdkColor st_color, void (*on_select)(chdkColor clr))
548 {
549
550 if (module_load(&h_palette))
551 libpalette->show_palette(mode, st_color, on_select);
552 }
553
554
555 libpalette_sym default_libpalette =
556 {
557 { 0,0,0,0,0 },
558 default_show_palette
559 };
560
561
562 libpalette_sym* libpalette = &default_libpalette;
563
564
565
566 #define MODULE_NAME_MPOPUP "mpopup.flt"
567
568
569 extern libmpopup_sym default_libmpopup;
570
571 module_handler_t h_mpopup =
572 {
573 (base_interface_t**)&libmpopup,
574 &default_libmpopup.base,
575 GUI_MPOPUP_VERSION,
576 MODULE_NAME_MPOPUP
577 };
578
579
580 static void default_show_popup(struct mpopup_item* popup_actions, const unsigned int flags, void (*on_select)(unsigned int actn))
581 {
582
583 if (module_load(&h_mpopup))
584 libmpopup->show_popup(popup_actions, flags, on_select);
585 }
586
587
588 libmpopup_sym default_libmpopup =
589 {
590 { 0,0,0,0,0 },
591 default_show_popup
592 };
593
594
595 libmpopup_sym* libmpopup = &default_libmpopup;
596
597
598
599 #define MODULE_NAME_FSELECT "fselect.flt"
600
601
602 extern libfselect_sym default_libfselect;
603
604 module_handler_t h_fselect =
605 {
606 (base_interface_t**)&libfselect,
607 &default_libfselect.base,
608 GUI_FSELECT_VERSION,
609 MODULE_NAME_FSELECT
610 };
611
612
613 static void default_file_select(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn))
614 {
615
616 if (module_load(&h_fselect))
617 libfselect->file_select(title, prev_dir, default_dir, on_select);
618 }
619
620
621 libfselect_sym default_libfselect =
622 {
623 { 0,0,0,0,0 },
624 default_file_select
625 };
626
627
628 libfselect_sym* libfselect = &default_libfselect;
629
630
631
632 #define MODULE_NAME_DNG "_dng.flt"
633
634
635 extern libdng_sym default_libdng;
636
637 module_handler_t h_dng =
638 {
639 (base_interface_t**)&libdng,
640 &default_libdng.base,
641 DNG_VERSION,
642 MODULE_NAME_DNG
643 };
644
645
646 static void default_create_badpixel_bin()
647 {
648
649 if (module_load(&h_dng))
650 libdng->create_badpixel_bin();
651 }
652 static void default_capture_data_for_exif()
653 {
654
655 if (module_load(&h_dng))
656 libdng->capture_data_for_exif();
657 }
658 static void default_load_bad_pixels_list_b(char* filename)
659 {
660
661 if (module_load(&h_dng))
662 libdng->load_bad_pixels_list_b(filename);
663 }
664 static int default_convert_dng_to_chdk_raw(char* fn)
665 {
666
667 if (module_load(&h_dng))
668 return libdng->convert_dng_to_chdk_raw(fn);
669
670
671 return 0;
672 }
673 static void default_load_dng_to_rawbuffer(char *fn, char *rawadr)
674 {
675
676 if (module_load(&h_dng))
677 libdng->load_dng_to_rawbuffer(fn, rawadr);
678 }
679
680
681 libdng_sym default_libdng =
682 {
683 { 0,0,0,0,0 },
684 default_create_badpixel_bin,
685 dummy_int,
686 default_capture_data_for_exif,
687 default_load_bad_pixels_list_b,
688 dummy_int,
689 default_convert_dng_to_chdk_raw,
690 dummy_int,
691 default_load_dng_to_rawbuffer,
692 dummy_void,
693 dummy_void
694 };
695
696
697 libdng_sym* libdng = &default_libdng;
698
699
700
701 #define MODULE_NAME_TBOX "_tbox.flt"
702
703
704 extern libtextbox_sym default_libtextbox;
705
706 module_handler_t h_textbox =
707 {
708 (base_interface_t**)&libtextbox,
709 &default_libtextbox.base,
710 GUI_TBOX_VERSION,
711 MODULE_NAME_TBOX
712 };
713
714
715 static int default_textbox_init(int title, int msg, const char* defaultstr, unsigned int maxsize, void (*on_select)(const char* newstr), char *input_buffer)
716 {
717
718 if (module_load(&h_textbox))
719 return libtextbox->textbox_init(title,msg,defaultstr,maxsize,on_select,input_buffer);
720
721
722 return 0;
723 }
724
725
726 libtextbox_sym default_libtextbox =
727 {
728 { 0,0,0,0,0 },
729 default_textbox_init,
730 };
731
732
733 libtextbox_sym* libtextbox = &default_libtextbox;
734
735
736
737 #define MODULE_NAME_HEXBOX "_hexbox.flt"
738
739
740 extern libhexbox_sym default_libhexbox;
741
742 module_handler_t h_hexbox =
743 {
744 (base_interface_t**)&libhexbox,
745 &default_libhexbox.base,
746 GUI_HEXBOX_VERSION,
747 MODULE_NAME_HEXBOX
748 };
749
750
751 static int default_hexbox_init(int *num, char *title, int flags)
752 {
753
754 if (module_load(&h_hexbox))
755 return libhexbox->hexbox_init(num, title, flags);
756
757
758 return 0;
759 }
760
761
762 libhexbox_sym default_libhexbox =
763 {
764 { 0,0,0,0,0 },
765 default_hexbox_init,
766 };
767
768
769 libhexbox_sym* libhexbox = &default_libhexbox;
770
771
772
773 #define MODULE_NAME_TXTREAD "txtread.flt"
774
775
776 extern libtxtread_sym default_libtxtread;
777
778 module_handler_t h_txtread =
779 {
780 (base_interface_t**)&libtxtread,
781 &default_libtxtread.base,
782 GUI_READ_VERSION,
783 MODULE_NAME_TXTREAD
784 };
785
786
787 static int default_read_file(const char *fn)
788 {
789
790 if (module_load(&h_txtread))
791 return libtxtread->read_file(fn);
792
793
794 return 0;
795 }
796
797
798 libtxtread_sym default_libtxtread =
799 {
800 { 0,0,0,0,0 },
801 default_read_file,
802 };
803
804
805 libtxtread_sym* libtxtread = &default_libtxtread;
806
807
808
809 #define MODULE_NAME_SHOTHIST "shothist.flt"
810
811
812 extern libshothisto_sym default_libshothisto;
813
814 module_handler_t h_shothisto =
815 {
816 (base_interface_t**)&libshothisto,
817 &default_libshothisto.base,
818 SHOT_HISTO_VERSION,
819 MODULE_NAME_SHOTHIST
820 };
821
822 static int default_shot_histogram_set(int enable)
823 {
824
825 if (enable)
826 if (module_load(&h_shothisto))
827 return libshothisto->shot_histogram_set(enable);
828 return 1;
829 }
830 static int default_shot_histogram_get_range()
831 {
832 return -1;
833 }
834
835
836 libshothisto_sym default_libshothisto=
837 {
838 { 0,0,0,0,0 },
839 default_shot_histogram_set,
840 default_shot_histogram_get_range,
841 dummy_void,
842 dummy_void,
843 };
844
845
846 libshothisto_sym* libshothisto = &default_libshothisto;