Esempio n. 1
0
long kbd_use_zoom_as_mf() {
    static long zoom_key_pressed = 0;

    if (kbd_is_key_pressed(KEY_ZOOM_IN) && camera_info.state.mode_rec) {
        if (shooting_get_focus_mode()) {
            kbd_key_release_all();
            kbd_key_press(KEY_RIGHT);
            zoom_key_pressed = KEY_ZOOM_IN;
            return 1;
        }
    } else {
        if (zoom_key_pressed==KEY_ZOOM_IN) {
            kbd_key_release(KEY_RIGHT);
            zoom_key_pressed = 0;
            return 1;
        }
    }
    if (kbd_is_key_pressed(KEY_ZOOM_OUT) && camera_info.state.mode_rec) {
        if (shooting_get_focus_mode()) {
            kbd_key_release_all();
            kbd_key_press(KEY_LEFT);
            zoom_key_pressed = KEY_ZOOM_OUT;
            return 1;
        }
    } else {
        if (zoom_key_pressed==KEY_ZOOM_OUT) {
            kbd_key_release(KEY_LEFT);
            zoom_key_pressed = 0;
            return 1;
        }
    }
    return 0;
}
Esempio n. 2
0
void script_start( int autostart )
{
    int i;

    shot_histogram_set(0);
    if (autostart) auto_started = 1; else auto_started = 0;
    delay_target_ticks = 0;
    kbd_int_stack_ptr = 0;
    kbd_last_clicked = 0;
    /*if (!autostart)*/ kbd_key_release_all();

    script_console_clear();
    script_print_screen_init();

			if (conf.script_param_save)
				{
        save_params_values(0);
      }
    if( autostart )
      script_console_add_line("***Autostart***");
    else
      script_console_add_line(lang_str(LANG_CONSOLE_TEXT_STARTED));

    if( is_lua() ) {
      
      if( !lua_script_start(state_ubasic_script) ) {
    script_print_screen_end();
    wait_and_end();
    return;
      }
      for (i=0; i<SCRIPT_NUM_PARAMS; ++i) {
    if( script_params[i][0] ) {
    char var = 'a'+i;
    lua_pushlstring( L, &var, 1 );
    lua_pushnumber( L, conf.ubasic_vars[i] );
    lua_settable( L, LUA_GLOBALSINDEX );
    }
      }
      state_lua_kbd_first_call_to_resume = 1;
    }
    else {
      ubasic_init(state_ubasic_script);

      for (i=0; i<SCRIPT_NUM_PARAMS; ++i) {
        ubasic_set_variable(i, conf.ubasic_vars[i]);
      }
    }

    state_kbd_script_run = 1;

    if (conf.alt_prevent_shutdown != ALT_PREVENT_SHUTDOWN_ALT_SCRIPT) {
        enable_shutdown();
    }
}
Esempio n. 3
0
void script_end()
{
    script_print_screen_end();
    if( L ) {
      lua_script_reset( L );
    }
    else {
      ubasic_end();
    }
	md_close_motion_detector();
	shot_histogram_set(0);
    if (conf.alt_prevent_shutdown != ALT_PREVENT_SHUTDOWN_NO) {
        disable_shutdown();
    }
    kbd_key_release_all();
    state_kbd_script_run = 0;
    vid_bitmap_refresh();
}
Esempio n. 4
0
long script_start_gui( int autostart )
{
    int i;

    if (conf.script_file[0] == 0) return 0;

    libshothisto->shot_histogram_set(0);
    camera_info.state.auto_started = autostart;

    // Kill high speed USB timer if running
    stop_usb_HPtimer();

    // Keyboard init
    camera_info.state.kbd_last_clicked = 0;
    camera_info.state.kbd_last_checked_time = get_tick_count();
    kbd_key_release_all();

    // Close old console, will be re-opened when first line added
    console_close();
    script_print_screen_init();

    save_params_values(0);

    script_console_add_line((autostart)?LANG_CONSOLE_TEXT_AUTOSTARTED:LANG_CONSOLE_TEXT_STARTED);

    module_set_script_lang(conf.script_file);
    if ( !libscriptapi->script_start_file(conf.script_file) )
    {
        return -1;
    }

    sc_param *p = script_params;
    while (p)
    {
        libscriptapi->set_variable(p->name, p->val, (p->range == 1), (p->data_type == DTYPE_TABLE), p->option_count, p->options);
        p = p->next;
    }

    conf_update_prevent_shutdown();

    old_gui_handler = gui_set_mode(&scriptGuiHandler);

    return script_stack_start();
}
Esempio n. 5
0
// Terminate a script, either because of error, or the script finished
void script_end()
{
    // Tell other code that script has ended
    camera_info.state.state_kbd_script_run = SCRIPT_STATE_INACTIVE;
    camera_info.state.osd_title_line = 1 ;

    // reset the script terminate key
    script_terminate_key = KEY_SHOOT_FULL ;

    script_print_screen_end();
    console_set_autoredraw(1);          // Force console display on in case script turned it off

    // Restore old handler - prevent calling MD draw after module unloaded
    if (old_gui_handler)
    {
        extern gui_handler defaultGuiHandler; 
        // if script switched in or out of alt, try to preserve
        // TODO is there ever a situation where it should be something other than default or alt?
        if(old_gui_handler == &altGuiHandler && camera_info.state.gui_mode_none) {
            gui_set_mode(&defaultGuiHandler);
        } else if(old_gui_handler == &defaultGuiHandler && camera_info.state.gui_mode_alt) {
            gui_set_mode(&altGuiHandler);
        } else {
            gui_set_mode(old_gui_handler);
        }
        old_gui_handler = 0;
    }

    // Reset script language module
    libscriptapi->script_reset();

    // Kill off the action_stack for the script, since we've just reset the script
    // language and unloaded the MD module, we don't need to let the stack empty
    // itself.
    action_stack_kill(running_script_stack_name);
    running_script_stack_name = -1;

	libshothisto->shot_histogram_set(0);
    kbd_key_release_all();

    conf_setAutosave(1);    // Turn on autosave of config file in conf_setValue in case script turned it off
    conf_update_prevent_shutdown();
}
Esempio n. 6
0
//-------------------------------------------------------------------
// Core keyboard handler
long kbd_process()
{
    static int key_pressed;

    if (camera_info.perf.md_af_tuning)
    {
        switch (camera_info.perf.md_af_on_flag)
        {
        case 1:
            if (get_tick_count() >= (camera_info.perf.md_detect_tick + camera_info.perf.md_af_on_delay))
            {
                camera_info.perf.md_af_on_flag = 2;
                camera_set_led(camera_info.cam_af_led,1,200);
            }
            break;
        case 2:
            if (get_tick_count() >= (camera_info.perf.md_detect_tick + camera_info.perf.md_af_on_delay + camera_info.perf.md_af_on_time))
            {
                camera_info.perf.md_af_on_flag = 0;
                camera_set_led(camera_info.cam_af_led,0,0);
            }
            break;
        }
    }

    // Reset keyboard auto repeat if no buttons pressed
    if (kbd_get_pressed_key() == 0)
        last_kbd_key = 0;

    // Set clicked key for scripts.
    if (kbd_get_clicked_key())
    {
        camera_info.state.kbd_last_clicked = kbd_get_clicked_key();
        camera_info.state.kbd_last_clicked_time = get_tick_count();
    }

    // Set Shutter Half Press state for GUI task.
    camera_info.state.is_shutter_half_press = kbd_is_key_pressed(KEY_SHOOT_HALF);

	// Alternative keyboard mode stated/exited by pressing print key.
	// While running Alt. mode shoot key will start a script execution.

	// alt-mode switch and delay emulation
 
	if ( key_pressed  && !usb_remote_active ) 
	{
        if (kbd_is_key_pressed(conf.alt_mode_button)
                || ((key_pressed >= CAM_EMUL_KEYPRESS_DELAY)
                && (key_pressed < CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION)))
        {
            if (key_pressed <= CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION) 
                key_pressed++;
            if (key_pressed == CAM_EMUL_KEYPRESS_DELAY) 
                kbd_key_press(conf.alt_mode_button);
            else if (key_pressed == CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION) 
                kbd_key_release(conf.alt_mode_button);
            return 1;
        } 
        else if (kbd_get_pressed_key() == 0)
        {
            if (key_pressed < CAM_EMUL_KEYPRESS_DELAY)
            {
                if (!kbd_blocked) 
                    enter_alt();
                else
                    exit_alt();
            }
            key_pressed = 0;
            return 1;
        }
        return 1;
    }
       
    // auto iso shift
    if (camera_info.state.is_shutter_half_press && kbd_is_key_pressed(conf.alt_mode_button)) 
        return 0;

    if (kbd_is_key_pressed(conf.alt_mode_button)) 
	{
        key_pressed = 1;
        kbd_key_release_all();          
        return 1;
    }

#ifdef CAM_TOUCHSCREEN_UI
    extern int ts_process_touch();
    if (ts_process_touch())
    {
        gui_set_need_restore();
    }
#endif

    // deals with the rest

    if ( !kbd_blocked || usb_remote_active ) 
	{
		kbd_blocked = handle_usb_remote();
	}

    if (gui_kbd_process())
        return 1;

    action_stack_process_all();

    return kbd_blocked;
}
Esempio n. 7
0
long kbd_process()
{
/* Alternative keyboard mode stated/exited by pressing print key.
 * While running Alt. mode shoot key will start a script execution.
 */
static int nCER=0;
// ------ modif by Masuji SUTO (start) --------------

unsigned int mmode;
unsigned int nCrzpos,i;
unsigned int drmode = 0;

   if(conf.ricoh_ca1_mode && conf.remote_enable)
  {
	drmode = shooting_get_drive_mode();
	mmode = mode_get();
	mplay = (mmode&MODE_MASK)==MODE_PLAY;
//	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);
	mvideo=MODE_IS_VIDEO(mmode);
  }
       // deals with alt-mode switch and delay emulation
        if (key_pressed)
        {
                if (kbd_is_key_pressed(conf.alt_mode_button) ||
                        ((key_pressed >= CAM_EMUL_KEYPRESS_DELAY) && 
                         (key_pressed < CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION)))
                {
                        if (key_pressed <= CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION) 
                                key_pressed++;
                        if (key_pressed == CAM_EMUL_KEYPRESS_DELAY) 
                                kbd_key_press(conf.alt_mode_button);
                        else if (key_pressed == +CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION) 
                                kbd_key_release(conf.alt_mode_button);
                        return 1;
                } else 
                if (kbd_get_pressed_key() == 0)
                {
                        if (key_pressed != 100 && (key_pressed < CAM_EMUL_KEYPRESS_DELAY))
                        {
                                kbd_blocked = 1-kbd_blocked;
                                if (kbd_blocked) gui_kbd_enter(); else gui_kbd_leave();
                        }
                        key_pressed = 0;
                        return 1;
                }
                return 1;
        }
       
       // auto iso shift
        if (kbd_is_key_pressed(KEY_SHOOT_HALF) && kbd_is_key_pressed(conf.alt_mode_button)) return 0;
        
        if (kbd_is_key_pressed(conf.alt_mode_button))
        {
                if (conf.ricoh_ca1_mode && conf.remote_enable) conf.synch_enable=1;
                key_pressed = 1;
                kbd_key_release_all();          
                return 1;
        }

        // deals with the rest
        if (kbd_blocked && nRmt==0)
        {
/*------------------- Alex scriptless remote additions start --------------------*/
        if (remoteShooting) {

          if (remoteHalfShutter) {
            if (get_usb_power(1)) {
              if (remoteClickTimer < REMOTE_MAX_CLICK_LENGTH) {
                remoteHalfShutter=0;
                remoteFullShutter=1;
                kbd_key_press(KEY_SHOOT_FULL);
              }
              return 1;
            } else {
              --remoteClickTimer;
              if ( remoteClickTimer == 0 ) {
                kbd_key_release_all();
                remoteHalfShutter=0;
                remoteShooting=0;
                kbd_blocked=0;
                return 0;
              }
            }
          }

          if (remoteFullShutter) {
            if (get_usb_power(1)) {
              return 1;
            } else {
              kbd_key_release_all();
              remoteFullShutter=0;
              remoteShooting=0;
              kbd_blocked=0;
              return 0;
            }
          }

        }
/*-------------------- Alex scriptless remote additions end ---------------------*/
                if (kbd_is_key_pressed(KEY_SHOOT_FULL))
                {
                        key_pressed = 100;
                        if (!state_kbd_script_run)
                        {
                                script_start(0);
                        } else if (state_kbd_script_run == 2 || state_kbd_script_run == 3)
                        {
                                script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
                                script_end();
                        } else if (L)
                        {
                            state_kbd_script_run = 2;
                            lua_getglobal(Lt, "restore");
                            if (lua_isfunction(Lt, -1))
                                {
                                if (lua_pcall( Lt, 0, 0, 0 ))
                                {
                                    script_console_add_line( lua_tostring( Lt, -1 ) );
                                }
                            }
                            script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
                            script_end();
                        }
                        else
                        {
                            state_kbd_script_run = 2;
                            if (jump_label("restore") == 0)
                            {
                                script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
                                script_end();
                            }
                        }
                }

                if (state_kbd_script_run) 
                        process_script(); else
                        gui_kbd_process();
        } else
        {

#ifndef SYNCHABLE_REMOTE_NOT_ENABLED
if(conf.ricoh_ca1_mode && conf.remote_enable)
{

// ------ add by Masuji SUTO (start) --------------
if(nWt>0) {nWt--;return 1;}
#if defined(CAMERA_ixus960)
if(nFirst==1){
    if(nSW==0){
        nSW=1;
        nWt=10;
        kbd_key_release_all();
        kbd_key_press(KEY_SHOOT_HALF); 
        soft_half_press = 1;
        set_key_press(1);
        return 1;
    }
    else if(nSW==1){
        nSW=2;
        nWt=10;
        kbd_key_release(KEY_SHOOT_HALF); 
        soft_half_press = 0;
        set_key_press(1);
        return 1;
    }
    else if(nSW==2){
        set_key_press(0);
        nWt=10;
        nSW=0;
        nFirst=0;
        return 1;
    }
}
#endif
if (kbd_is_key_pressed(KEY_SHOOT_FULL)) conf.synch_enable=0;
	if (kbd_is_key_pressed(KEY_SHOOT_HALF) && nTxzoom>0) {
		nCount2=0;
		nTxzoom=0;
		nReczoom=0;
		nTxvideo=0;
		debug_led(0);
		}
	if (mplay && (kbd_is_key_pressed(KEY_LEFT) || kbd_is_key_pressed(KEY_RIGHT))){
		nPlyname=KEY_LEFT;
		if(kbd_is_key_pressed(KEY_RIGHT)) nPlyname=KEY_RIGHT;
		}
	if (kbd_is_key_pressed(KEY_VIDEO)){
		nCount2=0;
		nTxzoom=0;
		nReczoom=0;
		nTxvideo++;
		if(nTxvideo<50){
			kbd_key_release_all();
			debug_led(1);
			}
		else {
			debug_led(0);
			return 0;
			}
		return 1;
		}
	else if(nTxvideo>49) nTxvideo=0;
	if (kbd_is_key_pressed(KEY_ZOOM_IN) || kbd_is_key_pressed(KEY_ZOOM_OUT)){
		nCount2=0;
		nTxvideo=0;
		if(kbd_is_key_pressed(KEY_ZOOM_IN)) {
			if(nTxzname==KEY_ZOOM_IN) nTxzoom++;
			else nTxzoom=1;
			nTxzname=KEY_ZOOM_IN;
			}
		else {
			if(nTxzname==KEY_ZOOM_OUT) nTxzoom++;
			else nTxzoom=1;
			nTxzname=KEY_ZOOM_OUT;
			}
		if(nTxzoom<50){
			kbd_key_release_all();
			debug_led(1);
			}
		else {
			debug_led(0);
			return 0;
			}
		return 1;
		}
	if(!get_usb_power(1) && nSW<100 && nCount==0 && nTxzoom>0) {
		nCount2++;
		if(nCount2>conf.zoom_timeout*100){
			if(nTxzoom>0){
				nTxzoom=0;
				nReczoom=0;
				debug_led(0);
				}
			nCount2=0;
			}
		return 1;
		}
	if(get_usb_power(1) && nSW<100 && nCount==0) {nCount2=0;kbd_key_release_all();conf.synch_enable=1;}

	
	if(get_usb_power(1) && nSW<100 && nCount==0) {kbd_key_release_all();conf.synch_enable=1;}
	if(get_usb_power(1) && nSW<100 && nCount<6){
		nCount++;
		return 1;
		}
	if(nCount>0 && nSW<100){
		if(mplay) {
			if(get_usb_power(1)) return 1;
			kbd_key_release_all();
			kbd_key_press(nPlyname);
			set_key_press(1);
			nCount=0;
			nCa=2;
			nSW=101;
			nWt=5;
			return 1;
			}
		if(nTxvideo>49) nTxvideo=0;
		if(nCount<5) nCa=1;		//for Richo remote switch CA-1
		else nCa=2;				//for hand made remote switch
		nCount=0;
//		debug_led(1);
		nSW=109;
		}

// -------------------------------------------------------------  hand made switch  --------------

	if(nCa==2){
     		if(nSW==101){
			kbd_key_release_all();
			set_key_press(0);
			nWt=50;
			nSW=0;
			nCa=0;
			return 1;
			}                                       
		if(nSW==109){
		//	nSW=110;
			nCER=0;
			if(nTxzoom>0 && conf.remote_zoom_enable){
				if(nTxzoom<100){
					nIntzpos=lens_get_zoom_point();
					for(i=0;i<ZSTEP_TABLE_SIZE;i++){
						if(nIntzpos<=nTxtbl[i]){
							if(i>0){
								if(abs(nTxtbl[i]-nIntzpos)<=abs(nTxtbl[i-1]-nIntzpos)) nTxtblcr=i;
								else nTxtblcr=i-1;
								}
							else nTxtblcr=i;
							i=ZSTEP_TABLE_SIZE;
							}
						}
					if(nTxzname==KEY_ZOOM_IN){
						nTxtblcr++;
						if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)) nTxtblcr=(ZSTEP_TABLE_SIZE-1);
						}
					else{
						nTxtblcr--;
						if(nTxtblcr<0) nTxtblcr=0;
						}
					nSW=108;
					return 1;
					}
				nTxzoom=0;
				nReczoom=0;
				}
			if(nTxvideo>0 && conf.remote_zoom_enable) {nSW=121;return 1;}
                                    nSW=110;
			nWt=2;
			kbd_key_release_all();
			kbd_key_press(KEY_SHOOT_HALF); 
		//	key_pressed = 1;
		//	kbd_blocked = 1;
		//	nRmt=1;
                  soft_half_press = 1;
                  set_key_press(1);
			return 1;
			}
			if(nTxzoom>0 && nSW==108 && conf.remote_zoom_enable){
				nCrzpos=lens_get_zoom_point();
				if(nIntzpos!=nCrzpos) {nReczoom=0;}
				if(nIntzpos==nCrzpos && nCER>50){
					if(!get_usb_power(1)){
						kbd_key_release_all();
						set_key_press(0);
						nTxzoom=1;
						nSW=0;
						nCount=0;
						nWt=10;
						nReczoom=1;
						return 1;
						}
					}
				if(nReczoom==0 && ((nTxzname==KEY_ZOOM_IN && nCrzpos>=nTxtbl[nTxtblcr]) || (nTxzname==KEY_ZOOM_OUT && nCrzpos<=nTxtbl[nTxtblcr]))){
					if(get_usb_power(1)){
						i=1;
						if(nTxzname==KEY_ZOOM_IN){
							nTxtblcr++;
							if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)){
                            nTxtblcr=(ZSTEP_TABLE_SIZE-1);
                            nTxzname=KEY_ZOOM_OUT;
                            }
							}
						else{
							nTxtblcr--;
							if(nTxtblcr<0){
                            nTxtblcr=0;
                            nTxzname=KEY_ZOOM_IN;
                            }
							}
						if(i==1) return 1;
						}
					kbd_key_release_all();
					set_key_press(0);
					nTxzoom=1;
	//				lens_set_zoom_speed(25);
					nSW=120;
					nWt=5;
					return 1;
					}
				kbd_key_release_all();
				kbd_key_press(nTxzname); 
				set_key_press(1);
				nCER++;
				return 1;
				}
				
		if(nTxvideo>0 && nSW==121){
			if(!get_usb_power(1)) {
				nWt=10;
				kbd_key_press(KEY_VIDEO);
				set_key_press(1);
				nSW=122;
				}
			return 1;
			}
		if(nTxvideo>0 && nSW==122){
			nWt=10;
			kbd_key_release(KEY_VIDEO);
			set_key_press(1);
			nSW=123;
			return 1;
			}
		if(nTxvideo>0 && nSW==123){
			set_key_press(0);
			nWt=50;
			nSW=0;
			nCa=0;
			nTxvideo=0;
			debug_led(0);
			return 1;
			}

		if(nSW==110){
			if (shooting_in_progress() || mvideo || nCER>100) {
				state_expos_recalculated = 0;
				histogram_restart();
				nCER=0;
				nSW=111;
			    }
			else {nCER++;return 1;}
			}
		if(nSW==111){
			if (state_expos_recalculated || nCER>100) {
				state_expos_under = under_exposed;
				state_expos_over = over_exposed;
				nCER=0;
				nSW=112;
                        //presynch();
			    }
			else {nCER++;return 1;}
			}
		if(nSW==112){
		    if (shooting_is_flash_ready() || nCER>10){
				nCER=0;
				nSW=113;
			    }
			else {nCER++;return 1;}
			}
		if(nSW==113){
			if(get_usb_power(1) && !mvideo) nSW=114;
			else if(!get_usb_power(1) && mvideo) nSW=114;
			else return 1;
			}
		if(nTxzoom>0 && nSW==120 && conf.remote_zoom_enable){
			nCrzpos=lens_get_zoom_point();
			if((nTxzname==KEY_ZOOM_IN && nCrzpos<=nTxtbl[nTxtblcr]) || (nTxzname==KEY_ZOOM_OUT && nCrzpos>=nTxtbl[nTxtblcr])){
				kbd_key_release_all();
				set_key_press(0);
				nTxzoom=1;
				lens_set_zoom_speed(100);
				nSW=0;
				nCount=0;
				nWt=10;
				return 1;
				}
			lens_set_zoom_speed(5);
			kbd_key_release_all();
			if(nTxzname==KEY_ZOOM_IN) kbd_key_press(KEY_ZOOM_OUT); 
			else kbd_key_press(KEY_ZOOM_IN); 
			set_key_press(1);
			return 1;
			}

		if(nSW==114){
			nSW=115;
			nWt=2;
                  shutter_int=0;
			kbd_key_press(KEY_SHOOT_FULL); 
                                    set_key_press(1);
		//	kbd_blocked = 1;
		//	nRmt=1;
			nCount=0;
			return 1;
			}
		if(nSW==115){
	//		debug_led(0);
			if(drmode==1 && shutter_int==0){
				return 1;
				}
			nSW=116;
			nWt=2;
			kbd_key_release(KEY_SHOOT_FULL); 
                                    set_key_press(1);
                                    soft_half_press = 0;
		//	kbd_blocked = 1;
		//	nRmt=1;
			return 1;
			}
		if(!get_usb_power(1) && nSW==116) {
                                    set_key_press(0);
		//	kbd_blocked = 0;
		//	key_pressed = 0;
			nWt=50;
			nSW=0;
		//	nRmt=0;
			nCa=0;
                  //postsynch();
			return 1;
			}
		}

