Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ixus900_sd900 kbd.c cleaned and added some comments

  • Loading branch information...
commit 1192b63754fc83841ea0d41866085c01da349177 1 parent d7afba3
pixel::doc authored
Showing with 99 additions and 121 deletions.
  1. +99 −121 platform/ixus900_sd900/kbd.c
220 platform/ixus900_sd900/kbd.c
View
@@ -23,7 +23,6 @@ static int shoot_counter=0;
#define USB_MASK (0x40000)
#define USB_REG 2
-// ToDo: override key and feather bits to avoid feather osd messing up chdk display in ALT mode like SD4000
#define KEYS_MASK0 (0x00000000)
#define KEYS_MASK1 (0xc0000000) // (0xc0800000)
#define KEYS_MASK2 (0x0ffc)
@@ -37,108 +36,6 @@ static int shoot_counter=0;
long __attribute__((naked)) wrap_kbd_p1_f();
-// called by capt_seq.c at sub_FF995A50_my()
-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;
- // ------ 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;
- 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));
- // ------ modif by Masuji SUTO (start) --------------
- 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));
- // ------ modif by Masuji SUTO (end) --------------
- }
- } 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<conf.synch_delay_value+(conf.synch_delay_coarse_value*1000);count1++) { // wait delay_value * 0.1ms
- for (count2=0;count2<1400;count2++) { // delay approx. 0.1ms
- }
- }
- }
-
- //debug_led(0);
- asm volatile ("LDMFD SP!, {R0-R11,LR}\n"); // restore R0-R11 and LR from stack
-}
-
static void __attribute__((noinline)) mykbd_task_proceed() {
while (physw_run) {
_SleepTask(10);
@@ -196,6 +93,7 @@ long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
return 0; // shut up the compiler
}
+// ToDo: required?
#if CAM_FEATURE_FEATHER
extern int touch_keys_angle;
extern int * touch_keys_sema;
@@ -203,7 +101,6 @@ long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
#endif
void my_kbd_read_keys() {
- //debug_led(1);
//kbd_prev_state[0] = kbd_new_state[0]; // nothing to override
kbd_prev_state[1] = kbd_new_state[1];
kbd_prev_state[2] = kbd_new_state[2];
@@ -211,7 +108,6 @@ void my_kbd_read_keys() {
//kbd_new_state[0] = physw_status[0];
kbd_new_state[1] = physw_status[1];
kbd_new_state[2] = physw_status[2];
-<<<<<<< HEAD
#if CAM_FEATURE_FEATHER
static int taskFeatherID = 0;
@@ -221,8 +117,6 @@ void my_kbd_read_keys() {
//printf("taskFeatherID:%x\n", taskFeatherID);
}
#endif
-=======
->>>>>>> 7fba619... ixus900_sd900 keyboard stuff changed (using kbd_read_keys() from canon firmware)
if (kbd_process() == 0) {
// nothing to override
@@ -252,10 +146,10 @@ void my_kbd_read_keys() {
}
if (conf.remote_enable) {
- physw_status[2] = physw_status[2] & ~(SD_READONLY_FLAG | USB_MASK);
+ physw_status[2] = physw_status[2] & ~(SD_READONLY_FLAG | USB_MASK); // override USB and SD-Card Readonly Bits
}
else
- physw_status[2] = physw_status[2] & ~SD_READONLY_FLAG;
+ physw_status[2] = physw_status[2] & ~SD_READONLY_FLAG; // override SD-Card Readonly Bit
}
int get_usb_power(int edge) {
@@ -267,18 +161,6 @@ int get_usb_power(int edge) {
return x;
}
-/*
-void kbd_set_alt_mode_key_mask(long key) {
- int i;
- for (i=0; keymap[i].hackkey; ++i) {
- if (keymap[i].hackkey == key) {
- alt_mode_key_mask = keymap[i].canonkey;
- return;
- }
- }
-}
-*/
-
void kbd_key_press(long key) {
int i;
for (i=0;keymap[i].hackkey;i++) {
@@ -434,3 +316,99 @@ static KeyMap keymap[] = {
{0, 0, 0}
};
+// generic function
+// called from capt_seq.c at sub_FF995A50_my()
+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
+ {
+ 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;
+ 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<conf.synch_delay_value+(conf.synch_delay_coarse_value*1000);count1++) { // wait delay_value * 0.1ms
+ for (count2=0;count2<1400;count2++) { // delay approx. 0.1ms
+ }
+ }
+ }
+
+ //debug_led(0);
+ asm volatile ("LDMFD SP!, {R0-R11,LR}\n"); // restore R0-R11 and LR from stack
+}
Please sign in to comment.
Something went wrong with that request. Please try again.