source: trunk/core/kbd.c @ 1199

Revision 1199, 38.6 KB checked in by msl, 2 years ago (diff)

Fix overwritten core/kbd.c/kbd.c in changeset 1198
Thx philmoz

  • Property svn:eol-style set to native
Line 
1#include "kbd.h"
2#include "stdlib.h"
3#include "platform.h"
4#include "core.h"
5#include "keyboard.h"
6#include "conf.h"
7#include "action_stack.h"
8#include "camera.h"
9#include "histogram.h"
10#include "gui_lang.h"
11#include "console.h"
12#include "lang.h"
13#include "gui_lang.h"
14
15long kbd_last_clicked;
16int state_kbd_script_run;
17int kbd_blocked;
18static long delay_target_ticks;
19static int soft_half_press = 0;
20static int key_pressed;
21
22// ------ add by Masuji SUTO (start) --------------
23static int mvideo,mplay;
24static int nSW=0;
25static int nRmt=0;
26static int nWt=0;
27static int nCount=0;
28static int nCa=0;
29static int nCount2=0;
30static int nTxvideo=0;
31static int nTxzoom=0;
32static int nTxzname=KEY_ZOOM_IN;
33static int nPlyname=KEY_LEFT;
34static int nIntzpos;
35static int nReczoom=0;
36static int nTxtblcr=0;
37int shutter_int=0;
38
39#if defined(CAMERA_ixus960_sd950)
40static int nFirst=1;
41#endif
42
43#if defined(CAMERA_a450) || defined(CAMERA_ixus50_sd400) || defined(CAMERA_ixusizoom_sd30) || defined(CAMERA_ixus40_sd300) || defined(CAMERA_ixus55_sd450) || defined(CAMERA_ixus60_sd600) || defined(CAMERA_ixus65_sd630) || defined(CAMERA_ixus70_sd1000) || defined(CAMERA_ixus700_sd500) || defined(CAMERA_ixus750_sd550) || defined(CAMERA_ixus850_sd800) || defined(CAMERA_ixus900_sd900) || defined(CAMERA_ixus75_sd750) || defined(CAMERA_a470) || defined(CAMERA_ixus90_sd790) || defined(CAMERA_ixus100_sd780) || defined(CAMERA_ixus120_sd940) || defined(CAMERA_a480) || defined(CAMERA_a495) || defined(CAMERA_d10) || defined(CAMERA_ixus85_sd770) || defined(CAMERA_ixus95_sd1200) || defined(CAMERA_a580) || defined(CAMERA_ixus300_sd4000)
44#define ZSTEP_TABLE_SIZE 7
45static int nTxtbl[]={0,1,2,3,4,5,6};    // remote zoom steps (we need a distinct number of steps, even if the camera zooms smoothly)
46#endif
47
48#if defined(CAMERA_s2is) || defined(CAMERA_s3is) || defined(CAMERA_s5is) || defined(CAMERA_sx10) || defined(CAMERA_sx1)  || defined(CAMERA_sx20)
49#define ZSTEP_TABLE_SIZE 8
50static int nTxtbl[]={0,11,25,41,64,86,105,128};
51#endif
52
53#if defined(CAMERA_sx30)
54#define ZSTEP_TABLE_SIZE 11
55static int nTxtbl[]={0,20,40,60,80,100,120,140,160,180,200};
56#endif
57
58#if defined(CAMERA_tx1)
59#define ZSTEP_TABLE_SIZE 8
60static int nTxtbl[]={0,18,43,55,76,93,113,124};
61#endif
62
63#if defined(CAMERA_a430) || defined(CAMERA_a460) || defined(CAMERA_a530) || defined (CAMERA_a540) || defined(CAMERA_a550) || defined(CAMERA_a560) || defined(CAMERA_a570) || defined(CAMERA_a590) ||defined(CAMERA_ixus860_sd870) || defined(CAMERA_ixus960_sd950) || defined(CAMERA_ixus80_sd1100) || defined(CAMERA_ixus970_sd890) || defined(CAMERA_ixus980_sd990)
64#define ZSTEP_TABLE_SIZE 8
65static int nTxtbl[]={0,1,2,3,4,5,6,7};
66#endif
67
68
69#if defined(CAMERA_a610) ||  defined(CAMERA_a620) || defined(CAMERA_a630) || defined(CAMERA_a640) || defined(CAMERA_ixus800_sd700) || defined(CAMERA_ixus950_sd850)
70#define ZSTEP_TABLE_SIZE 9
71static int nTxtbl[]={0,1,2,3,4,5,6,7,8};
72#endif
73
74#if defined (CAMERA_a700) || defined(CAMERA_a710) || defined (CAMERA_a720) || defined (CAMERA_a2000)
75#define ZSTEP_TABLE_SIZE 8
76static int nTxtbl[]={0,2,4,6,8,10,12,14};
77#endif
78
79#if defined(CAMERA_a650) || defined(CAMERA_g7) || defined(CAMERA_g9)
80#define ZSTEP_TABLE_SIZE 8
81static int nTxtbl[]={0,2,4,6,8,10,12,13};
82#endif
83// ------ add by Masuji SUTO (end)   --------------
84#if defined(CAMERA_sx100is) || defined(CAMERA_sx110is)
85#define ZSTEP_TABLE_SIZE 8
86static int nTxtbl[]={0,3,6,9,13,16,20,23};
87#endif
88
89#if defined(CAMERA_ixus870_sd880)
90#define ZSTEP_TABLE_SIZE 10
91static int nTxtbl[]={0,1,2,3,4,5,6,7,8,9};
92#endif
93
94#if defined(CAMERA_sx200is) || defined(CAMERA_sx130is)
95#define ZSTEP_TABLE_SIZE 7
96static int nTxtbl[]={0,16,32,62,78,102,125};
97#endif
98
99#if defined(CAMERA_g11) || defined(CAMERA_g12)
100#define ZSTEP_TABLE_SIZE 14
101static int nTxtbl[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13};
102#endif
103#if defined(CAMERA_s90) || defined(CAMERA_s95)
104#define ZSTEP_TABLE_SIZE 10
105static int nTxtbl[]={0,1,2,3,4,5,6,7,8,9};
106#endif
107
108#ifdef OPT_SCRIPTING
109// remote autostart
110void script_autostart()
111{
112    kbd_blocked = 1;
113    gui_kbd_enter();
114    console_clear();
115    script_console_add_line("***Autostart***"); //lang_str(LANG_CONSOLE_TEXT_STARTED));
116    script_start_gui( 1 );
117}
118#endif
119
120void exit_alt()
121{
122    kbd_blocked = 0;
123    gui_kbd_leave();
124}
125
126// ------ add by Masuji SUTO (start) --------------
127void set_key_press(int nSet)
128{
129        key_pressed = nSet;
130        kbd_blocked = nSet;
131        nRmt = nSet;
132}
133// ------ add by Masuji SUTO (end) --------------
134
135/*------------------- Alex scriptless remote additions start --------------------*/
136static int remoteHalfShutter=0, remoteFullShutter=0, remoteShooting=0, remoteClickTimer=0;
137#define REMOTE_MAX_CLICK_LENGTH 50
138/*-------------------- Alex scriptless remote additions end ---------------------*/
139
140/*
141    main kb processing
142    this monster needs to be broken up and documented, remote stuff should go in it's own functions
143*/
144long kbd_process()
145{
146/* Alternative keyboard mode stated/exited by pressing print key.
147 * While running Alt. mode shoot key will start a script execution.
148 */
149    static int nCER=0;
150// ------ modif by Masuji SUTO (start) --------------
151
152    unsigned int mmode;
153    unsigned int nCrzpos,i;
154    unsigned int drmode = 0;
155
156    if(conf.ricoh_ca1_mode && conf.remote_enable) {
157        drmode = shooting_get_drive_mode();
158        mmode = mode_get();
159        mplay = (mmode&MODE_MASK)==MODE_PLAY;
160//      mvideo= ((mmode&MODE_SHOOTING_MASK)==MODE_VIDEO_STD || (mmode&MODE_SHOOTING_MASK)==MODE_VIDEO_SPEED || (mmode&MODE_SHOOTING_MASK)==MODE_VIDEO_COMPACT ||(mmode&MODE_SHOOTING_MASK)==MODE_VIDEO_MY_COLORS || (mmode&MODE_SHOOTING_MASK)==MODE_VIDEO_COLOR_ACCENT);
161        mvideo=MODE_IS_VIDEO(mmode);
162    }
163    // deals with alt-mode switch and delay emulation
164    if (key_pressed) {
165        if (kbd_is_key_pressed(conf.alt_mode_button)
166                || ((key_pressed >= CAM_EMUL_KEYPRESS_DELAY)
167                && (key_pressed < CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION))) {
168            if (key_pressed <= CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION)
169                key_pressed++;
170            if (key_pressed == CAM_EMUL_KEYPRESS_DELAY)
171                kbd_key_press(conf.alt_mode_button);
172            else if (key_pressed == +CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION)
173                kbd_key_release(conf.alt_mode_button);
174            return 1;
175        } else if (kbd_get_pressed_key() == 0) {
176            if (key_pressed != 100 && (key_pressed < CAM_EMUL_KEYPRESS_DELAY)) {
177                kbd_blocked = 1-kbd_blocked;
178                if (kbd_blocked)
179                    gui_kbd_enter();
180                else
181                    gui_kbd_leave();
182            }
183            key_pressed = 0;
184            return 1;
185        }
186        return 1;
187    }
188
189    // auto iso shift
190    if (kbd_is_key_pressed(KEY_SHOOT_HALF) && kbd_is_key_pressed(conf.alt_mode_button))
191        return 0;
192
193    if (kbd_is_key_pressed(conf.alt_mode_button)) {
194        if (conf.ricoh_ca1_mode && conf.remote_enable)
195            conf.synch_enable=1;
196        key_pressed = 1;
197        kbd_key_release_all();
198        return 1;
199    }
200
201    // deals with the rest
202    if (kbd_blocked && nRmt==0) {
203/*------------------- Alex scriptless remote additions start --------------------*/
204        if (remoteShooting) {
205            if (remoteHalfShutter) {
206                if (get_usb_power(1)) {
207                    if (remoteClickTimer < REMOTE_MAX_CLICK_LENGTH) {
208                        remoteHalfShutter=0;
209                        remoteFullShutter=1;
210                        kbd_key_press(KEY_SHOOT_FULL);
211                    }
212                    return 1;
213                } else {
214                    --remoteClickTimer;
215                    if ( remoteClickTimer == 0 ) {
216                        kbd_key_release_all();
217                        remoteHalfShutter=0;
218                        remoteShooting=0;
219                        kbd_blocked=0;
220                        return 0;
221                    }
222                }
223            }
224
225            if (remoteFullShutter) {
226                if (get_usb_power(1)) {
227                    return 1;
228                } else {
229                    kbd_key_release_all();
230                    remoteFullShutter=0;
231                    remoteShooting=0;
232                    kbd_blocked=0;
233                    return 0;
234                }
235            }
236        }
237/*-------------------- Alex scriptless remote additions end ---------------------*/
238#ifdef OPT_SCRIPTING
239        if (kbd_is_key_pressed(KEY_SHOOT_FULL)) {
240            key_pressed = 100;
241            if (!state_kbd_script_run) {
242                script_start_gui(0);
243            } else if (state_kbd_script_run == 2 || state_kbd_script_run == 3) {
244                script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
245                script_end();
246            }
247#ifdef OPT_LUA
248            else if (L) {
249                state_kbd_script_run = 2;
250                                lua_run_restore();
251                script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
252                script_end();
253            }
254#endif
255#ifdef OPT_UBASIC
256            else {
257                state_kbd_script_run = 2;
258                if (jump_label("restore") == 0) {
259                    script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
260                    script_end();
261                }
262            }
263#endif
264        }
265#endif
266
267        action_stack_process_all();
268        if (!state_kbd_script_run)
269            gui_kbd_process();
270    } else {
271#ifndef SYNCHABLE_REMOTE_NOT_ENABLED
272        if(conf.ricoh_ca1_mode && conf.remote_enable) {
273// ------ add by Masuji SUTO (start) --------------
274            if(nWt>0) {
275                nWt--;
276                return 1;
277            }
278#if defined(CAMERA_ixus960)
279            if(nFirst==1) {
280                if(nSW==0) {
281                    nSW=1;
282                    nWt=10;
283                    kbd_key_release_all();
284                    kbd_key_press(KEY_SHOOT_HALF);
285                    soft_half_press = 1;
286                    set_key_press(1);
287                    return 1;
288                } else if(nSW==1) {
289                    nSW=2;
290                    nWt=10;
291                    kbd_key_release(KEY_SHOOT_HALF);
292                    soft_half_press = 0;
293                    set_key_press(1);
294                    return 1;
295                } else if(nSW==2) {
296                    set_key_press(0);
297                    nWt=10;
298                    nSW=0;
299                    nFirst=0;
300                    return 1;
301                }
302            }
303#endif // CAMERA_ixus960
304            if (kbd_is_key_pressed(KEY_SHOOT_FULL))
305                conf.synch_enable=0;
306            if (kbd_is_key_pressed(KEY_SHOOT_HALF) && nTxzoom>0) {
307                nCount2=0;
308                nTxzoom=0;
309                nReczoom=0;
310                nTxvideo=0;
311                debug_led(0);
312            }
313            if (mplay && (kbd_is_key_pressed(KEY_LEFT) || kbd_is_key_pressed(KEY_RIGHT))) {
314                nPlyname=KEY_LEFT;
315                if(kbd_is_key_pressed(KEY_RIGHT))
316                    nPlyname=KEY_RIGHT;
317            }
318            if (kbd_is_key_pressed(KEY_VIDEO)) {
319                nCount2=0;
320                nTxzoom=0;
321                nReczoom=0;
322                nTxvideo++;
323                if(nTxvideo<50) {
324                    kbd_key_release_all();
325                    debug_led(1);
326                } else {
327                    debug_led(0);
328                    return 0;
329                }
330                return 1;
331            }
332            else if(nTxvideo>49)
333                nTxvideo=0;
334            if (kbd_is_key_pressed(KEY_ZOOM_IN) || kbd_is_key_pressed(KEY_ZOOM_OUT)) {
335                nCount2=0;
336                nTxvideo=0;
337                if(kbd_is_key_pressed(KEY_ZOOM_IN)) {
338                    if(nTxzname==KEY_ZOOM_IN)
339                        nTxzoom++;
340                    else
341                        nTxzoom=1;
342                    nTxzname=KEY_ZOOM_IN;
343                } else {
344                    if(nTxzname==KEY_ZOOM_OUT)
345                        nTxzoom++;
346                    else
347                        nTxzoom=1;
348                    nTxzname=KEY_ZOOM_OUT;
349                }
350                if(nTxzoom<50) {
351                    kbd_key_release_all();
352                    debug_led(1);
353                } else {
354                    debug_led(0);
355                    return 0;
356                }
357                return 1;
358            }
359            if(!get_usb_power(1) && nSW<100 && nCount==0 && nTxzoom>0) {
360                nCount2++;
361                if(nCount2>conf.zoom_timeout*100) {
362                    if(nTxzoom>0) {
363                        nTxzoom=0;
364                        nReczoom=0;
365                        debug_led(0);
366                    }
367                    nCount2=0;
368                }
369                return 1;
370            }
371            if(get_usb_power(1) && nSW<100 && nCount==0) {
372                nCount2=0;
373                kbd_key_release_all();
374                conf.synch_enable=1;
375            }
376            if(get_usb_power(1) && nSW<100 && nCount==0) {
377                kbd_key_release_all();
378                conf.synch_enable=1;
379            }
380            if(get_usb_power(1) && nSW<100 && nCount<6) {
381                nCount++;
382                return 1;
383            }
384            if(nCount>0 && nSW<100) {
385                if(mplay) {
386                    if(get_usb_power(1))
387                        return 1;
388                    kbd_key_release_all();
389                    kbd_key_press(nPlyname);
390                    set_key_press(1);
391                    nCount=0;
392                    nCa=2;
393                    nSW=101;
394                    nWt=5;
395                    return 1;
396                }
397                if(nTxvideo>49)
398                    nTxvideo=0;
399                if(nCount<5)
400                    nCa=1;                //for Richo remote switch CA-1
401                else
402                    nCa=2;                                //for hand made remote switch
403
404                nCount=0;
405//              debug_led(1);
406                nSW=109;
407            }
408
409// -------------------------------------------------------------  hand made switch  --------------
410
411            if(nCa==2) {
412                if(nSW==101) {
413                    kbd_key_release_all();
414                    set_key_press(0);
415                    nWt=50;
416                    nSW=0;
417                    nCa=0;
418                    return 1;
419                }
420                if(nSW==109) {
421//                  nSW=110;
422                    nCER=0;
423                    if(nTxzoom>0 && conf.remote_zoom_enable) {
424                        if(nTxzoom<100) {
425                            nIntzpos=lens_get_zoom_point();
426                            for(i=0;i<ZSTEP_TABLE_SIZE;i++) {
427                                if(nIntzpos<=nTxtbl[i]) {
428                                    if(i>0) {
429                                        if(abs(nTxtbl[i]-nIntzpos)<=abs(nTxtbl[i-1]-nIntzpos))
430                                            nTxtblcr=i;
431                                        else
432                                            nTxtblcr=i-1;
433                                    }
434                                    else nTxtblcr=i;
435                                    i=ZSTEP_TABLE_SIZE;
436                                }
437                            }
438                            if(nTxzname==KEY_ZOOM_IN) {
439                                nTxtblcr++;
440                                if(nTxtblcr>(ZSTEP_TABLE_SIZE-1))
441                                    nTxtblcr=(ZSTEP_TABLE_SIZE-1);
442                            } else {
443                                nTxtblcr--;
444                                if(nTxtblcr<0)
445                                    nTxtblcr=0;
446                            }
447                            nSW=108;
448                            return 1;
449                        }
450                        nTxzoom=0;
451                        nReczoom=0;
452                    }
453                    if(nTxvideo>0 && conf.remote_zoom_enable) {
454                        nSW=121;
455                        return 1;
456                    }
457                    nSW=110;
458                    nWt=2;
459                    kbd_key_release_all();
460                    kbd_key_press(KEY_SHOOT_HALF);
461//                  key_pressed = 1;
462//                  kbd_blocked = 1;
463//                  nRmt=1;
464                    soft_half_press = 1;
465                    set_key_press(1);
466                    return 1;
467                }
468                if(nTxzoom>0 && nSW==108 && conf.remote_zoom_enable) {
469                    nCrzpos=lens_get_zoom_point();
470                    if(nIntzpos!=nCrzpos) {
471                        nReczoom=0;
472                    }
473                    if(nIntzpos==nCrzpos && nCER>50) {
474                        if(!get_usb_power(1)) {
475                            kbd_key_release_all();
476                            set_key_press(0);
477                            nTxzoom=1;
478                            nSW=0;
479                            nCount=0;
480                            nWt=10;
481                            nReczoom=1;
482                            return 1;
483                        }
484                    }
485                    if(nReczoom==0 && ((nTxzname==KEY_ZOOM_IN && nCrzpos>=nTxtbl[nTxtblcr])
486                            || (nTxzname==KEY_ZOOM_OUT && nCrzpos<=nTxtbl[nTxtblcr]))) {
487                        if(get_usb_power(1)) {
488                            i=1;
489                            if(nTxzname==KEY_ZOOM_IN) {
490                                nTxtblcr++;
491                                if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)) {
492                                    nTxtblcr=(ZSTEP_TABLE_SIZE-1);
493                                    nTxzname=KEY_ZOOM_OUT;
494                                }
495                            } else {
496                                nTxtblcr--;
497                                if(nTxtblcr<0){
498                                    nTxtblcr=0;
499                                    nTxzname=KEY_ZOOM_IN;
500                                }
501                            }
502                            if(i==1)
503                                return 1;
504                        }
505                        kbd_key_release_all();
506                        set_key_press(0);
507                        nTxzoom=1;
508//                      lens_set_zoom_speed(25);
509                        nSW=120;
510                        nWt=5;
511                        return 1;
512                    }
513                    kbd_key_release_all();
514                    kbd_key_press(nTxzname);
515                    set_key_press(1);
516                    nCER++;
517                    return 1;
518                }
519
520                if(nTxvideo>0 && nSW==121) {
521                    if(!get_usb_power(1)) {
522                        nWt=10;
523                        kbd_key_press(KEY_VIDEO);
524                        set_key_press(1);
525                        nSW=122;
526                    }
527                    return 1;
528                }
529                if(nTxvideo>0 && nSW==122) {
530                    nWt=10;
531                    kbd_key_release(KEY_VIDEO);
532                    set_key_press(1);
533                    nSW=123;
534                    return 1;
535                }
536                if(nTxvideo>0 && nSW==123) {
537                    set_key_press(0);
538                    nWt=50;
539                    nSW=0;
540                    nCa=0;
541                    nTxvideo=0;
542                    debug_led(0);
543                    return 1;
544                }
545
546                if(nSW==110) {
547                    if (shooting_in_progress() || mvideo || nCER>100) {
548                        state_expos_recalculated = 0;
549                        histogram_restart();
550                        nCER=0;
551                        nSW=111;
552                    } else {
553                        nCER++;return 1;
554                    }
555                }
556                if(nSW==111) {
557                    if (state_expos_recalculated || nCER>100) {
558                        state_expos_under = under_exposed;
559                        state_expos_over = over_exposed;
560                        nCER=0;
561                        nSW=112;
562                        //presynch();
563                    } else {
564                        nCER++;
565                        return 1;
566                    }
567                }
568                if(nSW==112) {
569                    if (shooting_is_flash_ready() || nCER>10) {
570                        nCER=0;
571                        nSW=113;
572                    } else {
573                        nCER++;
574                        return 1;
575                    }
576                }
577                if(nSW==113) {
578                    if(get_usb_power(1) && !mvideo)
579                        nSW=114;
580                    else if(!get_usb_power(1) && mvideo)
581                        nSW=114;
582                    else
583                        return 1;
584                }
585                if(nTxzoom>0 && nSW==120 && conf.remote_zoom_enable) {
586                    nCrzpos=lens_get_zoom_point();
587                    if((nTxzname==KEY_ZOOM_IN && nCrzpos<=nTxtbl[nTxtblcr])
588                            || (nTxzname==KEY_ZOOM_OUT && nCrzpos>=nTxtbl[nTxtblcr])) {
589                        kbd_key_release_all();
590                        set_key_press(0);
591                        nTxzoom=1;
592                        lens_set_zoom_speed(100);
593                        nSW=0;
594                        nCount=0;
595                        nWt=10;
596                        return 1;
597                    }
598                    lens_set_zoom_speed(5);
599                    kbd_key_release_all();
600                    if(nTxzname==KEY_ZOOM_IN)
601                        kbd_key_press(KEY_ZOOM_OUT);
602                    else
603                        kbd_key_press(KEY_ZOOM_IN);
604                    set_key_press(1);
605                    return 1;
606                }
607
608                if(nSW==114) {
609                    nSW=115;
610                    nWt=2;
611                    shutter_int=0;
612                    kbd_key_press(KEY_SHOOT_FULL);
613                    set_key_press(1);
614//                  kbd_blocked = 1;
615//                  nRmt=1;
616                    nCount=0;
617                    return 1;
618                }
619                if(nSW==115) {
620//                  debug_led(0);
621                    if(drmode==1 && shutter_int==0) {
622                        return 1;
623                    }
624                    nSW=116;
625                    nWt=2;
626                    kbd_key_release(KEY_SHOOT_FULL);
627                    set_key_press(1);
628                    soft_half_press = 0;
629//                  kbd_blocked = 1;
630//                  nRmt=1;
631                    return 1;
632                }
633                if(!get_usb_power(1) && nSW==116) {
634                    set_key_press(0);
635//                  kbd_blocked = 0;
636//                  key_pressed = 0;
637                    nWt=50;
638                    nSW=0;
639//                  nRmt=0;
640                    nCa=0;
641                    //postsynch();
642                    return 1;
643                }
644            }
645
646// -------------------------------------------------------------  Ricoh remote switch CA-1 --------------
647            if(nCa==1) {
648                if(get_usb_power(1) && nSW>108 && nSW<120) {
649                    nCount++;
650                }
651                if(nSW==109) {
652//                  nSW=110;
653                    nCER=0;
654                    if(nTxzoom>0 && conf.remote_zoom_enable) {
655                        if(nTxzoom<100) {
656                            nIntzpos=lens_get_zoom_point();
657                            for(i=0;i<ZSTEP_TABLE_SIZE;i++) {
658                                if(nIntzpos<=nTxtbl[i]) {
659                                    if(i>0) {
660                                        if(abs(nTxtbl[i]-nIntzpos)<=abs(nTxtbl[i-1]-nIntzpos))
661                                            nTxtblcr=i;
662                                        else
663                                            nTxtblcr=i-1;
664                                    }
665                                    else
666                                        nTxtblcr=i;
667                                    i=ZSTEP_TABLE_SIZE;
668                                }
669                            }
670                            if(nTxzname==KEY_ZOOM_IN) {
671                                nTxtblcr++;
672                                if(nTxtblcr>(ZSTEP_TABLE_SIZE-1))
673                                    nTxtblcr=(ZSTEP_TABLE_SIZE-1);
674                            }
675                            else {
676                                nTxtblcr--;
677                                if(nTxtblcr<0)
678                                    nTxtblcr=0;
679                            }
680                            nSW=113;
681                            return 1;
682                        }
683                        nTxzoom=0;
684                        nReczoom=0;
685                    }
686                    if(nTxvideo>0 && conf.remote_zoom_enable) {
687                        nSW=121;
688                        return 1;
689                    }
690                    nSW=110;
691                    nWt=2;
692                    kbd_key_release_all();
693                    kbd_key_press(KEY_SHOOT_HALF);
694//                  debug_led(1);
695                    soft_half_press = 1;
696                    set_key_press(1);
697//                  key_pressed = 1;
698//                  kbd_blocked = 1;
699//                  nRmt=1;
700                    return 1;
701                }
702                if(nTxvideo>0 && nSW==121) {
703                    if(get_usb_power(1)) {
704                        nWt=10;
705                        kbd_key_press(KEY_VIDEO);
706                        set_key_press(1);
707                        nSW=122;
708                    }
709                    return 1;
710                }
711                if(nTxvideo>0 && nSW==122) {
712                    nWt=10;
713                    kbd_key_release(KEY_VIDEO);
714                    set_key_press(1);
715                    nSW=123;
716                    return 1;
717                }
718                if(nTxvideo>0 && nSW==123) {
719                    set_key_press(0);
720                    nWt=100;
721                    nCount=0;
722                    nSW=0;
723                    nCa=0;
724                    nTxvideo=0;
725                    debug_led(0);
726                    return 1;
727                }
728
729                if(nSW==110) {
730                    if (shooting_in_progress() || mvideo || nCER>100) {
731//                      debug_led(0);
732                        state_expos_recalculated = 0;
733                        histogram_restart();
734                        nCER=0;
735                        nSW=111;
736                    } else {
737                        nCER++;
738                        return 1;
739                    }
740                }
741                if(nSW==111) {
742                    if (state_expos_recalculated || nCER>100) {
743                        state_expos_under = under_exposed;
744                        state_expos_over = over_exposed;
745                        nCER=0;
746                        nSW=112;
747                        //presynch();
748                    } else {
749                        nCER++;
750                        return 1;
751                    }
752                }
753                if(nSW==112) {
754                    if (shooting_is_flash_ready() || nCER>10) {
755                        nCER=0;
756                        nSW=113;
757                    } else {
758                        nCER++;
759                        return 1;
760                    }
761                }
762                if(nTxzoom>0 && nSW==114 && conf.remote_zoom_enable) {
763                    nCrzpos=lens_get_zoom_point();
764                    if(nIntzpos!=nCrzpos) {
765                        nReczoom=0;
766                    }
767                    if(nIntzpos==nCrzpos && nCER>50) {
768                        if(nCount>0) {
769                            kbd_key_release_all();
770                            set_key_press(0);
771                            nTxzoom=1;
772                            nSW=0;
773                            nCount=0;
774                            nWt=10;
775                            nReczoom=1;
776                            return 1;
777                        }
778                    }
779                    if(nReczoom==0 && ((nTxzname==KEY_ZOOM_IN && nCrzpos>=nTxtbl[nTxtblcr])
780                                || (nTxzname==KEY_ZOOM_OUT && nCrzpos<=nTxtbl[nTxtblcr]))) {
781                        if(nCount==0) {
782                            i=1;
783                            if(nTxzname==KEY_ZOOM_IN){
784                                nTxtblcr++;
785                                if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)){
786                                    nTxtblcr=(ZSTEP_TABLE_SIZE-1);
787                                    nTxzname=KEY_ZOOM_OUT;
788                                }
789                            } else {
790                                nTxtblcr--;
791                                if(nTxtblcr<0) {
792                                    nTxtblcr=0;
793                                    nTxzname=KEY_ZOOM_IN;
794                                }
795                            }
796                            if(i==1)
797                                return 1;
798                        }
799                        kbd_key_release_all();
800                        set_key_press(0);
801                        nTxzoom=1;
802//                      lens_set_zoom_speed(25);
803                        nSW=115;
804                        nWt=5;
805                        return 1;
806                    }
807                    kbd_key_release_all();
808                    kbd_key_press(nTxzname);
809                    set_key_press(1);
810                    nCER++;
811                    return 1;
812                }
813                if(nTxzoom>0 && nSW==115 && conf.remote_zoom_enable) {
814                    if(nCount==0)
815                        return 1;
816                    nCrzpos=lens_get_zoom_point();
817                    if((nTxzname==KEY_ZOOM_IN && nCrzpos<=nTxtbl[nTxtblcr])
818                            || (nTxzname==KEY_ZOOM_OUT && nCrzpos>=nTxtbl[nTxtblcr])) {
819                        kbd_key_release_all();
820                        set_key_press(0);
821                        nTxzoom=1;
822                        lens_set_zoom_speed(100);
823                        nSW=0;
824                        nCount=0;
825                        nWt=10;
826                        return 1;
827                    }
828                    lens_set_zoom_speed(5);
829                    kbd_key_release_all();
830                    if(nTxzname==KEY_ZOOM_IN)
831                        kbd_key_press(KEY_ZOOM_OUT);
832                    else
833                        kbd_key_press(KEY_ZOOM_IN);
834                    set_key_press(1);
835                    return 1;
836                }
837
838                if(get_usb_power(1)) {
839                    return 1;
840                }
841                if(nCount>0 && nSW==113) {
842                    if(nCount<9) {
843                        if(nTxzoom>0 && conf.remote_zoom_enable) {
844                            kbd_key_release_all();
845                            set_key_press(0);
846                            nTxzoom=0;
847                            nReczoom=0;
848                            nSW=0;
849                            nCa=0;
850                            nCount=0;
851                            nWt=10;
852//                          lens_set_zoom_speed(100);
853                            debug_led(0);
854                            return 1;
855                        }
856                        nSW=125;
857                        nWt=10;
858                        kbd_key_release(KEY_SHOOT_HALF);
859                        soft_half_press = 0;
860                        set_key_press(1);
861//                      kbd_blocked = 1;
862//                      nRmt=1;
863                        nCount=0;
864                        return 1;
865                    } else {
866                        if(nTxzoom>0 && conf.remote_zoom_enable) {
867                            nCount=0;
868                            nSW=114;
869                            return 1;
870                        }
871                        nSW=124;
872                        nWt=2;
873                        shutter_int=0;
874//                      debug_led(0);
875                        kbd_key_press(KEY_SHOOT_FULL);
876                        set_key_press(1);
877//                      kbd_blocked = 1;
878//                      nRmt=1;
879                        nCount=0;
880                        return 1;
881                    }
882                }
883                if(nSW==124) {
884//                  debug_led(0);
885                    if(drmode==1 && shutter_int==0) {
886                        return 1;
887                    }
888                    nSW=125;
889                    nWt=2;
890                    kbd_key_release(KEY_SHOOT_FULL);
891                    soft_half_press = 0;
892                    set_key_press(1);
893//                  kbd_blocked = 1;
894//                  nRmt=1;
895                    return 1;
896                }
897                if(!get_usb_power(1) && nSW==125) {
898                    set_key_press(0);
899//                  kbd_blocked = 0;
900//                  key_pressed = 0;
901                    nWt=50;
902                    nSW=0;
903//                  nRmt=0;
904                    nCa=0;
905                    //postsynch();
906                    return 1;
907                }
908            }
909// ------ add by Masuji SUTO (end)   --------------
910        } // ricoh_ca1_mode
911#endif // ifndef SYNCHABLE_REMOTE_NOT_ENABLED
912/*------------------- Alex scriptless remote additions start --------------------*/
913        if (conf.remote_enable && !conf.ricoh_ca1_mode && key_pressed != 2 && get_usb_power(1)) {
914            remoteShooting = 1;
915            kbd_blocked = 1;
916            kbd_key_release_all();
917            remoteClickTimer = REMOTE_MAX_CLICK_LENGTH;
918            if (shooting_get_focus_mode()) {
919                remoteFullShutter = 1;
920                kbd_key_press(KEY_SHOOT_FULL);
921            } else {
922                remoteHalfShutter = 1;
923                kbd_key_press(KEY_SHOOT_HALF);
924            }
925            return 1;
926        }
927/*-------------------- Alex scriptless remote additions end ---------------------*/
928#ifdef CAM_USE_ZOOM_FOR_MF
929        if (conf.use_zoom_mf && kbd_use_zoom_as_mf()) {
930            return 1;
931        }
932#endif // ifdef CAM_USE_ZOOM_FOR_MF
933        if ((conf.fast_ev || conf.fast_movie_control || conf.fast_movie_quality_control)
934                && kbd_use_up_down_left_right_as_fast_switch()) {
935            return 1;
936        }
937        other_kbd_process(); // processed other keys in not <alt> mode
938    }
939
940    return kbd_blocked;
941}
942
943int kbd_is_blocked() {
944        return kbd_blocked;
945}
946
947void kbd_set_block(int bEnableBlock) {
948    kbd_blocked = bEnableBlock ? 1 : 0;
949}
950
951long kbd_use_up_down_left_right_as_fast_switch() {
952    static long key_pressed = 0; // ??? static masking a global
953    int m=mode_get();
954    int mode_video = MODE_IS_VIDEO(m) || (movie_status > 1);
955    int ev_video=0;
956    int jogdial;
957
958#if CAM_EV_IN_VIDEO
959    ev_video=get_ev_video_avail();
960#endif
961
962    if (!(kbd_is_key_pressed(KEY_UP)) && !(kbd_is_key_pressed(KEY_DOWN))) key_pressed = 0;
963
964    if (canon_shoot_menu_active!=0 || (m&MODE_MASK) != MODE_REC)
965        return 0;
966
967#if !CAM_HAS_JOGDIAL
968    if (kbd_is_key_pressed(KEY_UP) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) {
969        if (conf.fast_ev && key_pressed == 0) {
970            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)+(conf.fast_ev_step+1)*16);
971            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)+(conf.fast_ev_step+1)*16);
972            EnterToCompensationEVF();
973            key_pressed = KEY_UP;
974
975            return 1;
976        }
977
978    }
979
980    if (kbd_is_key_pressed(KEY_DOWN) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) {
981        if (conf.fast_ev && key_pressed == 0) {
982            kbd_key_release_all();
983            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)-(conf.fast_ev_step+1)*16);
984            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)-(conf.fast_ev_step+1)*16);
985            key_pressed = KEY_DOWN;
986            EnterToCompensationEVF();
987            return 1;
988        }
989    }
990
991#else
992    jogdial=get_jogdial_direction();
993
994    if (conf.fast_ev &&kbd_is_key_pressed(KEY_SHOOT_HALF) && (jogdial==JOGDIAL_RIGHT) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) {
995            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)+(conf.fast_ev_step+1)*16);
996            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)+(conf.fast_ev_step+1)*16);
997            EnterToCompensationEVF();
998        }
999
1000    if (conf.fast_ev &&kbd_is_key_pressed(KEY_SHOOT_HALF) && (jogdial==JOGDIAL_LEFT) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) {
1001            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)-(conf.fast_ev_step+1)*16);
1002            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)-(conf.fast_ev_step+1)*16);
1003            EnterToCompensationEVF();
1004        }
1005
1006
1007#endif
1008
1009    if (kbd_is_key_pressed(KEY_UP) && mode_video && movie_status == 4 ) {
1010        if (conf.fast_movie_quality_control && key_pressed == 0) {
1011            if (conf.video_mode==0) {
1012#if !CAM_VIDEO_QUALITY_ONLY
1013                conf.video_bitrate+=1;
1014                if (conf.video_bitrate>=VIDEO_BITRATE_STEPS)
1015                    conf.video_bitrate=VIDEO_BITRATE_STEPS-1;
1016                shooting_video_bitrate_change(conf.video_bitrate);
1017                movie_reset = 1;
1018#endif
1019            }
1020            else if (conf.video_mode==1) {
1021                conf.video_quality+=1;
1022                if (conf.video_quality>VIDEO_MAX_QUALITY)
1023                    conf.video_quality=VIDEO_MAX_QUALITY;
1024                movie_reset = 1;
1025            }
1026            key_pressed = KEY_UP;
1027            return 1;
1028        }
1029    }
1030
1031    if (kbd_is_key_pressed(KEY_DOWN) && mode_video && movie_status == 4) {
1032        if (conf.fast_movie_quality_control && key_pressed == 0) {
1033            if (conf.video_mode==0) {
1034#if !CAM_VIDEO_QUALITY_ONLY
1035                conf.video_bitrate-=1;
1036                if (conf.video_bitrate<0)
1037                    conf.video_bitrate=0;
1038
1039                shooting_video_bitrate_change(conf.video_bitrate);
1040                movie_reset = 1;
1041#endif
1042            }
1043            else if (conf.video_mode==1) {
1044                conf.video_quality-=1;
1045                if (conf.video_quality<1)
1046                    conf.video_quality=1;
1047                movie_reset = 1;
1048            }
1049            key_pressed = KEY_DOWN;
1050            return 1;
1051        }
1052    }
1053
1054    if (kbd_is_key_pressed(KEY_LEFT) && mode_video && (movie_status == 4) && !ev_video) {
1055        if (conf.fast_movie_control && key_pressed == 0) {
1056            movie_status = VIDEO_RECORD_STOPPED;
1057            key_pressed = KEY_LEFT;
1058            return 1;
1059        }
1060    }
1061        // reyalp - HACK for cams that can do video in any mode
1062        // note that this means this will probably run whenever you press right
1063    if (kbd_is_key_pressed(KEY_RIGHT) &&
1064#ifndef CAM_HAS_VIDEO_BUTTON
1065            mode_video &&
1066#endif
1067                (movie_status == 1) && !ev_video) {
1068        // BUG this doesn't know whether recording was stopped or paused.
1069        if (conf.fast_movie_control && key_pressed == 0) {
1070            movie_status = VIDEO_RECORD_IN_PROGRESS;
1071            movie_reset = 1;
1072            key_pressed = KEY_RIGHT;
1073            return 1;
1074        }
1075    }
1076
1077    return 0;
1078}
Note: See TracBrowser for help on using the repository browser.