// -------------------------------------------------------------  Ricoh remote switch CA-1 --------------
	if(nCa==1){
		if(get_usb_power(1) && nSW>108 && nSW<120){
			nCount++;
			}
		if(nSW==109){
		//	nSW=110;
			nCER=0;
			if(nTxzoom>0 && conf.remote_zoom_enable){
				if(nTxzoom<100){
					nIntzpos=lens_get_zoom_point();
					for(i=0;i<ZSTEP_TABLE_SIZE;i++){
						if(nIntzpos<=nTxtbl[i]){
							if(i>0){
								if(abs(nTxtbl[i]-nIntzpos)<=abs(nTxtbl[i-1]-nIntzpos)) nTxtblcr=i;
								else nTxtblcr=i-1;
								}
							else nTxtblcr=i;
							i=ZSTEP_TABLE_SIZE;
							}
						}
					if(nTxzname==KEY_ZOOM_IN){
						nTxtblcr++;
						if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)) nTxtblcr=(ZSTEP_TABLE_SIZE-1);
						}
					else{
						nTxtblcr--;
						if(nTxtblcr<0) nTxtblcr=0;
						}
					nSW=113;
					return 1;
					}
				nTxzoom=0;
				nReczoom=0;
				}
			if(nTxvideo>0 && conf.remote_zoom_enable) {nSW=121;return 1;}
                  nSW=110;
			nWt=2;
			kbd_key_release_all();
			kbd_key_press(KEY_SHOOT_HALF); 
