This source file includes following definitions.
- usb_playback_module
- usb_shoot_module_normal
- usb_shoot_module_quick
- usb_shoot_module_burst
- usb_zoom_step
- usb_shoot_module_zoom
- usb_bracketing_done
- usb_shoot_module_bracketing
- usb_video_module_normal
- usb_null_module
1
2
3
4
5
6
7
8
9
10
11
12
13 #include "camera_info.h"
14 #include "clock.h"
15 #include "shooting.h"
16 #include "keyboard.h"
17 #include "conf.h"
18 #include "action_stack.h"
19 #include "usb_remote.h"
20
21
22
23
24
25 #ifdef USB_REMOTE_DEBUGGING
26
27 extern int debug_errors[] ;
28 extern void debug_error(int ) ;
29
30 #else
31
32 extern void debug_error(int ) ;
33
34 #endif
35
36
37
38
39
40
41
42
43 void usb_playback_module()
44 {
45 static int time_stamp = 0 ;
46 static int direction = 0 ;
47 int i, current_time ;
48
49 current_time = get_tick_count();
50
51 switch( logic_module_state )
52 {
53 case LM_RESET :
54 logic_module_state = LM_RELEASE ;
55 break ;
56 case LM_RELEASE :
57 i = get_usb_power(LM_PULSE_COUNT) ;
58 switch( i )
59 {
60 case PLAYBACK_REVERSE :
61 direction = direction ? 0 : 1 ;
62 case PLAYBACK_NEXT :
63 if ( direction ) kbd_key_press(KEY_LEFT);
64 else kbd_key_press(KEY_RIGHT);
65 logic_module_state = LM_KEY_PRESS ;
66 time_stamp = current_time ;
67 break ;
68 case PLAYBACK_LEFT :
69 direction = 0 ;
70 break ;
71 case PLAYBACK_RIGHT :
72 direction = 1 ;
73 break ;
74 default :
75 break ;
76 }
77 break ;
78
79 case LM_KEY_PRESS :
80 if( (current_time - time_stamp) > REMOTE_CLICK_TIME )
81 {
82 if ( direction ) kbd_key_release(KEY_LEFT);
83 else kbd_key_release(KEY_RIGHT);
84 logic_module_state = LM_RELEASE ;
85 }
86 break ;
87
88 default :
89 break ;
90 }
91 }
92
93
94
95
96
97
98
99
100
101
102 void usb_shoot_module_normal()
103 {
104 static AS_ID usb_remote_stack_name = 0;
105
106 if ( conf.synch_enable == 0 )
107 {
108 switch( logic_module_state )
109 {
110 case LM_RESET :
111 kbd_key_release(KEY_SHOOT_FULL);
112 kbd_key_release(KEY_SHOOT_HALF);
113 logic_module_state = LM_RELEASE ;
114 break ;
115 case LM_RELEASE :
116 switch ( virtual_remote_state )
117 {
118 case REMOTE_RELEASE :
119 break ;
120 case REMOTE_HALF_PRESS :
121 kbd_key_press(KEY_SHOOT_HALF);
122 logic_module_state = LM_HALF_PRESS ;
123 break ;
124 case REMOTE_FULL_PRESS:
125 kbd_key_press(KEY_SHOOT_HALF);
126 kbd_key_press(KEY_SHOOT_FULL);
127 logic_module_state = LM_FULL_PRESS ;
128 break ;
129 default :
130 debug_error(INVALID_STATE) ;
131 break ;
132 }
133 break ;
134
135 case LM_HALF_PRESS :
136 switch ( virtual_remote_state )
137 {
138 case REMOTE_RELEASE :
139 kbd_key_release(KEY_SHOOT_HALF);
140 logic_module_state = LM_RELEASE ;
141 break ;
142 case REMOTE_HALF_PRESS :
143 break ;
144 case REMOTE_FULL_PRESS:
145 kbd_key_press(KEY_SHOOT_FULL);
146 logic_module_state = LM_FULL_PRESS ;
147 break ;
148 default :
149 debug_error(INVALID_STATE) ;
150 break ;
151 }
152 break ;
153
154
155 case LM_FULL_PRESS :
156 switch ( virtual_remote_state )
157 {
158 case REMOTE_RELEASE :
159 kbd_key_release(KEY_SHOOT_FULL);
160 kbd_key_release(KEY_SHOOT_HALF);
161 logic_module_state = LM_RELEASE ;
162 break ;
163 case REMOTE_HALF_PRESS:
164 kbd_key_release(KEY_SHOOT_FULL);
165 logic_module_state = LM_HALF_PRESS ;
166 break ;
167 case REMOTE_FULL_PRESS:
168 break ;
169 default :
170 debug_error(INVALID_STATE) ;
171 break ;
172 }
173 break ;
174
175 default :
176 debug_error(INVALID_STATE) ;
177 break ;
178
179 }
180 }
181 else
182 {
183 switch( logic_module_state )
184 {
185 case LM_RESET :
186 logic_module_state = LM_RELEASE ;
187 break ;
188
189 case LM_RELEASE :
190 switch ( virtual_remote_state )
191 {
192 case REMOTE_HALF_PRESS :
193 switch ( switch_type)
194 {
195 case SW_ONE_PRESS :
196 usb_remote_stack_name = action_stack_create(&action_stack_AS_SHOOT);
197 usb_sync_wait_flag = 1;
198 logic_module_state = LM_HALF_PRESS ;
199 break ;
200 case SW_TWO_PRESS :
201 case SW_RICOH_CA1 :
202 kbd_key_press(KEY_SHOOT_HALF);
203 logic_module_state = LM_HALF_PRESS ;
204 break ;
205 default :
206 break ;
207 }
208 break ;
209
210 case REMOTE_RELEASE :
211 case REMOTE_FULL_PRESS:
212 break ;
213 default :
214 debug_error(INVALID_STATE) ;
215 break ;
216 }
217 break ;
218
219 case LM_HALF_PRESS :
220 switch ( virtual_remote_state )
221 {
222 case REMOTE_FULL_PRESS:
223 switch ( switch_type)
224 {
225 case SW_ONE_PRESS :
226 logic_module_state = LM_FULL_PRESS ;
227 break ;
228 case SW_TWO_PRESS :
229 case SW_RICOH_CA1 :
230 usb_sync_wait_flag = 1;
231 kbd_key_press(KEY_SHOOT_FULL);
232 logic_module_state = LM_FULL_PRESS ;
233 break ;
234 default :
235 break ;
236 }
237 break ;
238 case REMOTE_RELEASE :
239 switch ( switch_type)
240 {
241 case SW_ONE_PRESS :
242 if( action_stack_is_finished(usb_remote_stack_name) )
243 {
244 logic_module_state = LM_RELEASE ;
245 }
246 break ;
247 case SW_TWO_PRESS :
248 case SW_RICOH_CA1 :
249 kbd_key_release(KEY_SHOOT_HALF);
250 logic_module_state = LM_RELEASE ;
251 break ;
252 default :
253 break ;
254 }
255 break ;
256 case REMOTE_HALF_PRESS :
257 break ;
258 default :
259 debug_error(INVALID_STATE) ;
260 break ;
261 }
262 break ;
263
264 case LM_FULL_PRESS :
265 switch ( virtual_remote_state )
266 {
267 case REMOTE_RELEASE :
268 switch ( switch_type)
269 {
270 case SW_ONE_PRESS :
271 if( action_stack_is_finished(usb_remote_stack_name) )
272 {
273 logic_module_state = LM_RELEASE ;
274 }
275 break ;
276 case SW_TWO_PRESS :
277 case SW_RICOH_CA1 :
278 usb_sync_wait_flag = 0;
279 logic_module_state = LM_RELEASE ;
280 kbd_key_release(KEY_SHOOT_FULL);
281 kbd_key_release(KEY_SHOOT_HALF);
282 break ;
283 default :
284 break ;
285 }
286 break ;
287 case REMOTE_HALF_PRESS :
288 case REMOTE_FULL_PRESS:
289 break ;
290 default :
291 debug_error(INVALID_STATE) ;
292 break ;
293 }
294 break ;
295 default :
296 debug_error(INVALID_STATE) ;
297 break ;
298 }
299 }
300
301 };
302
303
304
305
306
307
308
309 void usb_shoot_module_quick()
310 {
311 static AS_ID usb_remote_stack_name = 0;
312
313 switch( logic_module_state )
314 {
315 case LM_RESET :
316 logic_module_state = LM_RELEASE ;
317 break ;
318 case LM_RELEASE :
319 switch ( virtual_remote_state )
320 {
321 case REMOTE_RELEASE :
322 break ;
323 case REMOTE_HALF_PRESS :
324 case REMOTE_FULL_PRESS:
325 usb_remote_stack_name = action_stack_create(&action_stack_AS_SHOOT);
326 logic_module_state = LM_FULL_PRESS ;
327 break ;
328 default :
329 debug_error(INVALID_STATE) ;
330 break ;
331 }
332 break ;
333
334 case LM_FULL_PRESS :
335 if (( virtual_remote_state == REMOTE_RELEASE ) && action_stack_is_finished(usb_remote_stack_name) )
336 {
337 logic_module_state = LM_RELEASE ;
338 }
339 break ;
340
341 default :
342 debug_error(INVALID_STATE) ;
343 break ;
344
345 }
346
347 }
348
349
350
351
352
353
354
355
356 void usb_shoot_module_burst()
357 {
358 static AS_ID usb_remote_stack_name = 0;
359
360 switch( logic_module_state )
361 {
362 case LM_RESET :
363 logic_module_state = LM_RELEASE ;
364 break ;
365 case LM_RELEASE :
366 switch ( virtual_remote_state )
367 {
368 case REMOTE_RELEASE :
369 break ;
370 case REMOTE_HALF_PRESS :
371 case REMOTE_FULL_PRESS:
372 usb_remote_stack_name = action_stack_create(&action_stack_AS_SHOOT);
373 logic_module_state = LM_HALF_PRESS ;
374 break ;
375 default :
376 debug_error(INVALID_STATE) ;
377 break ;
378 }
379 break ;
380 case LM_HALF_PRESS :
381 if( action_stack_is_finished(usb_remote_stack_name) )
382 {
383 logic_module_state = LM_RELEASE ;
384 }
385 break ;
386 default :
387 debug_error(INVALID_STATE) ;
388 break ;
389 }
390
391 }
392
393
394
395
396
397
398
399
400
401
402
403
404 void usb_zoom_step(int zdirection)
405 {
406 int zpos, zstep, newzpos ;
407 if (!camera_info.state.mode_play)
408 {
409
410 if (zoom_points <= 16 ) zstep = 1 ;
411 else if (zoom_points <= 32 ) zstep = 2 ;
412 else if (zoom_points <= 64 ) zstep = 6 ;
413 else if (zoom_points <= 110) zstep = 10 ;
414 else if (zoom_points <= 128) zstep = 12 ;
415 else zstep = 20 ;
416 zpos = shooting_get_zoom();
417
418 if(zdirection>0)
419 {
420 if(zpos+zstep+zstep/2<zoom_points)
421 {
422 newzpos = zpos+zstep;
423 }
424 else
425 {
426 newzpos = zoom_points;
427 }
428 }
429 else
430 {
431 if(zpos-zstep-zstep/2>0)
432 {
433 newzpos = zpos-zstep;
434 }
435 else
436 {
437 newzpos = 0;
438 }
439 }
440 shooting_set_zoom(newzpos);
441 }
442 }
443
444 void usb_shoot_module_zoom()
445 {
446 static AS_ID usb_remote_stack_name = 0;
447
448 switch( logic_module_state )
449 {
450 case LM_RESET :
451 logic_module_state = LM_RELEASE ;
452 break ;
453 case LM_RELEASE :
454 switch( get_usb_power(LM_PULSE_COUNT) )
455 {
456 case ZOOM_STEP_OUT :
457 usb_zoom_step(1) ;
458 break ;
459 case ZOOM_STEP_IN :
460 usb_zoom_step(-1);
461 break ;
462 case ZOOM_SHOOT :
463 logic_module_state = LM_FULL_PRESS ;
464 usb_remote_stack_name = action_stack_create(&action_stack_AS_SHOOT);
465 break ;
466 case ZOOM_FULL_OUT :
467 shooting_set_zoom(zoom_points) ;
468 break ;
469 case ZOOM_FULL_IN :
470 shooting_set_zoom(0) ;
471 break ;
472 default :
473 break ;
474 }
475 break ;
476 case LM_FULL_PRESS :
477 if( action_stack_is_finished(usb_remote_stack_name) )
478 {
479 logic_module_state = LM_RELEASE ;
480 }
481 break ;
482 default :
483 break ;
484 }
485 };
486
487
488
489
490
491
492
493 extern void bracketing_step() ;
494 extern void bracketing_reset() ;
495
496 void usb_bracketing_done()
497 {
498 bracketing_reset() ;
499 bracketing_timeout = 0 ;
500 }
501
502
503 void usb_shoot_module_bracketing()
504 {
505 int current_time ;
506
507 current_time = get_tick_count() ;
508
509 switch( logic_module_state )
510 {
511 case LM_RESET :
512 logic_module_state = LM_RELEASE ;
513 break ;
514 case LM_RELEASE :
515 if (( bracketing_timeout ) && ( current_time > bracketing_timeout ) ) usb_bracketing_done() ;
516 switch ( virtual_remote_state )
517 {
518 case REMOTE_RELEASE :
519 break ;
520 case REMOTE_HALF_PRESS :
521 case REMOTE_FULL_PRESS:
522 kbd_key_press(KEY_SHOOT_HALF);
523 logic_module_state = LM_HALF_PRESS ;
524 break ;
525 default :
526 debug_error(INVALID_STATE) ;
527 break ;
528 }
529 break ;
530 case LM_HALF_PRESS :
531 switch ( virtual_remote_state )
532 {
533 case REMOTE_RELEASE :
534 kbd_key_release(KEY_SHOOT_HALF);
535 logic_module_state = LM_RELEASE ;
536 usb_bracketing_done() ;
537 break ;
538 case REMOTE_HALF_PRESS :
539 break ;
540 case REMOTE_FULL_PRESS:
541 if ( shooting_in_progress() )
542 {
543 kbd_key_press(KEY_SHOOT_FULL);
544 logic_module_state = LM_FULL_PRESS ;
545 bracketing_timeout = current_time + BRACKETING_TIMEOUT ;
546 }
547 break ;
548 default :
549 debug_error(INVALID_STATE) ;
550 break ;
551 }
552 break ;
553 case LM_FULL_PRESS :
554 switch ( virtual_remote_state )
555 {
556 case REMOTE_RELEASE :
557 kbd_key_release(KEY_SHOOT_FULL_ONLY);
558 kbd_key_release(KEY_SHOOT_HALF);
559 logic_module_state = LM_RELEASE ;
560 bracketing_step(SET_LATER) ;
561 break ;
562 case REMOTE_HALF_PRESS :
563 kbd_key_release(KEY_SHOOT_FULL_ONLY);
564 logic_module_state = LM_HALF_PRESS ;
565 bracketing_step(SET_LATER) ;
566 break ;
567 case REMOTE_FULL_PRESS:
568 break ;
569 default :
570 debug_error(INVALID_STATE) ;
571 break ;
572 }
573 break ;
574 default :
575 debug_error(INVALID_STATE) ;
576 break ;
577 }
578
579 }
580
581
582
583
584
585
586 void usb_video_module_normal()
587 {
588 int usb_video_button = (camera_info.cam_has_video_button) ? KEY_VIDEO : KEY_SHOOT_FULL;
589
590 switch( logic_module_state )
591 {
592 case LM_RESET :
593 logic_module_state = LM_RELEASE ;
594 break ;
595 case LM_RELEASE :
596 switch ( virtual_remote_state )
597 {
598 case REMOTE_RELEASE :
599 break ;
600 case REMOTE_HALF_PRESS :
601 case REMOTE_FULL_PRESS:
602 kbd_key_press(usb_video_button);
603 logic_module_state = LM_START_RECORD ;
604 break ;
605 default :
606 debug_error(INVALID_STATE) ;
607 break ;
608 }
609 break ;
610 case LM_START_RECORD:
611 switch ( virtual_remote_state )
612 {
613 case REMOTE_RELEASE :
614 logic_module_state = LM_RECORDING ;
615 kbd_key_release(usb_video_button);
616 break ;
617 case REMOTE_HALF_PRESS :
618 case REMOTE_FULL_PRESS:
619 break ;
620 default :
621 debug_error(INVALID_STATE) ;
622 break ;
623 }
624 break;
625 case LM_RECORDING :
626 switch ( virtual_remote_state )
627 {
628 case REMOTE_RELEASE :
629 break ;
630 case REMOTE_HALF_PRESS :
631 case REMOTE_FULL_PRESS:
632 kbd_key_press(usb_video_button);
633 logic_module_state = LM_STOP_RECORDING ;
634 break ;
635 default :
636 debug_error(INVALID_STATE) ;
637 break ;
638 }
639 break;
640 case LM_STOP_RECORDING :
641 switch ( virtual_remote_state )
642 {
643 case REMOTE_RELEASE :
644 logic_module_state = LM_RELEASE ;
645 kbd_key_release(usb_video_button);
646 break ;
647 case REMOTE_HALF_PRESS :
648 case REMOTE_FULL_PRESS:
649 break ;
650 default :
651 debug_error(INVALID_STATE) ;
652 break ;
653 }
654 break;
655 default :
656 debug_error(INVALID_STATE) ;
657 break ;
658 }
659
660 };
661
662
663
664
665
666
667
668
669 void usb_null_module(__attribute__ ((unused))int i) { } ;
670
671
672
673
674 void (*usb_module_play[NUM_USB_MODULES])() =
675 {
676 usb_null_module ,
677 usb_playback_module ,
678 usb_playback_module ,
679 usb_playback_module ,
680 usb_playback_module ,
681 usb_playback_module ,
682 usb_playback_module ,
683 usb_playback_module ,
684 usb_playback_module ,
685 usb_null_module
686 };
687
688
689
690
691 void (*usb_module_shoot[NUM_USB_MODULES])() =
692 {
693 usb_null_module ,
694 usb_shoot_module_normal ,
695 usb_shoot_module_quick ,
696 usb_shoot_module_burst ,
697 usb_shoot_module_bracketing ,
698 usb_shoot_module_zoom ,
699 usb_video_module_normal ,
700 usb_null_module,
701 usb_null_module,
702 usb_null_module
703 };
704
705
706
707
708 void (*usb_module_video[NUM_USB_MODULES])() =
709 {
710 usb_null_module ,
711 usb_video_module_normal ,
712 usb_video_module_normal ,
713 usb_null_module ,
714 usb_null_module ,
715 usb_null_module ,
716 usb_video_module_normal ,
717 usb_null_module ,
718 usb_null_module ,
719 usb_null_module
720 };