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; }
void usb_playback_module() { static int time_stamp = 0 ; static int direction = 0 ; // 0 = left button, 1 = right button int i, current_time ; current_time = get_tick_count(); switch( logic_module_state ) { case LM_RESET : logic_module_state = LM_RELEASE ; break ; case LM_RELEASE : i = get_usb_power(LM_PULSE_COUNT) ; switch( i ) { case PLAYBACK_REVERSE : direction = direction ? 0 : 1 ; // fall through to next case case PLAYBACK_NEXT : if ( direction ) kbd_key_press(KEY_LEFT); else kbd_key_press(KEY_RIGHT); logic_module_state = LM_KEY_PRESS ; time_stamp = current_time ; break ; case PLAYBACK_LEFT : direction = 0 ; break ; case PLAYBACK_RIGHT : direction = 1 ; break ; default : break ; } break ; case LM_KEY_PRESS : if( (current_time - time_stamp) > REMOTE_CLICK_TIME ) { if ( direction ) kbd_key_release(KEY_LEFT); else kbd_key_release(KEY_RIGHT); logic_module_state = LM_RELEASE ; } break ; default : break ; } }
/* saves & updates key state, runs main CHDK kbd task code in kbd_process, returns kbd_process value */ long kbd_update_key_state(void) { kbd_prev_state[0] = kbd_new_state[0]; kbd_prev_state[1] = kbd_new_state[1]; kbd_prev_state[2] = kbd_new_state[2]; #ifdef CAM_TOUCHSCREEN_UI kbd_prev_state[3] = kbd_new_state[3]; #endif // note assumed kbd_pwr_on has been called if needed kbd_fetch_data(kbd_new_state); #ifdef CAM_HAS_GPS if (gps_key_trap > 0) // check if gps code is waiting for a specific key press to cancel shutdown { if (kbd_get_pressed_key() == gps_key_trap) { kbd_key_release(gps_key_trap); kbd_key_press(0); gps_key_trap = -1; // signal the gps task that the specified button was pressed msleep(1000); // pause to allow button release so Canon f/w does not see the press } } #endif long status = kbd_process(); if (status == 0){ // leave it alone... physw_status[0] = kbd_new_state[0]; physw_status[1] = kbd_new_state[1]; physw_status[2] = kbd_new_state[2]; #ifdef CAM_HAS_JOGDIAL jogdial_control(0); #endif } else { // override keys // TODO doesn't handle inverted logic yet physw_status[0] = (kbd_new_state[0] & (~KEYS_MASK0)) | (kbd_mod_state[0] & KEYS_MASK0); physw_status[1] = (kbd_new_state[1] & (~KEYS_MASK1)) | (kbd_mod_state[1] & KEYS_MASK1); physw_status[2] = (kbd_new_state[2] & (~KEYS_MASK2)) | (kbd_mod_state[2] & KEYS_MASK2); #ifdef CAM_HAS_JOGDIAL if ((jogdial_stopped==0) && !camera_info.state.state_kbd_script_run) { jogdial_control(1); get_jogdial_direction(); } else if (jogdial_stopped && camera_info.state.state_kbd_script_run) { jogdial_control(0); } #endif } return status; }
// Process a button press action from the stack static int action_stack_AS_PRESS() { extern int usb_sync_wait; long skey = action_pop_func(1); // Key parameter returned if ((skey == KEY_SHOOT_FULL) && conf.remote_enable && conf.synch_enable) usb_sync_wait = 1; kbd_key_press(skey); return 1; }
void md_kbd_sched_immediate_shoot(int no_release) { kbd_int_stack_ptr-=1;// REMOVE MD ITEM // stack operations are reversed! if (!no_release) // only release shutter if allowed { kbd_sched_release(KEY_SHOOT_FULL); kbd_sched_delay(20); } KBD_STACK_PUSH(SCRIPT_MOTION_DETECTOR); // it will removed right after exit from this function kbd_key_press(KEY_SHOOT_FULL); // not a stack operation... pressing right now }
static void md_kbd_sched_immediate_shoot(int no_release) { action_pop();// REMOVE MD ITEM // stack operations are reversed! if (!no_release) // only release shutter if allowed { action_push_release(KEY_SHOOT_FULL); action_push_delay(20); } action_push(AS_MOTION_DETECTOR); // it will removed right after exit from this function kbd_key_press(KEY_SHOOT_FULL); // not a stack operation... pressing right now }
static void md_kbd_sched_immediate_shoot(int no_release) { action_pop_func(0);// REMOVE MD ITEM // stack operations are reversed! if (!no_release) // only release shutter if allowed { action_push_release(KEY_SHOOT_FULL); } if (camera_info.cam_key_press_delay > 0) action_push_delay(camera_info.cam_key_press_delay); action_push_func(action_stack_AS_MOTION_DETECTOR); // it will removed right after exit from this function kbd_key_press(KEY_SHOOT_FULL); // not a stack operation... pressing right now // MD testing with AF LED if (camera_info.perf.md_af_tuning) { camera_info.perf.md_af_on_flag = 1; } }
//------------------------------------------------------------------- // 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; }
void usb_video_module_normal() { switch( logic_module_state ) { case LM_RESET : logic_module_state = LM_RELEASE ; break ; case LM_RELEASE : switch ( virtual_remote_state ) { case REMOTE_RELEASE : break ; case REMOTE_HALF_PRESS : case REMOTE_FULL_PRESS: kbd_key_press(USB_VIDEO_BUTTON); logic_module_state = LM_START_RECORD ; break ; default : debug_error(INVALID_STATE) ; break ; } break ; case LM_START_RECORD: switch ( virtual_remote_state ) { case REMOTE_RELEASE : logic_module_state = LM_RECORDING ; kbd_key_release(USB_VIDEO_BUTTON); break ; case REMOTE_HALF_PRESS : case REMOTE_FULL_PRESS: break ; default : debug_error(INVALID_STATE) ; break ; } break; case LM_RECORDING : switch ( virtual_remote_state ) { case REMOTE_RELEASE : break ; case REMOTE_HALF_PRESS : case REMOTE_FULL_PRESS: kbd_key_press(USB_VIDEO_BUTTON); logic_module_state = LM_STOP_RECORDING ; break ; default : debug_error(INVALID_STATE) ; break ; } break; case LM_STOP_RECORDING : switch ( virtual_remote_state ) { case REMOTE_RELEASE : logic_module_state = LM_RELEASE ; kbd_key_release(USB_VIDEO_BUTTON); break ; case REMOTE_HALF_PRESS : case REMOTE_FULL_PRESS: break ; default : debug_error(INVALID_STATE) ; break ; } break; default : debug_error(INVALID_STATE) ; break ; } };
void usb_shoot_module_bracketing() { int current_time ; current_time = get_tick_count() ; static long usb_remote_stack_name = -1; switch( logic_module_state ) { case LM_RESET : logic_module_state = LM_RELEASE ; break ; case LM_RELEASE : if (( stime_stamp ) && ( current_time - stime_stamp > 5000 ) ) { bracketing_reset() ; stime_stamp = 0 ; } switch ( virtual_remote_state ) { case REMOTE_RELEASE : break ; case REMOTE_HALF_PRESS : kbd_key_press(KEY_SHOOT_HALF); logic_module_state = LM_HALF_PRESS ; break ; case REMOTE_FULL_PRESS: kbd_key_press(KEY_SHOOT_FULL); logic_module_state = LM_FULL_PRESS ; stime_stamp = current_time ; break ; default : debug_error(INVALID_STATE) ; break ; } break ; case LM_HALF_PRESS : switch ( virtual_remote_state ) { case REMOTE_RELEASE : kbd_key_release(KEY_SHOOT_HALF); logic_module_state = LM_RELEASE ; break ; case REMOTE_HALF_PRESS : break ; case REMOTE_FULL_PRESS: kbd_key_press(KEY_SHOOT_FULL); logic_module_state = LM_FULL_PRESS ; stime_stamp = current_time ; break ; default : debug_error(INVALID_STATE) ; break ; } break ; case LM_FULL_PRESS : switch ( virtual_remote_state ) { case REMOTE_RELEASE : kbd_key_release(KEY_SHOOT_FULL_ONLY); kbd_key_release(KEY_SHOOT_HALF); logic_module_state = LM_RELEASE ; bracketing_step(SET_LATER) ; break ; case REMOTE_HALF_PRESS : kbd_key_release(KEY_SHOOT_FULL_ONLY); logic_module_state = LM_HALF_PRESS ; bracketing_step(SET_LATER) ; break ; case REMOTE_FULL_PRESS: break ; default : debug_error(INVALID_STATE) ; break ; } break ; default : debug_error(INVALID_STATE) ; break ; } }
void usb_shoot_module_normal() { static long usb_remote_stack_name = -1; if ( conf.synch_enable == 0 ) // handle key presses differently if in sync mode { switch( logic_module_state ) { case LM_RESET : kbd_key_release(KEY_SHOOT_FULL); kbd_key_release(KEY_SHOOT_HALF); logic_module_state = LM_RELEASE ; break ; case LM_RELEASE : switch ( virtual_remote_state ) { case REMOTE_RELEASE : break ; case REMOTE_HALF_PRESS : kbd_key_press(KEY_SHOOT_HALF); logic_module_state = LM_HALF_PRESS ; break ; case REMOTE_FULL_PRESS: kbd_key_press(KEY_SHOOT_HALF); kbd_key_press(KEY_SHOOT_FULL); logic_module_state = LM_FULL_PRESS ; break ; default : debug_error(INVALID_STATE) ; break ; } break ; case LM_HALF_PRESS : switch ( virtual_remote_state ) { case REMOTE_RELEASE : kbd_key_release(KEY_SHOOT_HALF); logic_module_state = LM_RELEASE ; break ; case REMOTE_HALF_PRESS : break ; case REMOTE_FULL_PRESS: kbd_key_press(KEY_SHOOT_FULL); logic_module_state = LM_FULL_PRESS ; break ; default : debug_error(INVALID_STATE) ; break ; } break ; case LM_FULL_PRESS : switch ( virtual_remote_state ) { case REMOTE_RELEASE : kbd_key_release(KEY_SHOOT_FULL); kbd_key_release(KEY_SHOOT_HALF); logic_module_state = LM_RELEASE ; break ; case REMOTE_HALF_PRESS: kbd_key_release(KEY_SHOOT_FULL); logic_module_state = LM_HALF_PRESS ; break ; case REMOTE_FULL_PRESS: break ; default : debug_error(INVALID_STATE) ; break ; } break ; default : debug_error(INVALID_STATE) ; break ; } } else // syncable remote mode { switch( logic_module_state ) { case LM_RESET : logic_module_state = LM_RELEASE ; break ; case LM_RELEASE : switch ( virtual_remote_state ) { case REMOTE_HALF_PRESS : switch ( switch_type) { case SW_ONE_PRESS : usb_remote_stack_name = action_stack_create(&action_stack_standard,AS_SHOOT); usb_sync_wait = 1; logic_module_state = LM_HALF_PRESS ; break ; case SW_TWO_PRESS : case SW_RICOH_CA1 : kbd_key_press(KEY_SHOOT_HALF); logic_module_state = LM_HALF_PRESS ; break ; default : break ; } break ; case REMOTE_RELEASE : case REMOTE_FULL_PRESS: break ; default : debug_error(INVALID_STATE) ; break ; } break ; case LM_HALF_PRESS : switch ( virtual_remote_state ) { case REMOTE_FULL_PRESS: switch ( switch_type) { case SW_ONE_PRESS : logic_module_state = LM_FULL_PRESS ; break ; case SW_TWO_PRESS : case SW_RICOH_CA1 : usb_sync_wait = 1; kbd_key_press(KEY_SHOOT_FULL); logic_module_state = LM_FULL_PRESS ; break ; default : break ; } break ; case REMOTE_RELEASE : switch ( switch_type) { case SW_ONE_PRESS : if( action_stack_is_finished(usb_remote_stack_name) ) { logic_module_state = LM_RELEASE ; } break ; case SW_TWO_PRESS : case SW_RICOH_CA1 : kbd_key_release(KEY_SHOOT_HALF); logic_module_state = LM_RELEASE ; break ; default : break ; } break ; case REMOTE_HALF_PRESS : break ; default : debug_error(INVALID_STATE) ; break ; } break ; case LM_FULL_PRESS : switch ( virtual_remote_state ) { case REMOTE_RELEASE : switch ( switch_type) { case SW_ONE_PRESS : if( action_stack_is_finished(usb_remote_stack_name) ) { logic_module_state = LM_RELEASE ; } break ; case SW_TWO_PRESS : case SW_RICOH_CA1 : usb_sync_wait = 0; logic_module_state = LM_RELEASE ; kbd_key_release(KEY_SHOOT_FULL); kbd_key_release(KEY_SHOOT_HALF); break ; default : break ; } break ; case REMOTE_HALF_PRESS : case REMOTE_FULL_PRESS: break ; default : debug_error(INVALID_STATE) ; break ; } break ; default : debug_error(INVALID_STATE) ; break ; } } };
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; }
void process_script() { long t; int Lres; // process stack operations if (kbd_int_stack_ptr){ switch (KBD_STACK_PREV(1)){ case SCRIPT_MOTION_DETECTOR: if(md_detect_motion()==0){ kbd_int_stack_ptr-=1; if (L) { // We need to recover the motion detector's // result from ubasic variable 0 and push // it onto the thread's stack. -- AUJ lua_pushnumber( Lt, ubasic_get_variable(0) ); } } return; case SCRIPT_PRESS: kbd_key_press(KBD_STACK_PREV(2)); kbd_int_stack_ptr-=2; // pop op. return; case SCRIPT_RELEASE: kbd_key_release(KBD_STACK_PREV(2)); kbd_int_stack_ptr-=2; // pop op. return; case SCRIPT_SLEEP: t = get_tick_count(); // FIXME take care if overflow occurs if (delay_target_ticks == 0){ /* setup timer */ delay_target_ticks = t+KBD_STACK_PREV(2); } else { if (delay_target_ticks <= t){ delay_target_ticks = 0; kbd_int_stack_ptr-=2; // pop sleep op. } } return; case SCRIPT_PR_WAIT_SAVE: state_shooting_progress = SHOOTING_PROGRESS_NONE; state_expos_recalculated = 0; histogram_stop(); kbd_int_stack_ptr-=1; // pop op. return; case SCRIPT_WAIT_SAVE:{ if (state_shooting_progress == SHOOTING_PROGRESS_DONE) kbd_int_stack_ptr-=1; // pop op. return; } case SCRIPT_WAIT_FLASH:{ if (shooting_is_flash_ready()) kbd_int_stack_ptr-=1; // pop op. return; } case SCRIPT_WAIT_EXPHIST:{ if (state_expos_recalculated) { kbd_int_stack_ptr-=1; // pop op. state_expos_under = under_exposed; state_expos_over = over_exposed; } return; } case SCRIPT_PR_WAIT_EXPHIST: { if (shooting_in_progress() || mvideo) { state_expos_recalculated = 0; histogram_restart(); kbd_int_stack_ptr-=1; // pop op. } return; } case SCRIPT_WAIT_CLICK: { t = get_tick_count(); if (delay_target_ticks == 0){ /* setup timer */ delay_target_ticks = t+((KBD_STACK_PREV(2))?KBD_STACK_PREV(2):86400000); } else { kbd_last_clicked = kbd_get_clicked_key(); if (kbd_last_clicked || delay_target_ticks <= t) { if (!kbd_last_clicked) kbd_last_clicked=0xFFFF; delay_target_ticks = 0; kbd_int_stack_ptr-=2; // pop op. } } return; } default: /*finished();*/ script_end(); } } if (state_kbd_script_run != 3) { if( L ) { int top; if (state_lua_kbd_first_call_to_resume) { state_lua_kbd_first_call_to_resume = 0; top = 0; } else { top = lua_gettop(Lt); } Lres = lua_resume( Lt, top ); if (Lres != LUA_YIELD && Lres != 0) { script_console_add_line( lua_tostring( Lt, -1 ) ); wait_and_end(); return; } if (Lres != LUA_YIELD) { script_console_add_line(lang_str(LANG_CONSOLE_TEXT_FINISHED)); script_end(); } } else { ubasic_run(); if (ubasic_finished()) { script_console_add_line(lang_str(LANG_CONSOLE_TEXT_FINISHED)); script_end(); } } } }