//			debug_led(1);
                                    soft_half_press = 1;
                                    set_key_press(1);
		//	key_pressed = 1;
		//	kbd_blocked = 1;
		//	nRmt=1;
			return 1;
			}
		if(nTxvideo>0 && nSW==121){
			if(get_usb_power(1)) {
				nWt=10;
				kbd_key_press(KEY_VIDEO);
				set_key_press(1);
				nSW=122;
				}
			return 1;
			}
		if(nTxvideo>0 && nSW==122){
			nWt=10;
			kbd_key_release(KEY_VIDEO);
			set_key_press(1);
			nSW=123;
			return 1;
			}
		if(nTxvideo>0 && nSW==123){
			set_key_press(0);
			nWt=100;
			nCount=0;
			nSW=0;
			nCa=0;
			nTxvideo=0;
			debug_led(0);
			return 1;
			}

		if(nSW==110){
			if (shooting_in_progress() || mvideo || nCER>100) {
//				debug_led(0);
				state_expos_recalculated = 0;
				histogram_restart();
				nCER=0;
				nSW=111;
			    }
			else {nCER++;return 1;}
			}
		if(nSW==111){
			if (state_expos_recalculated || nCER>100) {
				state_expos_under = under_exposed;
				state_expos_over = over_exposed;
				nCER=0;
				nSW=112;
                        //presynch();
			    }
			else {nCER++;return 1;}
			}
		if(nSW==112){
		    if (shooting_is_flash_ready() || nCER>10){
				nCER=0;
				nSW=113;
			    }
			else {nCER++;return 1;}
			}
		if(nTxzoom>0 && nSW==114 && conf.remote_zoom_enable){
			nCrzpos=lens_get_zoom_point();
			if(nIntzpos!=nCrzpos) {nReczoom=0;}
			if(nIntzpos==nCrzpos && nCER>50){
				if(nCount>0){
					kbd_key_release_all();
					set_key_press(0);
					nTxzoom=1;
					nSW=0;
					nCount=0;
					nWt=10;
					nReczoom=1;
					return 1;
					}
				}
			if(nReczoom==0 && ((nTxzname==KEY_ZOOM_IN && nCrzpos>=nTxtbl[nTxtblcr]) || (nTxzname==KEY_ZOOM_OUT && nCrzpos<=nTxtbl[nTxtblcr]))){
				if(nCount==0){
					i=1;
					if(nTxzname==KEY_ZOOM_IN){
						nTxtblcr++;
						if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)){
                        nTxtblcr=(ZSTEP_TABLE_SIZE-1);
                        nTxzname=KEY_ZOOM_OUT;
                        }
						}
					else{
						nTxtblcr--;
						if(nTxtblcr<0){
                        nTxtblcr=0;
                        nTxzname=KEY_ZOOM_IN;
                        }
						}
					if(i==1) return 1;
					}
				kbd_key_release_all();
				set_key_press(0);
				nTxzoom=1;
