#include "lolevel.h" #include "platform.h" #include "conf.h" #include "core.h" #include "keyboard.h" volatile long *mmio0 = (void*)0xc0220200; // Definition of input addresses volatile long *mmio1 = (void*)0xc0220204; volatile long *mmio2 = (void*)0xc0220208; volatile long *mmio3 = (void*)0xc022020C; typedef struct { long hackkey; long canonkey; } KeyMap; static long kbd_new_state[3]; static long kbd_prev_state[3]; static long kbd_mod_state; static KeyMap keymap[]; static long last_kbd_key = 0; static int usb_power=0; static int remote_key, remote_count; static int shoot_counter=0; #define DELAY_TIMEOUT 10000 #define NEW_SS (0x2000) #define SD_READONLY_FLAG (0x20000) #if defined(CAMERA_a710) || defined(CAMERA_a700) #define USB_MASK 8 #define USB_REG 0 #endif #if defined(CAMERA_a630) || defined(CAMERA_a640) || defined(CAMERA_a610) || defined(CAMERA_a620) || defined(CAMERA_ixus800_sd700) || defined(CAMERA_ixus65_sd630) || defined(CAMERA_ixus850_sd800) || defined(CAMERA_ixus900_sd900) || defined (CAMERA_ixus70_sd1000) || defined (CAMERA_ixus950_sd850) || defined(CAMERA_a410) #define USB_MASK 0x8000000 #define USB_REG 1 #endif #if defined(CAMERA_a430) || defined(CAMERA_a530) || defined(CAMERA_a540) #define USB_MASK 0x4000 #define USB_REG 2 #endif #if defined(CAMERA_g11) #define USB_MASK 0x100000 #define USB_REG 2 #endif #if defined(CAMERA_s90) || defined(CAMERA_s95) #define USB_MASK (0x200000) #define USB_REG 2 #endif long get_mmio(void) { long x; #if defined(CAMERA_a530) || defined(CAMERA_a540) x = (long)*mmio2; #endif #if defined(CAMERA_a610) || defined(CAMERA_a620) || defined(CAMERA_a630) || defined(CAMERA_a640) || defined(CAMERA_ixus800_sd700) || defined(CAMERA_a410) x = (long)*mmio1; #endif #if defined(CAMERA_a710) || defined(CAMERA_a700) x = (long)*mmio0; #endif return x; } #if defined(CAMERA_a530) || defined(CAMERA_a540) || defined(CAMERA_a610) || defined(CAMERA_a620) || defined(CAMERA_a630) || defined(CAMERA_a640) || defined(CAMERA_a700)|| defined(CAMERA_a710) || defined (CAMERA_ixus800_sd700) || defined(CAMERA_a410) void wait_until_remote_button_is_released(void) { long x; int count1; int count2; int tick,tick2,tick3; int nSW; int prev_usb_power,cur_usb_power; // ------ add by Masuji SUTO (start) -------------- static int nMode; // ------ add by Masuji SUTO (end) -------------- asm volatile ("STMFD SP!, {R0-R11,LR}\n"); // store R0-R11 and LR in stack // debug_led(1); tick=get_tick_count(); tick2 = tick; if (conf.synch_enable && conf.ricoh_ca1_mode && conf.remote_enable && (!shooting_get_drive_mode()|| (shooting_get_drive_mode()==1) || ((shooting_get_drive_mode()==2) && state_shooting_progress != SHOOTING_PROGRESS_PROCESSING))) // if(conf.synch_enable && conf.ricoh_ca1_mode && conf.remote_enable) // synch mode enable so wait for USB to disconnect { if(conf.ricoh_ca1_mode && conf.remote_enable) { nMode=0; x=get_mmio(); if(x&USB_MASK) nMode=1; // ------ add by Masuji SUTO (end) -------------- } // ricoh_ca1_mode if(conf.ricoh_ca1_mode && conf.remote_enable) { if(shooting_get_drive_mode()==1 && state_shooting_progress == SHOOTING_PROGRESS_PROCESSING){ //continuous-shooting mode if(conf.bracket_type>2){ // alternating if(shoot_counter<2) shutter_int=3; shoot_counter--; } else{ // lighter/darker prev_usb_power=0; nSW = 0; do { x=get_mmio(); cur_usb_power = x&USB_MASK; if(cur_usb_power) { if(!prev_usb_power) { tick2 = get_tick_count(); prev_usb_power=cur_usb_power; } else { if((int)get_tick_count()-tick2>1000) { /* debug_led(0); */} } } else{ if(prev_usb_power) { tick3 = (int)get_tick_count()-tick2; if(nSW==10) { if(tick3>50) shutter_int=1; nSW=20; } if(nSW==0 && tick3>0) { if(tick3<50) { nSW=10; } else { if(tick3>1000) shutter_int=1; nSW=20; } } prev_usb_power=cur_usb_power; } } // else if((int)get_tick_count()-tick >= DELAY_TIMEOUT) {nSW=20;shutter_int=2;} } while(nSW<20); } // lighter/darker } //continuous-shooting mode else{ // normal mode shoot_counter=0; if(conf.bracket_type>2) { shoot_counter=(conf.bracket_type-2)*2; } do x=get_mmio(); // while((x&USB_MASK) && ((int)get_tick_count()-tick < DELAY_TIMEOUT)); // ------ modif by Masuji SUTO (start) -------------- while(((!(x&USB_MASK) && (nMode==0)) || ((x&USB_MASK) && (nMode==1))) && ((int)get_tick_count()-tick < DELAY_TIMEOUT)); // ------ modif by Masuji SUTO (end) -------------- } } // ricoh ca1 mode else { do x=get_mmio(); while((x&USB_MASK) && ((int)get_tick_count()-tick < DELAY_TIMEOUT)); } if (conf.synch_delay_enable && conf.synch_delay_value>0) // if delay is switched on and greater than 0 { for (count1=0;count1((press_count)?175:500)) { ++press_count; last_kbd_time = t; return last_kbd_key; } else { return 0; } } else { last_kbd_key = 0; return 0; } } } long kbd_use_zoom_as_mf() { static long zoom_key_pressed = 0; if (kbd_is_key_pressed(KEY_ZOOM_IN) && (mode_get()&MODE_MASK) == 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) && (mode_get()&MODE_MASK) == 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; }