Exemple #1
0
void lens_set_zoom_point(long newpt)
{
#if defined (CAMERA_s95)
	long startTime;
#endif

    if (newpt < 0) {
        newpt = 0;
    } else if (newpt >= zoom_points) {
        newpt = zoom_points-1;
    }
#if defined(CAMERA_sx30)
// SX30 - Can't find zoom_status, _MoveZoomLensWithPoint crashes camera
// _PT_MoveOpticalZoomAt works, and updates PROPCASE_OPTICAL_ZOOM_POSITION; but doesn't wait for zoom to finish
	extern void _PT_MoveOpticalZoomAt(long*);
	if (lens_get_zoom_point() != newpt)
	{
		_PT_MoveOpticalZoomAt(&newpt);
		while (zoom_busy) msleep(10);
	}
#elif defined(CAMERA_g12)
// G12 - Can't find zoom_status, _MoveZoomLensWithPoint works anyway; but doesn't wait for zoom to finish
	if (lens_get_zoom_point() != newpt)
	{
	    _MoveZoomLensWithPoint((short*)&newpt);
		while (zoom_busy) msleep(10);
	    _SetPropertyCase(PROPCASE_OPTICAL_ZOOM_POSITION, &newpt, sizeof(newpt));
	}
#else	// !CAMERA_g12
    _MoveZoomLensWithPoint((short*)&newpt);

#if defined (CAMERA_s95)
	// this will hang sometimes on s95 when zoom_busy gets stuck as a 1
	// we add a timeout as a work-around for this problem
	startTime = get_tick_count();
	while (get_tick_count() < (startTime + 2000)) {
		if (!zoom_busy)
			break;
	}
#else	// !CAMERA_s95
	while (zoom_busy) ;
#endif	// CAMERA_s95

    if (newpt==0) zoom_status=ZOOM_OPTICAL_MIN;
    else if (newpt >= zoom_points) zoom_status=ZOOM_OPTICAL_MAX;
    else zoom_status=ZOOM_OPTICAL_MEDIUM;
    _SetPropertyCase(PROPCASE_OPTICAL_ZOOM_POSITION, &newpt, sizeof(newpt));
#endif	// CAMERA_g12
}
Exemple #2
0
void gui_osd_draw_rf3() {
  
  
  static char sd[10],dc[10],d[10],df[10],H[10];

  { unsigned short avv = 0;
    if (mode_get()&(MODE_M | MODE_AV))
         get_property_case(39, (void *)&avv, sizeof(avv));
    else get_property_case(68, (void *)&avv, sizeof(avv));

    canon_av2s((unsigned short)lens_get_zoom_point(),
               (unsigned short)lens_get_focus_pos(),
               (unsigned short)avv,
               (unsigned short)(10*3), // circle of confusion is 3 microns
               sd, 8,
               dc, 8,
               d, 8,
               df, 8,
               H, 8);

    //sprintf(osd_buf, "m %u A %u ", knob, avv, ""); }
    sprintf(osd_buf,"s%7u", (unsigned short)lens_get_focus_pos());
    draw_string(conf.values_pos.x, conf.values_pos.y+FONT_HEIGHT*6,
                osd_buf,conf.osd_color);
    sprintf(osd_buf,"f%7s",df);
    draw_string(conf.values_pos.x, conf.values_pos.y+FONT_HEIGHT*7,
                osd_buf,conf.osd_color);
    sprintf(osd_buf,"d%7s",d);
    draw_string(conf.values_pos.x, conf.values_pos.y+FONT_HEIGHT*8,
                osd_buf, conf.osd_color);
    sprintf(osd_buf,"c%7s",dc);
    draw_string(conf.values_pos.x, conf.values_pos.y+FONT_HEIGHT*9,
                osd_buf, conf.osd_color);
    sprintf(osd_buf,"s%7s",sd);
    draw_string(conf.values_pos.x, conf.values_pos.y+FONT_HEIGHT*10,
                osd_buf, conf.osd_color); }
}
Exemple #3
0
void shooting_set_autoiso(int iso_mode)
{
    short max_iso;

    if (iso_mode<=0)
        shooting_recalc_conf_autoiso_values();

    switch (iso_mode)
    {
    case -1: // ISO HI
        //max_iso = conf.autoiso_max_iso_hi*10;
        max_iso = conf.autoiso_max_iso_hi_real;
        break;
    case 0: // ISO AUTO
        //max_iso = conf.autoiso_max_iso_auto*10;
        max_iso = conf.autoiso_max_iso_auto_real;
        break;
    default:
        return;
    }

    // TODO also long shutter ?
    if (camera_info.state.mode_shooting==MODE_M || camera_info.state.mode_shooting==MODE_TV || camera_info.state.mode_shooting==MODE_STITCH)
        return; //Only operate outside of M and Tv

    int ev_overexp = 0;
    if (conf.overexp_ev_enum)
    {
        // No shoot_histogram exist here because no future shot exist yet :)
        int total = live_histogram_read_y(live_histogram_proc);

        // step 32 is 1/3ev for tv96
        if (live_histogram_get_range(total,255-conf.autoiso2_over,255) >= conf.overexp_threshold)
            ev_overexp = conf.overexp_ev_enum << 5; 
    }

    float current_shutter = shooting_get_shutter_speed_from_tv96(shooting_get_tv96());

    short current_iso = shooting_get_iso_real();

    short min_shutter = shutter1_values[conf.autoiso_shutter_enum];
    if (min_shutter == 0)
    {
        short IS_factor = (shooting_get_is_mode()<=1)?conf.autoiso_is_factor:1;
        min_shutter = get_focal_length(lens_get_zoom_point())*conf.autoiso_user_factor / (IS_factor*1000);
        //min_shutter is NOT 1/Xs but optimized for the calculation.
        if (shutter2_values[conf.autoiso2_shutter_enum])
            shooting_calc_autoiso_coef( min_shutter );
    }

    short target_iso = current_iso * min_shutter * current_shutter;
    short min_iso = conf.autoiso_min_iso_real;

    if (target_iso > max_iso)
    {
        ev_overexp=0;

        // AutoISO2 if
        // 	it is turned on (C2!=0.0)
        //	and it has valid iso2/shutter2 ( C2<0)
        //       and non-IsoHI mode
        if ( !iso_mode && conf.autoiso2_coef < 0.0 )
        {
            target_iso = (max_iso - min_shutter*conf.autoiso2_coef) / ( 1.0 - conf.autoiso2_coef  / (current_shutter * current_iso) );
            if ( target_iso > conf.autoiso2_max_iso_auto_real )
                target_iso = conf.autoiso2_max_iso_auto_real;
        }
        else
        {
            target_iso = max_iso;
        }
    }
    else if (target_iso < min_iso)
    {
        target_iso = min_iso;
    }

    float target_shutter = current_shutter *  current_iso / target_iso;

	if (target_shutter > 0)
        shooting_set_tv96_direct(shooting_get_tv96_from_shutter_speed(target_shutter) + ev_overexp, SET_NOW);

    shooting_set_iso_real(target_iso, SET_NOW);
}
Exemple #4
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;
}