//				lens_set_zoom_speed(25);
				nSW=115;
				nWt=5;
				return 1;
				}
			kbd_key_release_all();
			kbd_key_press(nTxzname); 
			set_key_press(1);
			nCER++;
			return 1;
			}
		if(nTxzoom>0 && nSW==115 && conf.remote_zoom_enable){
			if(nCount==0) return 1;
			nCrzpos=lens_get_zoom_point();
			if((nTxzname==KEY_ZOOM_IN && nCrzpos<=nTxtbl[nTxtblcr]) || (nTxzname==KEY_ZOOM_OUT && nCrzpos>=nTxtbl[nTxtblcr])){
				kbd_key_release_all();
				set_key_press(0);
				nTxzoom=1;
				lens_set_zoom_speed(100);
				nSW=0;
				nCount=0;
				nWt=10;
				return 1;
				}
			lens_set_zoom_speed(5);
			kbd_key_release_all();
			if(nTxzname==KEY_ZOOM_IN) kbd_key_press(KEY_ZOOM_OUT); 
			else kbd_key_press(KEY_ZOOM_IN); 
			set_key_press(1);
			return 1;
			}


		if(get_usb_power(1)){
			return 1;
			}
		if(nCount>0 && nSW==113){
			if(nCount<9){
				if(nTxzoom>0 && conf.remote_zoom_enable){
					kbd_key_release_all();
					set_key_press(0);
					nTxzoom=0;
					nReczoom=0;
					nSW=0;
					nCa=0;
					nCount=0;
					nWt=10;
//					lens_set_zoom_speed(100);
					debug_led(0);
					return 1;
					}
				nSW=125;
				nWt=10;
				kbd_key_release(KEY_SHOOT_HALF); 
	                                    soft_half_press = 0;
                                        set_key_press(1);
			//	kbd_blocked = 1;
			//	nRmt=1;
				nCount=0;
				return 1;
				}
			else{
				if(nTxzoom>0 && conf.remote_zoom_enable){
					nCount=0;
					nSW=114;
					return 1;
					}
				nSW=124;
				nWt=2;
                        shutter_int=0;
//				debug_led(0);
				kbd_key_press(KEY_SHOOT_FULL); 
                                                set_key_press(1);
			//	kbd_blocked = 1;
			//	nRmt=1;
				nCount=0;
				return 1;
				}
			}
		if(nSW==124){
	//		debug_led(0);
			if(drmode==1 && shutter_int==0){
				return 1;
				}
			nSW=125;
			nWt=2;
			kbd_key_release(KEY_SHOOT_FULL);
                  soft_half_press = 0;
                  set_key_press(1);
		//	kbd_blocked = 1;
		//	nRmt=1;
			return 1;
			}
		if(!get_usb_power(1) && nSW==125) {
                                    set_key_press(0);
		//	kbd_blocked = 0;
		//	key_pressed = 0;
			nWt=50;
			nSW=0;
		//	nRmt=0;
			nCa=0;
                  //postsynch();
			return 1;
			}
		}

