#include "lolevel.h" #include "platform.h" #include "core.h" #include "conf.h" #include "keyboard.h" typedef struct { short grp; short hackkey; long canonkey; } KeyMap; static long kbd_new_state[3]; static long kbd_prev_state[3]; static long kbd_mod_state[3]; static long last_kbd_key = 0; static int usb_power=0; static int remote_key, remote_count; static int shoot_counter=0; extern void _platformsub_kbd_fetch_data(long*); #define DELAY_TIMEOUT 10000 #define KEYS_MASK0 (0x00020000) #define KEYS_MASK1 (0x00000000) #define KEYS_MASK2 (0x017001f4) #define SD_READONLY_FLAG (0x40000) #define USB_MASK (0x80000) #define USB_REG 2 static KeyMap keymap[] = { /* tiny bug: key order matters. see kbd_get_pressed_key() * for example */ //{ 0, KEY_DISPLAY , 0x00020000 }, // Playback { 0, KEY_PRINT , 0x00020000 }, // Playback { 2, KEY_SHOOT_FULL , 0x00000030 }, // ? 0x00000010(KEY_SHOOT_HALF) + 0x00000030 (KEY_SHOOT_FULL) { 2, KEY_SHOOT_HALF , 0x00000010 }, { 2, KEY_UP , 0x00100000 }, { 2, KEY_DOWN , 0x00200000 }, { 2, KEY_LEFT , 0x00400000 }, { 2, KEY_RIGHT , 0x00000004 }, { 2, KEY_SET , 0x00000100 }, { 2, KEY_ZOOM_IN , 0x00000080 }, { 2, KEY_ZOOM_OUT , 0x00000040 }, { 2, KEY_MENU , 0x01000000 }, { 0, 0, 0 } }; long __attribute__((naked)) wrap_kbd_p1_f() ; void wait_until_remote_button_is_released(void) { int count1; int count2; int tick,tick2,tick3; int nSW; int prev_usb_power,cur_usb_power; static int nMode; asm volatile ("STMFD SP!, {R0-R11,LR}\n"); // store R0-R11 and LR in stack //debug_led(1); tick = get_tick_count(); tick2 = tick; static long usb_physw[3]; 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 && (!shooting_get_drive_mode()|| ((shooting_get_drive_mode()==2) && state_shooting_progress != SHOOTING_PROGRESS_PROCESSING))) // synch mode enable so wait for USB to disconnect { // ------ add by Masuji SUTO (start) -------------- nMode = 0; usb_physw[2] = 0; // makes sure USB bit is cleared. _kbd_read_keys_r2(usb_physw); if((usb_physw[2] & USB_MASK)==USB_MASK) nMode=1; // ------ add by Masuji SUTO (end) -------------- 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) { if(shoot_counter<2) shutter_int=3; shoot_counter--; } else { prev_usb_power=0; nSW = 0; do { usb_physw[2] = 0; // makes sure USB bit is cleared. _kbd_read_keys_r2(usb_physw); cur_usb_power = (usb_physw[2] & USB_MASK)==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; } } if((int)get_tick_count()-tick >= DELAY_TIMEOUT) { nSW=20;shutter_int=2; } } while(nSW<20); } } // continuous-shooting mode else { //nomal mode shoot_counter=0; if(conf.bracket_type>2) { shoot_counter=(conf.bracket_type-2)*2; } do { usb_physw[2] = 0; // makes sure USB bit is cleared. _kbd_read_keys_r2(usb_physw); } //while(((usb_physw[2] & USB_MASK)==USB_MASK) && ((int)get_tick_count()-tick < DELAY_TIMEOUT)); while (((((usb_physw[2] & USB_MASK)!=USB_MASK) && (nMode==0)) || (((usb_physw[2] & USB_MASK)==USB_MASK) && (nMode==1))) && ((int)get_tick_count()-tick < DELAY_TIMEOUT)); } } else { do { usb_physw[2] = 0; // makes sure USB bit is cleared. _kbd_read_keys_r2(usb_physw); } while ((usb_physw[2]&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; } } } int get_usb_power(int edge) { int x; if (edge) return remote_key; x = usb_power; usb_power = 0; return x; } long kbd_use_zoom_as_mf() { return 0; }