| 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 "camera.h" |
|---|
| 8 | #include "lang.h" |
|---|
| 9 | #include "ubasic.h" |
|---|
| 10 | #include "histogram.h" |
|---|
| 11 | #include "script.h" |
|---|
| 12 | #include "gui_lang.h" |
|---|
| 13 | #include "motion_detector.h" |
|---|
| 14 | #include "lua.h" |
|---|
| 15 | #include "lualib.h" |
|---|
| 16 | #include "lauxlib.h" |
|---|
| 17 | #include "luascript.h" |
|---|
| 18 | #include "../lib/lua/lstate.h" // for L->nCcalls, baseCcalls |
|---|
| 19 | #include "shot_histogram.h" |
|---|
| 20 | |
|---|
| 21 | #define SCRIPT_END 0 |
|---|
| 22 | #define SCRIPT_CLICK 1 |
|---|
| 23 | #define SCRIPT_SHOOT 2 |
|---|
| 24 | #define SCRIPT_SLEEP 3 |
|---|
| 25 | #define SCRIPT_PRESS 4 |
|---|
| 26 | #define SCRIPT_RELEASE 5 |
|---|
| 27 | #define SCRIPT_PR_WAIT_SAVE 6 |
|---|
| 28 | #define SCRIPT_WAIT_SAVE 7 |
|---|
| 29 | #define SCRIPT_WAIT_FLASH 8 |
|---|
| 30 | #define SCRIPT_WAIT_EXPHIST 9 |
|---|
| 31 | #define SCRIPT_PR_WAIT_EXPHIST 10 |
|---|
| 32 | #define SCRIPT_WAIT_CLICK 11 |
|---|
| 33 | #define SCRIPT_MOTION_DETECTOR 12 |
|---|
| 34 | |
|---|
| 35 | #define KBD_STACK_SIZE 24 |
|---|
| 36 | |
|---|
| 37 | static long kbd_int_stack[KBD_STACK_SIZE]; |
|---|
| 38 | static int kbd_int_stack_ptr; |
|---|
| 39 | |
|---|
| 40 | #define KBD_STACK_PUSH(v) kbd_int_stack[kbd_int_stack_ptr++] = (v); |
|---|
| 41 | #define KBD_STACK_PREV(p) (kbd_int_stack[kbd_int_stack_ptr-(p)]) |
|---|
| 42 | |
|---|
| 43 | static int soft_half_press = 0; |
|---|
| 44 | static int kbd_blocked; |
|---|
| 45 | static int key_pressed; |
|---|
| 46 | int state_kbd_script_run; |
|---|
| 47 | int state_lua_kbd_first_call_to_resume; // AUJ |
|---|
| 48 | static long delay_target_ticks; |
|---|
| 49 | static long kbd_last_clicked; |
|---|
| 50 | |
|---|
| 51 | // ------ add by Masuji SUTO (start) -------------- |
|---|
| 52 | static int mvideo,mplay; |
|---|
| 53 | static int nSW=0; |
|---|
| 54 | static int nRmt=0; |
|---|
| 55 | static int nWt=0; |
|---|
| 56 | static int nCount=0; |
|---|
| 57 | static int nCa=0; |
|---|
| 58 | static int nCount2=0; |
|---|
| 59 | static int nTxvideo=0; |
|---|
| 60 | static int nTxzoom=0; |
|---|
| 61 | static int nTxzname=KEY_ZOOM_IN; |
|---|
| 62 | static int nPlyname=KEY_LEFT; |
|---|
| 63 | static int nIntzpos; |
|---|
| 64 | static int nReczoom=0; |
|---|
| 65 | static int nTxtblcr=0; |
|---|
| 66 | int shutter_int=0; |
|---|
| 67 | |
|---|
| 68 | #if defined(CAMERA_ixus960_sd950) |
|---|
| 69 | static int nFirst=1; |
|---|
| 70 | #endif |
|---|
| 71 | |
|---|
| 72 | #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_ixus75_sd750) || defined(CAMERA_a470) |
|---|
| 73 | #define ZSTEP_TABLE_SIZE 7 |
|---|
| 74 | static int nTxtbl[]={0,1,2,3,4,5,6}; |
|---|
| 75 | #endif |
|---|
| 76 | |
|---|
| 77 | #if defined(CAMERA_s2is) || defined(CAMERA_s3is) || defined(CAMERA_s5is) || defined(CAMERA_sx10) || defined(CAMERA_sx1) |
|---|
| 78 | #define ZSTEP_TABLE_SIZE 8 |
|---|
| 79 | static int nTxtbl[]={0,11,25,41,64,86,105,128}; |
|---|
| 80 | #endif |
|---|
| 81 | |
|---|
| 82 | #if defined(CAMERA_tx1) |
|---|
| 83 | #define ZSTEP_TABLE_SIZE 8 |
|---|
| 84 | static int nTxtbl[]={0,18,43,55,76,93,113,124}; |
|---|
| 85 | #endif |
|---|
| 86 | |
|---|
| 87 | #if 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) |
|---|
| 88 | #define ZSTEP_TABLE_SIZE 8 |
|---|
| 89 | static int nTxtbl[]={0,1,2,3,4,5,6,7}; |
|---|
| 90 | #endif |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | #if defined(CAMERA_a610) || defined(CAMERA_a620) || defined(CAMERA_a630) || defined(CAMERA_a640) || defined(CAMERA_ixus800_sd700) || defined(CAMERA_ixus950_sd850) |
|---|
| 94 | #define ZSTEP_TABLE_SIZE 9 |
|---|
| 95 | static int nTxtbl[]={0,1,2,3,4,5,6,7,8}; |
|---|
| 96 | #endif |
|---|
| 97 | |
|---|
| 98 | #if defined (CAMERA_a700) || defined(CAMERA_a710) || defined (CAMERA_a720) || defined (CAMERA_a2000) |
|---|
| 99 | #define ZSTEP_TABLE_SIZE 8 |
|---|
| 100 | static int nTxtbl[]={0,2,4,6,8,10,12,14}; |
|---|
| 101 | #endif |
|---|
| 102 | |
|---|
| 103 | #if defined(CAMERA_a650) || defined(CAMERA_g7) || defined(CAMERA_g9) |
|---|
| 104 | #define ZSTEP_TABLE_SIZE 8 |
|---|
| 105 | static int nTxtbl[]={0,2,4,6,8,10,12,13}; |
|---|
| 106 | #endif |
|---|
| 107 | // ------ add by Masuji SUTO (end) -------------- |
|---|
| 108 | #if defined(CAMERA_sx100is) || defined(CAMERA_sx110is) |
|---|
| 109 | #define ZSTEP_TABLE_SIZE 8 |
|---|
| 110 | static int nTxtbl[]={0,3,6,9,13,16,20,23}; |
|---|
| 111 | #endif |
|---|
| 112 | |
|---|
| 113 | #if defined(CAMERA_ixus870_sd880) |
|---|
| 114 | #define ZSTEP_TABLE_SIZE 10 |
|---|
| 115 | static int nTxtbl[]={0,1,2,3,4,5,6,7,8,9}; |
|---|
| 116 | #endif |
|---|
| 117 | |
|---|
| 118 | #if defined(CAMERA_sx200is) |
|---|
| 119 | #define ZSTEP_TABLE_SIZE 7 |
|---|
| 120 | static int nTxtbl[]={0,16,32,62,78,102,125}; |
|---|
| 121 | #endif |
|---|
| 122 | |
|---|
| 123 | void kbd_sched_delay(long msec) |
|---|
| 124 | { |
|---|
| 125 | KBD_STACK_PUSH(msec); |
|---|
| 126 | KBD_STACK_PUSH(SCRIPT_SLEEP); |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | void kbd_sched_motion_detector(){ |
|---|
| 131 | KBD_STACK_PUSH(SCRIPT_MOTION_DETECTOR); |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | void kbd_sched_press(long key) |
|---|
| 135 | { |
|---|
| 136 | // WARNING stack program flow is reversed |
|---|
| 137 | kbd_sched_delay(20); |
|---|
| 138 | |
|---|
| 139 | KBD_STACK_PUSH(key); |
|---|
| 140 | KBD_STACK_PUSH(SCRIPT_PRESS); |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | void kbd_sched_release(long key) |
|---|
| 144 | { |
|---|
| 145 | // WARNING stack program flow is reversed |
|---|
| 146 | kbd_sched_delay(20); |
|---|
| 147 | |
|---|
| 148 | KBD_STACK_PUSH(key); |
|---|
| 149 | KBD_STACK_PUSH(SCRIPT_RELEASE); |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | void md_kbd_sched_immediate_shoot(int no_release) |
|---|
| 153 | { |
|---|
| 154 | kbd_int_stack_ptr-=1;// REMOVE MD ITEM |
|---|
| 155 | |
|---|
| 156 | // stack operations are reversed! |
|---|
| 157 | if (!no_release) // only release shutter if allowed |
|---|
| 158 | { |
|---|
| 159 | kbd_sched_release(KEY_SHOOT_FULL); |
|---|
| 160 | kbd_sched_delay(20); |
|---|
| 161 | } |
|---|
| 162 | KBD_STACK_PUSH(SCRIPT_MOTION_DETECTOR); // it will removed right after exit from this function |
|---|
| 163 | kbd_key_press(KEY_SHOOT_FULL); // not a stack operation... pressing right now |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | |
|---|
| 167 | void kbd_sched_click(long key) |
|---|
| 168 | { |
|---|
| 169 | // WARNING stack program flow is reversed |
|---|
| 170 | kbd_sched_release(key); |
|---|
| 171 | kbd_sched_press(key); |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | static void kbd_sched_wait_click(int timeout) |
|---|
| 175 | { |
|---|
| 176 | // WARNING stack program flow is reversed |
|---|
| 177 | KBD_STACK_PUSH(timeout); |
|---|
| 178 | KBD_STACK_PUSH(SCRIPT_WAIT_CLICK); |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | void kbd_sched_shoot() |
|---|
| 182 | { |
|---|
| 183 | // WARNING stack program flow is reversed |
|---|
| 184 | |
|---|
| 185 | kbd_sched_delay(conf.script_shoot_delay*100);// XXX FIXME find out how to wait to jpeg save finished |
|---|
| 186 | |
|---|
| 187 | KBD_STACK_PUSH(SCRIPT_WAIT_SAVE); |
|---|
| 188 | |
|---|
| 189 | KBD_STACK_PUSH(KEY_SHOOT_FULL); |
|---|
| 190 | KBD_STACK_PUSH(SCRIPT_RELEASE); |
|---|
| 191 | |
|---|
| 192 | kbd_sched_delay(20); |
|---|
| 193 | |
|---|
| 194 | KBD_STACK_PUSH(KEY_SHOOT_FULL); |
|---|
| 195 | KBD_STACK_PUSH(SCRIPT_PRESS); |
|---|
| 196 | |
|---|
| 197 | KBD_STACK_PUSH(SCRIPT_WAIT_FLASH); |
|---|
| 198 | KBD_STACK_PUSH(SCRIPT_WAIT_EXPHIST); |
|---|
| 199 | KBD_STACK_PUSH(SCRIPT_PR_WAIT_EXPHIST); |
|---|
| 200 | |
|---|
| 201 | kbd_sched_delay(10); |
|---|
| 202 | |
|---|
| 203 | KBD_STACK_PUSH(KEY_SHOOT_HALF); |
|---|
| 204 | KBD_STACK_PUSH(SCRIPT_PRESS); |
|---|
| 205 | |
|---|
| 206 | KBD_STACK_PUSH(SCRIPT_PR_WAIT_SAVE); |
|---|
| 207 | |
|---|
| 208 | } |
|---|
| 209 | |
|---|
| 210 | static lua_State* L, *Lt; |
|---|
| 211 | |
|---|
| 212 | static int is_lua() |
|---|
| 213 | { |
|---|
| 214 | int len; |
|---|
| 215 | char const* s; |
|---|
| 216 | s = conf.script_file; |
|---|
| 217 | len = strlen( s ); |
|---|
| 218 | return len >= 4 && ( s[len-1] == 'a' || s[len-1] == 'A' ) |
|---|
| 219 | && ( s[len-2] == 'u' || s[len-2] == 'U' ) |
|---|
| 220 | && ( s[len-3] == 'l' || s[len-3] == 'L' ) |
|---|
| 221 | && s[len-4] == '.'; |
|---|
| 222 | } |
|---|
| 223 | |
|---|
| 224 | static void lua_count_hook(lua_State *L, lua_Debug *ar) |
|---|
| 225 | { |
|---|
| 226 | if( L->nCcalls <= L->baseCcalls ) |
|---|
| 227 | lua_yield( L, 0 ); |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | void lua_script_reset(lua_State *L){ |
|---|
| 231 | lua_close( L ); |
|---|
| 232 | L = 0; |
|---|
| 233 | Lt = 0; |
|---|
| 234 | } |
|---|
| 235 | |
|---|
| 236 | static int lua_script_start( char const* script ) |
|---|
| 237 | { |
|---|
| 238 | L = lua_open(); |
|---|
| 239 | luaL_openlibs( L ); |
|---|
| 240 | register_lua_funcs( L ); |
|---|
| 241 | |
|---|
| 242 | Lt = lua_newthread( L ); |
|---|
| 243 | lua_setfield( L, LUA_REGISTRYINDEX, "Lt" ); |
|---|
| 244 | if( luaL_loadstring( Lt, script ) != 0 ) { |
|---|
| 245 | script_console_add_line( lua_tostring( Lt, -1 ) ); |
|---|
| 246 | lua_script_reset( L ); |
|---|
| 247 | return 0; |
|---|
| 248 | } |
|---|
| 249 | lua_sethook(Lt, lua_count_hook, LUA_MASKCOUNT, 1000 ); |
|---|
| 250 | return 1; |
|---|
| 251 | } |
|---|
| 252 | |
|---|
| 253 | static void wait_and_end(void) |
|---|
| 254 | { |
|---|
| 255 | script_console_add_line("PRESS SHUTTER TO CLOSE"); |
|---|
| 256 | |
|---|
| 257 | // We're not running any more, but we have scheduled stuff that |
|---|
| 258 | // needs to finish. So keep the script marked as running, but don't |
|---|
| 259 | // call any more scripting functions. |
|---|
| 260 | state_kbd_script_run = 3; |
|---|
| 261 | } |
|---|
| 262 | |
|---|
| 263 | void script_start( int autostart ) |
|---|
| 264 | { |
|---|
| 265 | int i; |
|---|
| 266 | |
|---|
| 267 | shot_histogram_set(0); |
|---|
| 268 | if (autostart) |
|---|
| 269 | auto_started = 1; |
|---|
| 270 | else |
|---|
| 271 | auto_started = 0; |
|---|
| 272 | |
|---|
| 273 | delay_target_ticks = 0; |
|---|
| 274 | kbd_int_stack_ptr = 0; |
|---|
| 275 | kbd_last_clicked = 0; |
|---|
| 276 | |
|---|
| 277 | /*if (!autostart)*/ kbd_key_release_all(); |
|---|
| 278 | |
|---|
| 279 | script_console_clear(); |
|---|
| 280 | script_print_screen_init(); |
|---|
| 281 | |
|---|
| 282 | if (conf.script_param_save) { |
|---|
| 283 | save_params_values(0); |
|---|
| 284 | } |
|---|
| 285 | if( autostart ) |
|---|
| 286 | script_console_add_line("***Autostart***"); |
|---|
| 287 | else |
|---|
| 288 | script_console_add_line(lang_str(LANG_CONSOLE_TEXT_STARTED)); |
|---|
| 289 | |
|---|
| 290 | if( is_lua() ) { |
|---|
| 291 | if( !lua_script_start(state_ubasic_script) ) { |
|---|
| 292 | script_print_screen_end(); |
|---|
| 293 | wait_and_end(); |
|---|
| 294 | return; |
|---|
| 295 | } |
|---|
| 296 | for (i=0; i<SCRIPT_NUM_PARAMS; ++i) { |
|---|
| 297 | if( script_params[i][0] ) { |
|---|
| 298 | char var = 'a'+i; |
|---|
| 299 | lua_pushlstring( L, &var, 1 ); |
|---|
| 300 | lua_pushnumber( L, conf.ubasic_vars[i] ); |
|---|
| 301 | lua_settable( L, LUA_GLOBALSINDEX ); |
|---|
| 302 | } |
|---|
| 303 | } |
|---|
| 304 | state_lua_kbd_first_call_to_resume = 1; |
|---|
| 305 | } else { // ubasic |
|---|
| 306 | ubasic_init(state_ubasic_script); |
|---|
| 307 | |
|---|
| 308 | for (i=0; i<SCRIPT_NUM_PARAMS; ++i) { |
|---|
| 309 | ubasic_set_variable(i, conf.ubasic_vars[i]); |
|---|
| 310 | } |
|---|
| 311 | } |
|---|
| 312 | |
|---|
| 313 | state_kbd_script_run = 1; |
|---|
| 314 | |
|---|
| 315 | if (conf.alt_prevent_shutdown != ALT_PREVENT_SHUTDOWN_ALT_SCRIPT) { |
|---|
| 316 | enable_shutdown(); |
|---|
| 317 | } |
|---|
| 318 | } |
|---|
| 319 | |
|---|
| 320 | void script_end() |
|---|
| 321 | { |
|---|
| 322 | script_print_screen_end(); |
|---|
| 323 | if( L ) { |
|---|
| 324 | lua_script_reset( L ); |
|---|
| 325 | } |
|---|
| 326 | else { |
|---|
| 327 | ubasic_end(); |
|---|
| 328 | } |
|---|
| 329 | md_close_motion_detector(); |
|---|
| 330 | shot_histogram_set(0); |
|---|
| 331 | if (conf.alt_prevent_shutdown != ALT_PREVENT_SHUTDOWN_NO) { |
|---|
| 332 | disable_shutdown(); |
|---|
| 333 | } |
|---|
| 334 | kbd_key_release_all(); |
|---|
| 335 | state_kbd_script_run = 0; |
|---|
| 336 | vid_bitmap_refresh(); |
|---|
| 337 | } |
|---|
| 338 | |
|---|
| 339 | void process_script() |
|---|
| 340 | { |
|---|
| 341 | long t; |
|---|
| 342 | int Lres; |
|---|
| 343 | |
|---|
| 344 | // process stack operations |
|---|
| 345 | if (kbd_int_stack_ptr){ |
|---|
| 346 | switch (KBD_STACK_PREV(1)) { |
|---|
| 347 | case SCRIPT_MOTION_DETECTOR: |
|---|
| 348 | if(md_detect_motion()==0) { |
|---|
| 349 | kbd_int_stack_ptr-=1; |
|---|
| 350 | if (L) |
|---|
| 351 | { |
|---|
| 352 | // We need to recover the motion detector's |
|---|
| 353 | // result from ubasic variable 0 and push |
|---|
| 354 | // it onto the thread's stack. -- AUJ |
|---|
| 355 | lua_pushnumber( Lt, ubasic_get_variable(0) ); |
|---|
| 356 | } |
|---|
| 357 | } |
|---|
| 358 | return; |
|---|
| 359 | case SCRIPT_PRESS: |
|---|
| 360 | kbd_key_press(KBD_STACK_PREV(2)); |
|---|
| 361 | kbd_int_stack_ptr-=2; // pop op. |
|---|
| 362 | return; |
|---|
| 363 | case SCRIPT_RELEASE: |
|---|
| 364 | kbd_key_release(KBD_STACK_PREV(2)); |
|---|
| 365 | kbd_int_stack_ptr-=2; // pop op. |
|---|
| 366 | return; |
|---|
| 367 | case SCRIPT_SLEEP: |
|---|
| 368 | t = get_tick_count(); |
|---|
| 369 | // FIXME take care if overflow occurs |
|---|
| 370 | if (delay_target_ticks == 0){ |
|---|
| 371 | /* setup timer */ |
|---|
| 372 | delay_target_ticks = t+KBD_STACK_PREV(2); |
|---|
| 373 | } else { |
|---|
| 374 | if (delay_target_ticks <= t){ |
|---|
| 375 | delay_target_ticks = 0; |
|---|
| 376 | kbd_int_stack_ptr-=2; // pop sleep op. |
|---|
| 377 | } |
|---|
| 378 | } |
|---|
| 379 | return; |
|---|
| 380 | case SCRIPT_PR_WAIT_SAVE: |
|---|
| 381 | state_shooting_progress = SHOOTING_PROGRESS_NONE; |
|---|
| 382 | state_expos_recalculated = 0; |
|---|
| 383 | histogram_stop(); |
|---|
| 384 | |
|---|
| 385 | kbd_int_stack_ptr-=1; // pop op. |
|---|
| 386 | return; |
|---|
| 387 | case SCRIPT_WAIT_SAVE:{ |
|---|
| 388 | if (state_shooting_progress == SHOOTING_PROGRESS_DONE) |
|---|
| 389 | kbd_int_stack_ptr-=1; // pop op. |
|---|
| 390 | return; |
|---|
| 391 | } |
|---|
| 392 | case SCRIPT_WAIT_FLASH:{ |
|---|
| 393 | if (shooting_is_flash_ready()) |
|---|
| 394 | kbd_int_stack_ptr-=1; // pop op. |
|---|
| 395 | return; |
|---|
| 396 | } |
|---|
| 397 | case SCRIPT_WAIT_EXPHIST:{ |
|---|
| 398 | if (state_expos_recalculated) { |
|---|
| 399 | kbd_int_stack_ptr-=1; // pop op. |
|---|
| 400 | state_expos_under = under_exposed; |
|---|
| 401 | state_expos_over = over_exposed; |
|---|
| 402 | } |
|---|
| 403 | return; |
|---|
| 404 | } |
|---|
| 405 | case SCRIPT_PR_WAIT_EXPHIST: { |
|---|
| 406 | if (shooting_in_progress() || mvideo) { |
|---|
| 407 | state_expos_recalculated = 0; |
|---|
| 408 | histogram_restart(); |
|---|
| 409 | kbd_int_stack_ptr-=1; // pop op. |
|---|
| 410 | } |
|---|
| 411 | return; |
|---|
| 412 | } |
|---|
| 413 | case SCRIPT_WAIT_CLICK: { |
|---|
| 414 | t = get_tick_count(); |
|---|
| 415 | if (delay_target_ticks == 0){ |
|---|
| 416 | /* setup timer */ |
|---|
| 417 | delay_target_ticks = t+((KBD_STACK_PREV(2))?KBD_STACK_PREV(2):86400000); |
|---|
| 418 | } else { |
|---|
| 419 | kbd_last_clicked = kbd_get_clicked_key(); |
|---|
| 420 | if (kbd_last_clicked || delay_target_ticks <= t) { |
|---|
| 421 | if (!kbd_last_clicked) |
|---|
| 422 | kbd_last_clicked=0xFFFF; |
|---|
| 423 | delay_target_ticks = 0; |
|---|
| 424 | kbd_int_stack_ptr-=2; // pop op. |
|---|
| 425 | } |
|---|
| 426 | } |
|---|
| 427 | return; |
|---|
| 428 | } |
|---|
| 429 | default: |
|---|
| 430 | /*finished();*/ |
|---|
| 431 | script_end(); |
|---|
| 432 | } |
|---|
| 433 | } |
|---|
| 434 | |
|---|
| 435 | if (state_kbd_script_run != 3) { |
|---|
| 436 | if( L ) { |
|---|
| 437 | int top; |
|---|
| 438 | if (state_lua_kbd_first_call_to_resume) { |
|---|
| 439 | state_lua_kbd_first_call_to_resume = 0; |
|---|
| 440 | top = 0; |
|---|
| 441 | } else { |
|---|
| 442 | top = lua_gettop(Lt); |
|---|
| 443 | } |
|---|
| 444 | Lres = lua_resume( Lt, top ); |
|---|
| 445 | |
|---|
| 446 | if (Lres != LUA_YIELD && Lres != 0) { |
|---|
| 447 | script_console_add_line( lua_tostring( Lt, -1 ) ); |
|---|
| 448 | if(conf.debug_lua_restart_on_error){ |
|---|
| 449 | lua_script_reset( L ); |
|---|
| 450 | script_start(0); |
|---|
| 451 | } else { |
|---|
| 452 | wait_and_end(); |
|---|
| 453 | } |
|---|
| 454 | return; |
|---|
| 455 | } |
|---|
| 456 | |
|---|
| 457 | if (Lres != LUA_YIELD) { |
|---|
| 458 | script_console_add_line(lang_str(LANG_CONSOLE_TEXT_FINISHED)); |
|---|
| 459 | script_end(); |
|---|
| 460 | } |
|---|
| 461 | } else { |
|---|
| 462 | ubasic_run(); |
|---|
| 463 | if (ubasic_finished()) { |
|---|
| 464 | script_console_add_line(lang_str(LANG_CONSOLE_TEXT_FINISHED)); |
|---|
| 465 | script_end(); |
|---|
| 466 | } |
|---|
| 467 | } |
|---|
| 468 | } |
|---|
| 469 | } |
|---|
| 470 | |
|---|
| 471 | void ubasic_camera_press(const char *s) |
|---|
| 472 | { |
|---|
| 473 | long k = keyid_by_name(s); |
|---|
| 474 | if (k > 0) { |
|---|
| 475 | kbd_sched_press(k); |
|---|
| 476 | } else { |
|---|
| 477 | ubasic_error = 3; |
|---|
| 478 | } |
|---|
| 479 | } |
|---|
| 480 | |
|---|
| 481 | void ubasic_camera_release(const char *s) |
|---|
| 482 | { |
|---|
| 483 | long k = keyid_by_name(s); |
|---|
| 484 | if (k > 0) { |
|---|
| 485 | kbd_sched_release(k); |
|---|
| 486 | } else { |
|---|
| 487 | ubasic_error = 3; |
|---|
| 488 | } |
|---|
| 489 | } |
|---|
| 490 | |
|---|
| 491 | void ubasic_camera_click(const char *s) |
|---|
| 492 | { |
|---|
| 493 | long k = keyid_by_name(s); |
|---|
| 494 | if (k > 0) { |
|---|
| 495 | kbd_sched_click(k); |
|---|
| 496 | } else { |
|---|
| 497 | ubasic_error = 3; |
|---|
| 498 | } |
|---|
| 499 | } |
|---|
| 500 | |
|---|
| 501 | void ubasic_camera_wait_click(int timeout) |
|---|
| 502 | { |
|---|
| 503 | kbd_sched_wait_click(timeout); |
|---|
| 504 | } |
|---|
| 505 | |
|---|
| 506 | int ubasic_camera_is_pressed(const char *s) |
|---|
| 507 | { |
|---|
| 508 | long k = keyid_by_name(s); |
|---|
| 509 | if (k==0xFF) return get_usb_power(1); |
|---|
| 510 | if (k > 0) { |
|---|
| 511 | return (kbd_is_key_pressed(k)); |
|---|
| 512 | } else { |
|---|
| 513 | ubasic_error = 3; |
|---|
| 514 | } |
|---|
| 515 | return 0; |
|---|
| 516 | } |
|---|
| 517 | |
|---|
| 518 | int ubasic_camera_is_clicked(const char *s) |
|---|
| 519 | { |
|---|
| 520 | long k = keyid_by_name(s); |
|---|
| 521 | if (k==0xFF) return get_usb_power(1); |
|---|
| 522 | if (k > 0) { |
|---|
| 523 | return (kbd_last_clicked == k); |
|---|
| 524 | } else { |
|---|
| 525 | ubasic_error = 3; |
|---|
| 526 | } |
|---|
| 527 | return 0; |
|---|
| 528 | } |
|---|
| 529 | |
|---|
| 530 | void ubasic_camera_sleep(long v) |
|---|
| 531 | { |
|---|
| 532 | kbd_sched_delay(v); |
|---|
| 533 | } |
|---|
| 534 | |
|---|
| 535 | void ubasic_camera_shoot() |
|---|
| 536 | { |
|---|
| 537 | kbd_sched_shoot(); |
|---|
| 538 | } |
|---|
| 539 | // remote autostart |
|---|
| 540 | void script_autostart() |
|---|
| 541 | { |
|---|
| 542 | kbd_blocked = 1; |
|---|
| 543 | gui_kbd_enter(); |
|---|
| 544 | script_console_clear(); |
|---|
| 545 | script_console_add_line("***Autostart***"); //lang_str(LANG_CONSOLE_TEXT_STARTED)); |
|---|
| 546 | script_start( 1 ); |
|---|
| 547 | } |
|---|
| 548 | void exit_alt() |
|---|
| 549 | { |
|---|
| 550 | kbd_blocked = 0; |
|---|
| 551 | gui_kbd_leave(); |
|---|
| 552 | } |
|---|
| 553 | |
|---|
| 554 | // ------ add by Masuji SUTO (start) -------------- |
|---|
| 555 | void set_key_press(int nSet) |
|---|
| 556 | { |
|---|
| 557 | key_pressed = nSet; |
|---|
| 558 | kbd_blocked = nSet; |
|---|
| 559 | nRmt = nSet; |
|---|
| 560 | } |
|---|
| 561 | // ------ add by Masuji SUTO (end) -------------- |
|---|
| 562 | |
|---|
| 563 | /*------------------- Alex scriptless remote additions start --------------------*/ |
|---|
| 564 | static int remoteHalfShutter=0, remoteFullShutter=0, remoteShooting=0, remoteClickTimer=0; |
|---|
| 565 | #define REMOTE_MAX_CLICK_LENGTH 50 |
|---|
| 566 | /*-------------------- Alex scriptless remote additions end ---------------------*/ |
|---|
| 567 | |
|---|
| 568 | /* |
|---|
| 569 | main kb processing |
|---|
| 570 | this monster needs to be broken up and documented, remote stuff should go in it's own functions |
|---|
| 571 | */ |
|---|
| 572 | long kbd_process() |
|---|
| 573 | { |
|---|
| 574 | /* Alternative keyboard mode stated/exited by pressing print key. |
|---|
| 575 | * While running Alt. mode shoot key will start a script execution. |
|---|
| 576 | */ |
|---|
| 577 | static int nCER=0; |
|---|
| 578 | // ------ modif by Masuji SUTO (start) -------------- |
|---|
| 579 | |
|---|
| 580 | unsigned int mmode; |
|---|
| 581 | unsigned int nCrzpos,i; |
|---|
| 582 | unsigned int drmode = 0; |
|---|
| 583 | |
|---|
| 584 | if(conf.ricoh_ca1_mode && conf.remote_enable) { |
|---|
| 585 | drmode = shooting_get_drive_mode(); |
|---|
| 586 | mmode = mode_get(); |
|---|
| 587 | mplay = (mmode&MODE_MASK)==MODE_PLAY; |
|---|
| 588 | // 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); |
|---|
| 589 | mvideo=MODE_IS_VIDEO(mmode); |
|---|
| 590 | } |
|---|
| 591 | // deals with alt-mode switch and delay emulation |
|---|
| 592 | if (key_pressed) { |
|---|
| 593 | if (kbd_is_key_pressed(conf.alt_mode_button) |
|---|
| 594 | || ((key_pressed >= CAM_EMUL_KEYPRESS_DELAY) |
|---|
| 595 | && (key_pressed < CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION))) { |
|---|
| 596 | if (key_pressed <= CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION) |
|---|
| 597 | key_pressed++; |
|---|
| 598 | if (key_pressed == CAM_EMUL_KEYPRESS_DELAY) |
|---|
| 599 | kbd_key_press(conf.alt_mode_button); |
|---|
| 600 | else if (key_pressed == +CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION) |
|---|
| 601 | kbd_key_release(conf.alt_mode_button); |
|---|
| 602 | return 1; |
|---|
| 603 | } else if (kbd_get_pressed_key() == 0) { |
|---|
| 604 | if (key_pressed != 100 && (key_pressed < CAM_EMUL_KEYPRESS_DELAY)) { |
|---|
| 605 | kbd_blocked = 1-kbd_blocked; |
|---|
| 606 | if (kbd_blocked) |
|---|
| 607 | gui_kbd_enter(); |
|---|
| 608 | else |
|---|
| 609 | gui_kbd_leave(); |
|---|
| 610 | } |
|---|
| 611 | key_pressed = 0; |
|---|
| 612 | return 1; |
|---|
| 613 | } |
|---|
| 614 | return 1; |
|---|
| 615 | } |
|---|
| 616 | |
|---|
| 617 | // auto iso shift |
|---|
| 618 | if (kbd_is_key_pressed(KEY_SHOOT_HALF) && kbd_is_key_pressed(conf.alt_mode_button)) |
|---|
| 619 | return 0; |
|---|
| 620 | |
|---|
| 621 | if (kbd_is_key_pressed(conf.alt_mode_button)) { |
|---|
| 622 | if (conf.ricoh_ca1_mode && conf.remote_enable) |
|---|
| 623 | conf.synch_enable=1; |
|---|
| 624 | key_pressed = 1; |
|---|
| 625 | kbd_key_release_all(); |
|---|
| 626 | return 1; |
|---|
| 627 | } |
|---|
| 628 | |
|---|
| 629 | // deals with the rest |
|---|
| 630 | if (kbd_blocked && nRmt==0) { |
|---|
| 631 | /*------------------- Alex scriptless remote additions start --------------------*/ |
|---|
| 632 | if (remoteShooting) { |
|---|
| 633 | if (remoteHalfShutter) { |
|---|
| 634 | if (get_usb_power(1)) { |
|---|
| 635 | if (remoteClickTimer < REMOTE_MAX_CLICK_LENGTH) { |
|---|
| 636 | remoteHalfShutter=0; |
|---|
| 637 | remoteFullShutter=1; |
|---|
| 638 | kbd_key_press(KEY_SHOOT_FULL); |
|---|
| 639 | } |
|---|
| 640 | return 1; |
|---|
| 641 | } else { |
|---|
| 642 | --remoteClickTimer; |
|---|
| 643 | if ( remoteClickTimer == 0 ) { |
|---|
| 644 | kbd_key_release_all(); |
|---|
| 645 | remoteHalfShutter=0; |
|---|
| 646 | remoteShooting=0; |
|---|
| 647 | kbd_blocked=0; |
|---|
| 648 | return 0; |
|---|
| 649 | } |
|---|
| 650 | } |
|---|
| 651 | } |
|---|
| 652 | |
|---|
| 653 | if (remoteFullShutter) { |
|---|
| 654 | if (get_usb_power(1)) { |
|---|
| 655 | return 1; |
|---|
| 656 | } else { |
|---|
| 657 | kbd_key_release_all(); |
|---|
| 658 | remoteFullShutter=0; |
|---|
| 659 | remoteShooting=0; |
|---|
| 660 | kbd_blocked=0; |
|---|
| 661 | return 0; |
|---|
| 662 | } |
|---|
| 663 | } |
|---|
| 664 | } |
|---|
| 665 | /*-------------------- Alex scriptless remote additions end ---------------------*/ |
|---|
| 666 | if (kbd_is_key_pressed(KEY_SHOOT_FULL)) { |
|---|
| 667 | key_pressed = 100; |
|---|
| 668 | if (!state_kbd_script_run) { |
|---|
| 669 | script_start(0); |
|---|
| 670 | } else if (state_kbd_script_run == 2 || state_kbd_script_run == 3) { |
|---|
| 671 | script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED)); |
|---|
| 672 | script_end(); |
|---|
| 673 | } else if (L) { |
|---|
| 674 | state_kbd_script_run = 2; |
|---|
| 675 | lua_getglobal(Lt, "restore"); |
|---|
| 676 | if (lua_isfunction(Lt, -1)) { |
|---|
| 677 | if (lua_pcall( Lt, 0, 0, 0 )) { |
|---|
| 678 | script_console_add_line( lua_tostring( Lt, -1 ) ); |
|---|
| 679 | } |
|---|
| 680 | } |
|---|
| 681 | script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED)); |
|---|
| 682 | script_end(); |
|---|
| 683 | } else { |
|---|
| 684 | state_kbd_script_run = 2; |
|---|
| 685 | if (jump_label("restore") == 0) { |
|---|
| 686 | script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED)); |
|---|
| 687 | script_end(); |
|---|
| 688 | } |
|---|
| 689 | } |
|---|
| 690 | } |
|---|
| 691 | |
|---|
| 692 | if (state_kbd_script_run) |
|---|
| 693 | process_script(); |
|---|
| 694 | else |
|---|
| 695 | gui_kbd_process(); |
|---|
| 696 | } else { |
|---|
| 697 | #ifndef SYNCHABLE_REMOTE_NOT_ENABLED |
|---|
| 698 | if(conf.ricoh_ca1_mode && conf.remote_enable) { |
|---|
| 699 | // ------ add by Masuji SUTO (start) -------------- |
|---|
| 700 | if(nWt>0) { |
|---|
| 701 | nWt--; |
|---|
| 702 | return 1; |
|---|
| 703 | } |
|---|
| 704 | #if defined(CAMERA_ixus960) |
|---|
| 705 | if(nFirst==1) { |
|---|
| 706 | if(nSW==0) { |
|---|
| 707 | nSW=1; |
|---|
| 708 | nWt=10; |
|---|
| 709 | kbd_key_release_all(); |
|---|
| 710 | kbd_key_press(KEY_SHOOT_HALF); |
|---|
| 711 | soft_half_press = 1; |
|---|
| 712 | set_key_press(1); |
|---|
| 713 | return 1; |
|---|
| 714 | } else if(nSW==1) { |
|---|
| 715 | nSW=2; |
|---|
| 716 | nWt=10; |
|---|
| 717 | kbd_key_release(KEY_SHOOT_HALF); |
|---|
| 718 | soft_half_press = 0; |
|---|
| 719 | set_key_press(1); |
|---|
| 720 | return 1; |
|---|
| 721 | } else if(nSW==2) { |
|---|
| 722 | set_key_press(0); |
|---|
| 723 | nWt=10; |
|---|
| 724 | nSW=0; |
|---|
| 725 | nFirst=0; |
|---|
| 726 | return 1; |
|---|
| 727 | } |
|---|
| 728 | } |
|---|
| 729 | #endif // CAMERA_ixus960 |
|---|
| 730 | if (kbd_is_key_pressed(KEY_SHOOT_FULL)) |
|---|
| 731 | conf.synch_enable=0; |
|---|
| 732 | if (kbd_is_key_pressed(KEY_SHOOT_HALF) && nTxzoom>0) { |
|---|
| 733 | nCount2=0; |
|---|
| 734 | nTxzoom=0; |
|---|
| 735 | nReczoom=0; |
|---|
| 736 | nTxvideo=0; |
|---|
| 737 | debug_led(0); |
|---|
| 738 | } |
|---|
| 739 | if (mplay && (kbd_is_key_pressed(KEY_LEFT) || kbd_is_key_pressed(KEY_RIGHT))) { |
|---|
| 740 | nPlyname=KEY_LEFT; |
|---|
| 741 | if(kbd_is_key_pressed(KEY_RIGHT)) |
|---|
| 742 | nPlyname=KEY_RIGHT; |
|---|
| 743 | } |
|---|
| 744 | if (kbd_is_key_pressed(KEY_VIDEO)) { |
|---|
| 745 | nCount2=0; |
|---|
| 746 | nTxzoom=0; |
|---|
| 747 | nReczoom=0; |
|---|
| 748 | nTxvideo++; |
|---|
| 749 | if(nTxvideo<50) { |
|---|
| 750 | kbd_key_release_all(); |
|---|
| 751 | debug_led(1); |
|---|
| 752 | } else { |
|---|
| 753 | debug_led(0); |
|---|
| 754 | return 0; |
|---|
| 755 | } |
|---|
| 756 | return 1; |
|---|
| 757 | } |
|---|
| 758 | else if(nTxvideo>49) |
|---|
| 759 | nTxvideo=0; |
|---|
| 760 | if (kbd_is_key_pressed(KEY_ZOOM_IN) || kbd_is_key_pressed(KEY_ZOOM_OUT)) { |
|---|
| 761 | nCount2=0; |
|---|
| 762 | nTxvideo=0; |
|---|
| 763 | if(kbd_is_key_pressed(KEY_ZOOM_IN)) { |
|---|
| 764 | if(nTxzname==KEY_ZOOM_IN) |
|---|
| 765 | nTxzoom++; |
|---|
| 766 | else |
|---|
| 767 | nTxzoom=1; |
|---|
| 768 | nTxzname=KEY_ZOOM_IN; |
|---|
| 769 | } else { |
|---|
| 770 | if(nTxzname==KEY_ZOOM_OUT) |
|---|
| 771 | nTxzoom++; |
|---|
| 772 | else |
|---|
| 773 | nTxzoom=1; |
|---|
| 774 | nTxzname=KEY_ZOOM_OUT; |
|---|
| 775 | } |
|---|
| 776 | if(nTxzoom<50) { |
|---|
| 777 | kbd_key_release_all(); |
|---|
| 778 | debug_led(1); |
|---|
| 779 | } else { |
|---|
| 780 | debug_led(0); |
|---|
| 781 | return 0; |
|---|
| 782 | } |
|---|
| 783 | return 1; |
|---|
| 784 | } |
|---|
| 785 | if(!get_usb_power(1) && nSW<100 && nCount==0 && nTxzoom>0) { |
|---|
| 786 | nCount2++; |
|---|
| 787 | if(nCount2>conf.zoom_timeout*100) { |
|---|
| 788 | if(nTxzoom>0) { |
|---|
| 789 | nTxzoom=0; |
|---|
| 790 | nReczoom=0; |
|---|
| 791 | debug_led(0); |
|---|
| 792 | } |
|---|
| 793 | nCount2=0; |
|---|
| 794 | } |
|---|
| 795 | return 1; |
|---|
| 796 | } |
|---|
| 797 | if(get_usb_power(1) && nSW<100 && nCount==0) { |
|---|
| 798 | nCount2=0; |
|---|
| 799 | kbd_key_release_all(); |
|---|
| 800 | conf.synch_enable=1; |
|---|
| 801 | } |
|---|
| 802 | if(get_usb_power(1) && nSW<100 && nCount==0) { |
|---|
| 803 | kbd_key_release_all(); |
|---|
| 804 | conf.synch_enable=1; |
|---|
| 805 | } |
|---|
| 806 | if(get_usb_power(1) && nSW<100 && nCount<6) { |
|---|
| 807 | nCount++; |
|---|
| 808 | return 1; |
|---|
| 809 | } |
|---|
| 810 | if(nCount>0 && nSW<100) { |
|---|
| 811 | if(mplay) { |
|---|
| 812 | if(get_usb_power(1)) |
|---|
| 813 | return 1; |
|---|
| 814 | kbd_key_release_all(); |
|---|
| 815 | kbd_key_press(nPlyname); |
|---|
| 816 | set_key_press(1); |
|---|
| 817 | nCount=0; |
|---|
| 818 | nCa=2; |
|---|
| 819 | nSW=101; |
|---|
| 820 | nWt=5; |
|---|
| 821 | return 1; |
|---|
| 822 | } |
|---|
| 823 | if(nTxvideo>49) |
|---|
| 824 | nTxvideo=0; |
|---|
| 825 | if(nCount<5) |
|---|
| 826 | nCa=1; //for Richo remote switch CA-1 |
|---|
| 827 | else |
|---|
| 828 | nCa=2; //for hand made remote switch |
|---|
| 829 | |
|---|
| 830 | nCount=0; |
|---|
| 831 | // debug_led(1); |
|---|
| 832 | nSW=109; |
|---|
| 833 | } |
|---|
| 834 | |
|---|
| 835 | // ------------------------------------------------------------- hand made switch -------------- |
|---|
| 836 | |
|---|
| 837 | if(nCa==2) { |
|---|
| 838 | if(nSW==101) { |
|---|
| 839 | kbd_key_release_all(); |
|---|
| 840 | set_key_press(0); |
|---|
| 841 | nWt=50; |
|---|
| 842 | nSW=0; |
|---|
| 843 | nCa=0; |
|---|
| 844 | return 1; |
|---|
| 845 | } |
|---|
| 846 | if(nSW==109) { |
|---|
| 847 | // nSW=110; |
|---|
| 848 | nCER=0; |
|---|
| 849 | if(nTxzoom>0 && conf.remote_zoom_enable) { |
|---|
| 850 | if(nTxzoom<100) { |
|---|
| 851 | nIntzpos=lens_get_zoom_point(); |
|---|
| 852 | for(i=0;i<ZSTEP_TABLE_SIZE;i++) { |
|---|
| 853 | if(nIntzpos<=nTxtbl[i]) { |
|---|
| 854 | if(i>0) { |
|---|
| 855 | if(abs(nTxtbl[i]-nIntzpos)<=abs(nTxtbl[i-1]-nIntzpos)) |
|---|
| 856 | nTxtblcr=i; |
|---|
| 857 | else |
|---|
| 858 | nTxtblcr=i-1; |
|---|
| 859 | } |
|---|
| 860 | else nTxtblcr=i; |
|---|
| 861 | i=ZSTEP_TABLE_SIZE; |
|---|
| 862 | } |
|---|
| 863 | } |
|---|
| 864 | if(nTxzname==KEY_ZOOM_IN) { |
|---|
| 865 | nTxtblcr++; |
|---|
| 866 | if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)) |
|---|
| 867 | nTxtblcr=(ZSTEP_TABLE_SIZE-1); |
|---|
| 868 | } else { |
|---|
| 869 | nTxtblcr--; |
|---|
| 870 | if(nTxtblcr<0) |
|---|
| 871 | nTxtblcr=0; |
|---|
| 872 | } |
|---|
| 873 | nSW=108; |
|---|
| 874 | return 1; |
|---|
| 875 | } |
|---|
| 876 | nTxzoom=0; |
|---|
| 877 | nReczoom=0; |
|---|
| 878 | } |
|---|
| 879 | if(nTxvideo>0 && conf.remote_zoom_enable) { |
|---|
| 880 | nSW=121; |
|---|
| 881 | return 1; |
|---|
| 882 | } |
|---|
| 883 | nSW=110; |
|---|
| 884 | nWt=2; |
|---|
| 885 | kbd_key_release_all(); |
|---|
| 886 | kbd_key_press(KEY_SHOOT_HALF); |
|---|
| 887 | // key_pressed = 1; |
|---|
| 888 | // kbd_blocked = 1; |
|---|
| 889 | // nRmt=1; |
|---|
| 890 | soft_half_press = 1; |
|---|
| 891 | set_key_press(1); |
|---|
| 892 | return 1; |
|---|
| 893 | } |
|---|
| 894 | if(nTxzoom>0 && nSW==108 && conf.remote_zoom_enable) { |
|---|
| 895 | nCrzpos=lens_get_zoom_point(); |
|---|
| 896 | if(nIntzpos!=nCrzpos) { |
|---|
| 897 | nReczoom=0; |
|---|
| 898 | } |
|---|
| 899 | if(nIntzpos==nCrzpos && nCER>50) { |
|---|
| 900 | if(!get_usb_power(1)) { |
|---|
| 901 | kbd_key_release_all(); |
|---|
| 902 | set_key_press(0); |
|---|
| 903 | nTxzoom=1; |
|---|
| 904 | nSW=0; |
|---|
| 905 | nCount=0; |
|---|
| 906 | nWt=10; |
|---|
| 907 | nReczoom=1; |
|---|
| 908 | return 1; |
|---|
| 909 | } |
|---|
| 910 | } |
|---|
| 911 | if(nReczoom==0 && ((nTxzname==KEY_ZOOM_IN && nCrzpos>=nTxtbl[nTxtblcr]) |
|---|
| 912 | || (nTxzname==KEY_ZOOM_OUT && nCrzpos<=nTxtbl[nTxtblcr]))) { |
|---|
| 913 | if(get_usb_power(1)) { |
|---|
| 914 | i=1; |
|---|
| 915 | if(nTxzname==KEY_ZOOM_IN) { |
|---|
| 916 | nTxtblcr++; |
|---|
| 917 | if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)) { |
|---|
| 918 | nTxtblcr=(ZSTEP_TABLE_SIZE-1); |
|---|
| 919 | nTxzname=KEY_ZOOM_OUT; |
|---|
| 920 | } |
|---|
| 921 | } else { |
|---|
| 922 | nTxtblcr--; |
|---|
| 923 | if(nTxtblcr<0){ |
|---|
| 924 | nTxtblcr=0; |
|---|
| 925 | nTxzname=KEY_ZOOM_IN; |
|---|
| 926 | } |
|---|
| 927 | } |
|---|
| 928 | if(i==1) |
|---|
| 929 | return 1; |
|---|
| 930 | } |
|---|
| 931 | kbd_key_release_all(); |
|---|
| 932 | set_key_press(0); |
|---|
| 933 | nTxzoom=1; |
|---|
| 934 | // lens_set_zoom_speed(25); |
|---|
| 935 | nSW=120; |
|---|
| 936 | nWt=5; |
|---|
| 937 | return 1; |
|---|
| 938 | } |
|---|
| 939 | kbd_key_release_all(); |
|---|
| 940 | kbd_key_press(nTxzname); |
|---|
| 941 | set_key_press(1); |
|---|
| 942 | nCER++; |
|---|
| 943 | return 1; |
|---|
| 944 | } |
|---|
| 945 | |
|---|
| 946 | if(nTxvideo>0 && nSW==121) { |
|---|
| 947 | if(!get_usb_power(1)) { |
|---|
| 948 | nWt=10; |
|---|
| 949 | kbd_key_press(KEY_VIDEO); |
|---|
| 950 | set_key_press(1); |
|---|
| 951 | nSW=122; |
|---|
| 952 | } |
|---|
| 953 | return 1; |
|---|
| 954 | } |
|---|
| 955 | if(nTxvideo>0 && nSW==122) { |
|---|
| 956 | nWt=10; |
|---|
| 957 | kbd_key_release(KEY_VIDEO); |
|---|
| 958 | set_key_press(1); |
|---|
| 959 | nSW=123; |
|---|
| 960 | return 1; |
|---|
| 961 | } |
|---|
| 962 | if(nTxvideo>0 && nSW==123) { |
|---|
| 963 | set_key_press(0); |
|---|
| 964 | nWt=50; |
|---|
| 965 | nSW=0; |
|---|
| 966 | nCa=0; |
|---|
| 967 | nTxvideo=0; |
|---|
| 968 | debug_led(0); |
|---|
| 969 | return 1; |
|---|
| 970 | } |
|---|
| 971 | |
|---|
| 972 | if(nSW==110) { |
|---|
| 973 | if (shooting_in_progress() || mvideo || nCER>100) { |
|---|
| 974 | state_expos_recalculated = 0; |
|---|
| 975 | histogram_restart(); |
|---|
| 976 | nCER=0; |
|---|
| 977 | nSW=111; |
|---|
| 978 | } else { |
|---|
| 979 | nCER++;return 1; |
|---|
| 980 | } |
|---|
| 981 | } |
|---|
| 982 | if(nSW==111) { |
|---|
| 983 | if (state_expos_recalculated || nCER>100) { |
|---|
| 984 | state_expos_under = under_exposed; |
|---|
| 985 | state_expos_over = over_exposed; |
|---|
| 986 | nCER=0; |
|---|
| 987 | nSW=112; |
|---|
| 988 | //presynch(); |
|---|
| 989 | } else { |
|---|
| 990 | nCER++; |
|---|
| 991 | return 1; |
|---|
| 992 | } |
|---|
| 993 | } |
|---|
| 994 | if(nSW==112) { |
|---|
| 995 | if (shooting_is_flash_ready() || nCER>10) { |
|---|
| 996 | nCER=0; |
|---|
| 997 | nSW=113; |
|---|
| 998 | } else { |
|---|
| 999 | nCER++; |
|---|
| 1000 | return 1; |
|---|
| 1001 | } |
|---|
| 1002 | } |
|---|
| 1003 | if(nSW==113) { |
|---|
| 1004 | if(get_usb_power(1) && !mvideo) |
|---|
| 1005 | nSW=114; |
|---|
| 1006 | else if(!get_usb_power(1) && mvideo) |
|---|
| 1007 | nSW=114; |
|---|
| 1008 | else |
|---|
| 1009 | return 1; |
|---|
| 1010 | } |
|---|
| 1011 | if(nTxzoom>0 && nSW==120 && conf.remote_zoom_enable) { |
|---|
| 1012 | nCrzpos=lens_get_zoom_point(); |
|---|
| 1013 | if((nTxzname==KEY_ZOOM_IN && nCrzpos<=nTxtbl[nTxtblcr]) |
|---|
| 1014 | || (nTxzname==KEY_ZOOM_OUT && nCrzpos>=nTxtbl[nTxtblcr])) { |
|---|
| 1015 | kbd_key_release_all(); |
|---|
| 1016 | set_key_press(0); |
|---|
| 1017 | nTxzoom=1; |
|---|
| 1018 | lens_set_zoom_speed(100); |
|---|
| 1019 | nSW=0; |
|---|
| 1020 | nCount=0; |
|---|
| 1021 | nWt=10; |
|---|
| 1022 | return 1; |
|---|
| 1023 | } |
|---|
| 1024 | lens_set_zoom_speed(5); |
|---|
| 1025 | kbd_key_release_all(); |
|---|
| 1026 | if(nTxzname==KEY_ZOOM_IN) |
|---|
| 1027 | kbd_key_press(KEY_ZOOM_OUT); |
|---|
| 1028 | else |
|---|
| 1029 | kbd_key_press(KEY_ZOOM_IN); |
|---|
| 1030 | set_key_press(1); |
|---|
| 1031 | return 1; |
|---|
| 1032 | } |
|---|
| 1033 | |
|---|
| 1034 | if(nSW==114) { |
|---|
| 1035 | nSW=115; |
|---|
| 1036 | nWt=2; |
|---|
| 1037 | shutter_int=0; |
|---|
| 1038 | kbd_key_press(KEY_SHOOT_FULL); |
|---|
| 1039 | set_key_press(1); |
|---|
| 1040 | // kbd_blocked = 1; |
|---|
| 1041 | // nRmt=1; |
|---|
| 1042 | nCount=0; |
|---|
| 1043 | return 1; |
|---|
| 1044 | } |
|---|
| 1045 | if(nSW==115) { |
|---|
| 1046 | // debug_led(0); |
|---|
| 1047 | if(drmode==1 && shutter_int==0) { |
|---|
| 1048 | return 1; |
|---|
| 1049 | } |
|---|
| 1050 | nSW=116; |
|---|
| 1051 | nWt=2; |
|---|
| 1052 | kbd_key_release(KEY_SHOOT_FULL); |
|---|
| 1053 | set_key_press(1); |
|---|
| 1054 | soft_half_press = 0; |
|---|
| 1055 | // kbd_blocked = 1; |
|---|
| 1056 | // nRmt=1; |
|---|
| 1057 | return 1; |
|---|
| 1058 | } |
|---|
| 1059 | if(!get_usb_power(1) && nSW==116) { |
|---|
| 1060 | set_key_press(0); |
|---|
| 1061 | // kbd_blocked = 0; |
|---|
| 1062 | // key_pressed = 0; |
|---|
| 1063 | nWt=50; |
|---|
| 1064 | nSW=0; |
|---|
| 1065 | // nRmt=0; |
|---|
| 1066 | nCa=0; |
|---|
| 1067 | //postsynch(); |
|---|
| 1068 | return 1; |
|---|
| 1069 | } |
|---|
| 1070 | } |
|---|
| 1071 | |
|---|
| 1072 | // ------------------------------------------------------------- Ricoh remote switch CA-1 -------------- |
|---|
| 1073 | if(nCa==1) { |
|---|
| 1074 | if(get_usb_power(1) && nSW>108 && nSW<120) { |
|---|
| 1075 | nCount++; |
|---|
| 1076 | } |
|---|
| 1077 | if(nSW==109) { |
|---|
| 1078 | // nSW=110; |
|---|
| 1079 | nCER=0; |
|---|
| 1080 | if(nTxzoom>0 && conf.remote_zoom_enable) { |
|---|
| 1081 | if(nTxzoom<100) { |
|---|
| 1082 | nIntzpos=lens_get_zoom_point(); |
|---|
| 1083 | for(i=0;i<ZSTEP_TABLE_SIZE;i++) { |
|---|
| 1084 | if(nIntzpos<=nTxtbl[i]) { |
|---|
| 1085 | if(i>0) { |
|---|
| 1086 | if(abs(nTxtbl[i]-nIntzpos)<=abs(nTxtbl[i-1]-nIntzpos)) |
|---|
| 1087 | nTxtblcr=i; |
|---|
| 1088 | else |
|---|
| 1089 | nTxtblcr=i-1; |
|---|
| 1090 | } |
|---|
| 1091 | else |
|---|
| 1092 | nTxtblcr=i; |
|---|
| 1093 | i=ZSTEP_TABLE_SIZE; |
|---|
| 1094 | } |
|---|
| 1095 | } |
|---|
| 1096 | if(nTxzname==KEY_ZOOM_IN) { |
|---|
| 1097 | nTxtblcr++; |
|---|
| 1098 | if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)) |
|---|
| 1099 | nTxtblcr=(ZSTEP_TABLE_SIZE-1); |
|---|
| 1100 | } |
|---|
| 1101 | else { |
|---|
| 1102 | nTxtblcr--; |
|---|
| 1103 | if(nTxtblcr<0) |
|---|
| 1104 | nTxtblcr=0; |
|---|
| 1105 | } |
|---|
| 1106 | nSW=113; |
|---|
| 1107 | return 1; |
|---|
| 1108 | } |
|---|
| 1109 | nTxzoom=0; |
|---|
| 1110 | nReczoom=0; |
|---|
| 1111 | } |
|---|
| 1112 | if(nTxvideo>0 && conf.remote_zoom_enable) { |
|---|
| 1113 | nSW=121; |
|---|
| 1114 | return 1; |
|---|
| 1115 | } |
|---|
| 1116 | nSW=110; |
|---|
| 1117 | nWt=2; |
|---|
| 1118 | kbd_key_release_all(); |
|---|
| 1119 | kbd_key_press(KEY_SHOOT_HALF); |
|---|
| 1120 | // debug_led(1); |
|---|
| 1121 | soft_half_press = 1; |
|---|
| 1122 | set_key_press(1); |
|---|
| 1123 | // key_pressed = 1; |
|---|
| 1124 | // kbd_blocked = 1; |
|---|
| 1125 | // nRmt=1; |
|---|
| 1126 | return 1; |
|---|
| 1127 | } |
|---|
| 1128 | if(nTxvideo>0 && nSW==121) { |
|---|
| 1129 | if(get_usb_power(1)) { |
|---|
| 1130 | nWt=10; |
|---|
| 1131 | kbd_key_press(KEY_VIDEO); |
|---|
| 1132 | set_key_press(1); |
|---|
| 1133 | nSW=122; |
|---|
| 1134 | } |
|---|
| 1135 | return 1; |
|---|
| 1136 | } |
|---|
| 1137 | if(nTxvideo>0 && nSW==122) { |
|---|
| 1138 | nWt=10; |
|---|
| 1139 | kbd_key_release(KEY_VIDEO); |
|---|
| 1140 | set_key_press(1); |
|---|
| 1141 | nSW=123; |
|---|
| 1142 | return 1; |
|---|
| 1143 | } |
|---|
| 1144 | if(nTxvideo>0 && nSW==123) { |
|---|
| 1145 | set_key_press(0); |
|---|
| 1146 | nWt=100; |
|---|
| 1147 | nCount=0; |
|---|
| 1148 | nSW=0; |
|---|
| 1149 | nCa=0; |
|---|
| 1150 | nTxvideo=0; |
|---|
| 1151 | debug_led(0); |
|---|
| 1152 | return 1; |
|---|
| 1153 | } |
|---|
| 1154 | |
|---|
| 1155 | if(nSW==110) { |
|---|
| 1156 | if (shooting_in_progress() || mvideo || nCER>100) { |
|---|
| 1157 | // debug_led(0); |
|---|
| 1158 | state_expos_recalculated = 0; |
|---|
| 1159 | histogram_restart(); |
|---|
| 1160 | nCER=0; |
|---|
| 1161 | nSW=111; |
|---|
| 1162 | } else { |
|---|
| 1163 | nCER++; |
|---|
| 1164 | return 1; |
|---|
| 1165 | } |
|---|
| 1166 | } |
|---|
| 1167 | if(nSW==111) { |
|---|
| 1168 | if (state_expos_recalculated || nCER>100) { |
|---|
| 1169 | state_expos_under = under_exposed; |
|---|
| 1170 | state_expos_over = over_exposed; |
|---|
| 1171 | nCER=0; |
|---|
| 1172 | nSW=112; |
|---|
| 1173 | //presynch(); |
|---|
| 1174 | } else { |
|---|
| 1175 | nCER++; |
|---|
| 1176 | return 1; |
|---|
| 1177 | } |
|---|
| 1178 | } |
|---|
| 1179 | if(nSW==112) { |
|---|
| 1180 | if (shooting_is_flash_ready() || nCER>10) { |
|---|
| 1181 | nCER=0; |
|---|
| 1182 | nSW=113; |
|---|
| 1183 | } else { |
|---|
| 1184 | nCER++; |
|---|
| 1185 | return 1; |
|---|
| 1186 | } |
|---|
| 1187 | } |
|---|
| 1188 | if(nTxzoom>0 && nSW==114 && conf.remote_zoom_enable) { |
|---|
| 1189 | nCrzpos=lens_get_zoom_point(); |
|---|
| 1190 | if(nIntzpos!=nCrzpos) { |
|---|
| 1191 | nReczoom=0; |
|---|
| 1192 | } |
|---|
| 1193 | if(nIntzpos==nCrzpos && nCER>50) { |
|---|
| 1194 | if(nCount>0) { |
|---|
| 1195 | kbd_key_release_all(); |
|---|
| 1196 | set_key_press(0); |
|---|
| 1197 | nTxzoom=1; |
|---|
| 1198 | nSW=0; |
|---|
| 1199 | nCount=0; |
|---|
| 1200 | nWt=10; |
|---|
| 1201 | nReczoom=1; |
|---|
| 1202 | return 1; |
|---|
| 1203 | } |
|---|
| 1204 | } |
|---|
| 1205 | if(nReczoom==0 && ((nTxzname==KEY_ZOOM_IN && nCrzpos>=nTxtbl[nTxtblcr]) |
|---|
| 1206 | || (nTxzname==KEY_ZOOM_OUT && nCrzpos<=nTxtbl[nTxtblcr]))) { |
|---|
| 1207 | if(nCount==0) { |
|---|
| 1208 | i=1; |
|---|
| 1209 | if(nTxzname==KEY_ZOOM_IN){ |
|---|
| 1210 | nTxtblcr++; |
|---|
| 1211 | if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)){ |
|---|
| 1212 | nTxtblcr=(ZSTEP_TABLE_SIZE-1); |
|---|
| 1213 | nTxzname=KEY_ZOOM_OUT; |
|---|
| 1214 | } |
|---|
| 1215 | } else { |
|---|
| 1216 | nTxtblcr--; |
|---|
| 1217 | if(nTxtblcr<0) { |
|---|
| 1218 | nTxtblcr=0; |
|---|
| 1219 | nTxzname=KEY_ZOOM_IN; |
|---|
| 1220 | } |
|---|
| 1221 | } |
|---|
| 1222 | if(i==1) |
|---|
| 1223 | return 1; |
|---|
| 1224 | } |
|---|
| 1225 | kbd_key_release_all(); |
|---|
| 1226 | set_key_press(0); |
|---|
| 1227 | nTxzoom=1; |
|---|
| 1228 | // lens_set_zoom_speed(25); |
|---|
| 1229 | nSW=115; |
|---|
| 1230 | nWt=5; |
|---|
| 1231 | return 1; |
|---|
| 1232 | } |
|---|
| 1233 | kbd_key_release_all(); |
|---|
| 1234 | kbd_key_press(nTxzname); |
|---|
| 1235 | set_key_press(1); |
|---|
| 1236 | nCER++; |
|---|
| 1237 | return 1; |
|---|
| 1238 | } |
|---|
| 1239 | if(nTxzoom>0 && nSW==115 && conf.remote_zoom_enable) { |
|---|
| 1240 | if(nCount==0) |
|---|
| 1241 | return 1; |
|---|
| 1242 | nCrzpos=lens_get_zoom_point(); |
|---|
| 1243 | if((nTxzname==KEY_ZOOM_IN && nCrzpos<=nTxtbl[nTxtblcr]) |
|---|
| 1244 | || (nTxzname==KEY_ZOOM_OUT && nCrzpos>=nTxtbl[nTxtblcr])) { |
|---|
| 1245 | kbd_key_release_all(); |
|---|
| 1246 | set_key_press(0); |
|---|
| 1247 | nTxzoom=1; |
|---|
| 1248 | lens_set_zoom_speed(100); |
|---|
| 1249 | nSW=0; |
|---|
| 1250 | nCount=0; |
|---|
| 1251 | nWt=10; |
|---|
| 1252 | return 1; |
|---|
| 1253 | } |
|---|
| 1254 | lens_set_zoom_speed(5); |
|---|
| 1255 | kbd_key_release_all(); |
|---|
| 1256 | if(nTxzname==KEY_ZOOM_IN) |
|---|
| 1257 | kbd_key_press(KEY_ZOOM_OUT); |
|---|
| 1258 | else |
|---|
| 1259 | kbd_key_press(KEY_ZOOM_IN); |
|---|
| 1260 | set_key_press(1); |
|---|
| 1261 | return 1; |
|---|
| 1262 | } |
|---|
| 1263 | |
|---|
| 1264 | if(get_usb_power(1)) { |
|---|
| 1265 | return 1; |
|---|
| 1266 | } |
|---|
| 1267 | if(nCount>0 && nSW==113) { |
|---|
| 1268 | if(nCount<9) { |
|---|
| 1269 | if(nTxzoom>0 && conf.remote_zoom_enable) { |
|---|
| 1270 | kbd_key_release_all(); |
|---|
| 1271 | set_key_press(0); |
|---|
| 1272 | nTxzoom=0; |
|---|
| 1273 | nReczoom=0; |
|---|
| 1274 | nSW=0; |
|---|
| 1275 | nCa=0; |
|---|
| 1276 | nCount=0; |
|---|
| 1277 | nWt=10; |
|---|
| 1278 | // lens_set_zoom_speed(100); |
|---|
| 1279 | debug_led(0); |
|---|
| 1280 | return 1; |
|---|
| 1281 | } |
|---|
| 1282 | nSW=125; |
|---|
| 1283 | nWt=10; |
|---|
| 1284 | kbd_key_release(KEY_SHOOT_HALF); |
|---|
| 1285 | soft_half_press = 0; |
|---|
| 1286 | set_key_press(1); |
|---|
| 1287 | // kbd_blocked = 1; |
|---|
| 1288 | // nRmt=1; |
|---|
| 1289 | nCount=0; |
|---|
| 1290 | return 1; |
|---|
| 1291 | } else { |
|---|
| 1292 | if(nTxzoom>0 && conf.remote_zoom_enable) { |
|---|
| 1293 | nCount=0; |
|---|
| 1294 | nSW=114; |
|---|
| 1295 | return 1; |
|---|
| 1296 | } |
|---|
| 1297 | nSW=124; |
|---|
| 1298 | nWt=2; |
|---|
| 1299 | shutter_int=0; |
|---|
| 1300 | // debug_led(0); |
|---|
| 1301 | kbd_key_press(KEY_SHOOT_FULL); |
|---|
| 1302 | set_key_press(1); |
|---|
| 1303 | // kbd_blocked = 1; |
|---|
| 1304 | // nRmt=1; |
|---|
| 1305 | nCount=0; |
|---|
| 1306 | return 1; |
|---|
| 1307 | } |
|---|
| 1308 | } |
|---|
| 1309 | if(nSW==124) { |
|---|
| 1310 | // debug_led(0); |
|---|
| 1311 | if(drmode==1 && shutter_int==0) { |
|---|
| 1312 | return 1; |
|---|
| 1313 | } |
|---|
| 1314 | nSW=125; |
|---|
| 1315 | nWt=2; |
|---|
| 1316 | kbd_key_release(KEY_SHOOT_FULL); |
|---|
| 1317 | soft_half_press = 0; |
|---|
| 1318 | set_key_press(1); |
|---|
| 1319 | // kbd_blocked = 1; |
|---|
| 1320 | // nRmt=1; |
|---|
| 1321 | return 1; |
|---|
| 1322 | } |
|---|
| 1323 | if(!get_usb_power(1) && nSW==125) { |
|---|
| 1324 | set_key_press(0); |
|---|
| 1325 | // kbd_blocked = 0; |
|---|
| 1326 | // key_pressed = 0; |
|---|
| 1327 | nWt=50; |
|---|
| 1328 | nSW=0; |
|---|
| 1329 | // nRmt=0; |
|---|
| 1330 | nCa=0; |
|---|
| 1331 | //postsynch(); |
|---|
| 1332 | return 1; |
|---|
| 1333 | } |
|---|
| 1334 | } |
|---|
| 1335 | // ------ add by Masuji SUTO (end) -------------- |
|---|
| 1336 | } // ricoh_ca1_mode |
|---|
| 1337 | #endif // ifndef SYNCHABLE_REMOTE_NOT_ENABLED |
|---|
| 1338 | /*------------------- Alex scriptless remote additions start --------------------*/ |
|---|
| 1339 | if (conf.remote_enable && !conf.ricoh_ca1_mode && key_pressed != 2 && get_usb_power(1)) { |
|---|
| 1340 | remoteShooting = 1; |
|---|
| 1341 | kbd_blocked = 1; |
|---|
| 1342 | kbd_key_release_all(); |
|---|
| 1343 | remoteClickTimer = REMOTE_MAX_CLICK_LENGTH; |
|---|
| 1344 | if (shooting_get_focus_mode()) { |
|---|
| 1345 | remoteFullShutter = 1; |
|---|
| 1346 | kbd_key_press(KEY_SHOOT_FULL); |
|---|
| 1347 | } else { |
|---|
| 1348 | remoteHalfShutter = 1; |
|---|
| 1349 | kbd_key_press(KEY_SHOOT_HALF); |
|---|
| 1350 | } |
|---|
| 1351 | return 1; |
|---|
| 1352 | } |
|---|
| 1353 | /*-------------------- Alex scriptless remote additions end ---------------------*/ |
|---|
| 1354 | #ifdef CAM_USE_ZOOM_FOR_MF |
|---|
| 1355 | if (conf.use_zoom_mf && kbd_use_zoom_as_mf()) { |
|---|
| 1356 | return 1; |
|---|
| 1357 | } |
|---|
| 1358 | #endif // ifdef CAM_USE_ZOOM_FOR_MF |
|---|
| 1359 | if ((conf.fast_ev || conf.fast_movie_control || conf.fast_movie_quality_control) |
|---|
| 1360 | && kbd_use_up_down_left_right_as_fast_switch()) { |
|---|
| 1361 | return 1; |
|---|
| 1362 | } |
|---|
| 1363 | other_kbd_process(); // processed other keys in not <alt> mode |
|---|
| 1364 | } |
|---|
| 1365 | |
|---|
| 1366 | return kbd_blocked; |
|---|
| 1367 | } |
|---|
| 1368 | |
|---|
| 1369 | static const struct Keynames { |
|---|
| 1370 | int keyid; |
|---|
| 1371 | char *keyname; |
|---|
| 1372 | } keynames[] = { |
|---|
| 1373 | { KEY_UP, "up" }, |
|---|
| 1374 | { KEY_DOWN, "down" }, |
|---|
| 1375 | { KEY_LEFT, "left" }, |
|---|
| 1376 | { KEY_RIGHT, "right" }, |
|---|
| 1377 | { KEY_SET, "set" }, |
|---|
| 1378 | { KEY_SHOOT_HALF, "shoot_half" }, |
|---|
| 1379 | { KEY_SHOOT_FULL, "shoot_full" }, |
|---|
| 1380 | { KEY_ZOOM_IN, "zoom_in" }, |
|---|
| 1381 | { KEY_ZOOM_OUT, "zoom_out" }, |
|---|
| 1382 | { KEY_MENU, "menu" }, |
|---|
| 1383 | { KEY_DISPLAY, "display" }, |
|---|
| 1384 | { KEY_PRINT, "print" }, |
|---|
| 1385 | { KEY_ERASE, "erase" }, |
|---|
| 1386 | { KEY_ISO, "iso" }, |
|---|
| 1387 | { KEY_FLASH, "flash" }, |
|---|
| 1388 | { KEY_MF, "mf" }, |
|---|
| 1389 | { KEY_MACRO, "macro" }, |
|---|
| 1390 | { KEY_VIDEO, "video" }, |
|---|
| 1391 | { KEY_TIMER, "timer" }, |
|---|
| 1392 | { KEY_EXPO_CORR, "expo_corr" }, |
|---|
| 1393 | { KEY_MICROPHONE, "fe" }, |
|---|
| 1394 | { 0xFF, "remote" }, |
|---|
| 1395 | { 0xFFFF, "no_key" }, |
|---|
| 1396 | }; |
|---|
| 1397 | |
|---|
| 1398 | int keyid_by_name (const char *n) |
|---|
| 1399 | { |
|---|
| 1400 | int i; |
|---|
| 1401 | for (i=0;i<sizeof(keynames)/sizeof(keynames[0]);i++) |
|---|
| 1402 | if (strcmp(keynames[i].keyname,n) == 0) |
|---|
| 1403 | return keynames[i].keyid; |
|---|
| 1404 | return 0; |
|---|
| 1405 | } |
|---|
| 1406 | |
|---|
| 1407 | int kbd_is_blocked() { |
|---|
| 1408 | return kbd_blocked; |
|---|
| 1409 | } |
|---|
| 1410 | |
|---|
| 1411 | long kbd_use_up_down_left_right_as_fast_switch() { |
|---|
| 1412 | static long key_pressed = 0; // ??? static masking a global |
|---|
| 1413 | int m=mode_get(); |
|---|
| 1414 | int mode_video = MODE_IS_VIDEO(m) || (movie_status > 1); |
|---|
| 1415 | int ev_video=0; |
|---|
| 1416 | int jogdial; |
|---|
| 1417 | |
|---|
| 1418 | #if CAM_EV_IN_VIDEO |
|---|
| 1419 | ev_video=get_ev_video_avail(); |
|---|
| 1420 | #endif |
|---|
| 1421 | |
|---|
| 1422 | if (!(kbd_is_key_pressed(KEY_UP)) && !(kbd_is_key_pressed(KEY_DOWN))) key_pressed = 0; |
|---|
| 1423 | |
|---|
| 1424 | if (canon_shoot_menu_active!=0 || (m&MODE_MASK) != MODE_REC) |
|---|
| 1425 | return 0; |
|---|
| 1426 | |
|---|
| 1427 | #if !CAM_HAS_JOGDIAL |
|---|
| 1428 | if (kbd_is_key_pressed(KEY_UP) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) { |
|---|
| 1429 | if (conf.fast_ev && key_pressed == 0) { |
|---|
| 1430 | shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)+(conf.fast_ev_step+1)*16); |
|---|
| 1431 | shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)+(conf.fast_ev_step+1)*16); |
|---|
| 1432 | EnterToCompensationEVF(); |
|---|
| 1433 | key_pressed = KEY_UP; |
|---|
| 1434 | |
|---|
| 1435 | return 1; |
|---|
| 1436 | } |
|---|
| 1437 | |
|---|
| 1438 | } |
|---|
| 1439 | |
|---|
| 1440 | if (kbd_is_key_pressed(KEY_DOWN) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) { |
|---|
| 1441 | if (conf.fast_ev && key_pressed == 0) { |
|---|
| 1442 | kbd_key_release_all(); |
|---|
| 1443 | shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)-(conf.fast_ev_step+1)*16); |
|---|
| 1444 | shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)-(conf.fast_ev_step+1)*16); |
|---|
| 1445 | key_pressed = KEY_DOWN; |
|---|
| 1446 | EnterToCompensationEVF(); |
|---|
| 1447 | return 1; |
|---|
| 1448 | } |
|---|
| 1449 | } |
|---|
| 1450 | |
|---|
| 1451 | #else |
|---|
| 1452 | jogdial=get_jogdial_direction(); |
|---|
| 1453 | |
|---|
| 1454 | if (conf.fast_ev &&kbd_is_key_pressed(KEY_SHOOT_HALF) && (jogdial==JOGDIAL_RIGHT) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) { |
|---|
| 1455 | shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)+(conf.fast_ev_step+1)*16); |
|---|
| 1456 | shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)+(conf.fast_ev_step+1)*16); |
|---|
| 1457 | EnterToCompensationEVF(); |
|---|
| 1458 | } |
|---|
| 1459 | |
|---|
| 1460 | if (conf.fast_ev &&kbd_is_key_pressed(KEY_SHOOT_HALF) && (jogdial==JOGDIAL_LEFT) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) { |
|---|
| 1461 | shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)-(conf.fast_ev_step+1)*16); |
|---|
| 1462 | shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)-(conf.fast_ev_step+1)*16); |
|---|
| 1463 | EnterToCompensationEVF(); |
|---|
| 1464 | } |
|---|
| 1465 | |
|---|
| 1466 | |
|---|
| 1467 | #endif |
|---|
| 1468 | |
|---|
| 1469 | if (kbd_is_key_pressed(KEY_UP) && mode_video && movie_status == 4 ) { |
|---|
| 1470 | if (conf.fast_movie_quality_control && key_pressed == 0) { |
|---|
| 1471 | if (conf.video_mode==0) { |
|---|
| 1472 | #if !CAM_VIDEO_QUALITY_ONLY |
|---|
| 1473 | conf.video_bitrate+=1; |
|---|
| 1474 | if (conf.video_bitrate>=VIDEO_BITRATE_STEPS) |
|---|
| 1475 | conf.video_bitrate=VIDEO_BITRATE_STEPS-1; |
|---|
| 1476 | shooting_video_bitrate_change(conf.video_bitrate); |
|---|
| 1477 | movie_reset = 1; |
|---|
| 1478 | #endif |
|---|
| 1479 | } |
|---|
| 1480 | else if (conf.video_mode==1) { |
|---|
| 1481 | conf.video_quality+=1; |
|---|
| 1482 | if (conf.video_quality>VIDEO_MAX_QUALITY) |
|---|
| 1483 | conf.video_quality=VIDEO_MAX_QUALITY; |
|---|
| 1484 | movie_reset = 1; |
|---|
| 1485 | } |
|---|
| 1486 | key_pressed = KEY_UP; |
|---|
| 1487 | return 1; |
|---|
| 1488 | } |
|---|
| 1489 | } |
|---|
| 1490 | |
|---|
| 1491 | if (kbd_is_key_pressed(KEY_DOWN) && mode_video && movie_status == 4) { |
|---|
| 1492 | if (conf.fast_movie_quality_control && key_pressed == 0) { |
|---|
| 1493 | if (conf.video_mode==0) { |
|---|
| 1494 | #if !CAM_VIDEO_QUALITY_ONLY |
|---|
| 1495 | conf.video_bitrate-=1; |
|---|
| 1496 | if (conf.video_bitrate<0) |
|---|
| 1497 | conf.video_bitrate=0; |
|---|
| 1498 | |
|---|
| 1499 | shooting_video_bitrate_change(conf.video_bitrate); |
|---|
| 1500 | movie_reset = 1; |
|---|
| 1501 | #endif |
|---|
| 1502 | } |
|---|
| 1503 | else if (conf.video_mode==1) { |
|---|
| 1504 | conf.video_quality-=1; |
|---|
| 1505 | if (conf.video_quality<1) |
|---|
| 1506 | conf.video_quality=1; |
|---|
| 1507 | movie_reset = 1; |
|---|
| 1508 | } |
|---|
| 1509 | key_pressed = KEY_DOWN; |
|---|
| 1510 | return 1; |
|---|
| 1511 | } |
|---|
| 1512 | } |
|---|
| 1513 | |
|---|
| 1514 | if (kbd_is_key_pressed(KEY_LEFT) && mode_video && (movie_status == 4) && !ev_video) { |
|---|
| 1515 | if (conf.fast_movie_control && key_pressed == 0) { |
|---|
| 1516 | movie_status = VIDEO_RECORD_STOPPED; |
|---|
| 1517 | key_pressed = KEY_LEFT; |
|---|
| 1518 | return 1; |
|---|
| 1519 | } |
|---|
| 1520 | } |
|---|
| 1521 | // reyalp - HACK for cams that can do video in any mode |
|---|
| 1522 | // note that this means this will probably run whenever you press right |
|---|
| 1523 | if (kbd_is_key_pressed(KEY_RIGHT) && |
|---|
| 1524 | #ifndef CAM_HAS_VIDEO_BUTTON |
|---|
| 1525 | mode_video && |
|---|
| 1526 | #endif |
|---|
| 1527 | (movie_status == 1) && !ev_video) { |
|---|
| 1528 | // BUG this doesn't know whether recording was stopped or paused. |
|---|
| 1529 | if (conf.fast_movie_control && key_pressed == 0) { |
|---|
| 1530 | movie_status = VIDEO_RECORD_IN_PROGRESS; |
|---|
| 1531 | movie_reset = 1; |
|---|
| 1532 | key_pressed = KEY_RIGHT; |
|---|
| 1533 | return 1; |
|---|
| 1534 | } |
|---|
| 1535 | } |
|---|
| 1536 | |
|---|
| 1537 | return 0; |
|---|
| 1538 | } |
|---|