// ------ add by Masuji SUTO (end)   --------------

} // ricoh_ca1_mode
#endif
/*------------------- Alex scriptless remote additions start --------------------*/
        if (conf.remote_enable && !conf.ricoh_ca1_mode && key_pressed != 2 && get_usb_power(1)) {
          remoteShooting = 1;
          kbd_blocked = 1;
          kbd_key_release_all();
          remoteClickTimer = REMOTE_MAX_CLICK_LENGTH;
          if (shooting_get_focus_mode()) {
            remoteFullShutter = 1;
            kbd_key_press(KEY_SHOOT_FULL);
          } else {
            remoteHalfShutter = 1;
            kbd_key_press(KEY_SHOOT_HALF);
          }
          return 1;
        }
/*-------------------- Alex scriptless remote additions end ---------------------*/
#ifdef CAM_USE_ZOOM_FOR_MF
                if (conf.use_zoom_mf && kbd_use_zoom_as_mf()) {
                    return 1;
                }
#endif
                if ((conf.fast_ev || conf.fast_movie_control || conf.fast_movie_quality_control) && kbd_use_up_down_left_right_as_fast_switch()) {
                    return 1;
                }
                other_kbd_process(); // processed other keys in not <alt> mode 
        }

        return kbd_blocked;
}
Esempio n. 8
0
long kbd_use_up_down_left_right_as_fast_switch() {
    static long key_pressed = 0; // ??? static masking a global
    int m=mode_get(); 
    int mode_video = MODE_IS_VIDEO(m) || (movie_status > 1);
    int ev_video=0;
    int jogdial;

#if CAM_EV_IN_VIDEO
    ev_video=get_ev_video_avail(); 
#endif

    if (!(kbd_is_key_pressed(KEY_UP)) && !(kbd_is_key_pressed(KEY_DOWN))) key_pressed = 0;

    if (canon_shoot_menu_active!=0 || (m&MODE_MASK) != MODE_REC)
        return 0;

#if !CAM_HAS_JOGDIAL
    if (kbd_is_key_pressed(KEY_UP) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) {
        if (conf.fast_ev && key_pressed == 0) {
            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)+(conf.fast_ev_step+1)*16);
            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)+(conf.fast_ev_step+1)*16);
            EnterToCompensationEVF();
            key_pressed = KEY_UP;
                
            return 1;
        }

    } 

    if (kbd_is_key_pressed(KEY_DOWN) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) {
        if (conf.fast_ev && key_pressed == 0) {
            kbd_key_release_all();
            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)-(conf.fast_ev_step+1)*16);
            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)-(conf.fast_ev_step+1)*16);
            key_pressed = KEY_DOWN;
            EnterToCompensationEVF();
            return 1;
        }
    } 

#else
    jogdial=get_jogdial_direction();

    if (conf.fast_ev &&kbd_is_key_pressed(KEY_SHOOT_HALF) && (jogdial==JOGDIAL_RIGHT) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) {
            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)+(conf.fast_ev_step+1)*16);
            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)+(conf.fast_ev_step+1)*16);
            EnterToCompensationEVF();
        }

    if (conf.fast_ev &&kbd_is_key_pressed(KEY_SHOOT_HALF) && (jogdial==JOGDIAL_LEFT) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) {
            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)-(conf.fast_ev_step+1)*16);
            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)-(conf.fast_ev_step+1)*16);
            EnterToCompensationEVF();
        }
     

#endif

    if (kbd_is_key_pressed(KEY_UP) && mode_video && movie_status == 4 ) {
        if (conf.fast_movie_quality_control && key_pressed == 0) {
            if (conf.video_mode==0) {
#if !CAM_VIDEO_QUALITY_ONLY
                conf.video_bitrate+=1;
                if (conf.video_bitrate>=VIDEO_BITRATE_STEPS)
                    conf.video_bitrate=VIDEO_BITRATE_STEPS-1;
                shooting_video_bitrate_change(conf.video_bitrate);
                movie_reset = 1;
#endif
            }    
            else if (conf.video_mode==1) {
                conf.video_quality+=1;
                if (conf.video_quality>VIDEO_MAX_QUALITY)
                    conf.video_quality=VIDEO_MAX_QUALITY;
                movie_reset = 1;
            }              
            key_pressed = KEY_UP;
            return 1;
        }
    } 
    
    if (kbd_is_key_pressed(KEY_DOWN) && mode_video && movie_status == 4) {
        if (conf.fast_movie_quality_control && key_pressed == 0) {
            if (conf.video_mode==0) {                
#if !CAM_VIDEO_QUALITY_ONLY
                conf.video_bitrate-=1;
                if (conf.video_bitrate<0)
                    conf.video_bitrate=0;

                shooting_video_bitrate_change(conf.video_bitrate);
                movie_reset = 1;
#endif
            }
            else if (conf.video_mode==1) {
                conf.video_quality-=1;
                if (conf.video_quality<1)
                    conf.video_quality=1;
                movie_reset = 1;
            }          
            key_pressed = KEY_DOWN;
            return 1;
        }
    } 
    
    if (kbd_is_key_pressed(KEY_LEFT) && mode_video && (movie_status == 4) && !ev_video) {
        if (conf.fast_movie_control && key_pressed == 0) {
            movie_status = VIDEO_RECORD_STOPPED;
            key_pressed = KEY_LEFT;
            return 1;
        }
    } 
	// reyalp - HACK for cams that can do video in any mode
	// note that this means this will probably run whenever you press right
    if (kbd_is_key_pressed(KEY_RIGHT) &&
#ifndef CAM_HAS_VIDEO_BUTTON 
            mode_video &&
#endif
	        (movie_status == 1) && !ev_video) {
        // BUG this doesn't know whether recording was stopped or paused.
        if (conf.fast_movie_control && key_pressed == 0) {
            movie_status = VIDEO_RECORD_IN_PROGRESS;
            movie_reset = 1;
            key_pressed = KEY_RIGHT;
            return 1;
        }
    } 

    return 0;
}