| 1 | #include "lolevel.h" |
|---|
| 2 | #include "platform.h" |
|---|
| 3 | #include "core.h" |
|---|
| 4 | #include "keyboard.h" |
|---|
| 5 | #include "conf.h" |
|---|
| 6 | //#include "stdlib.h" |
|---|
| 7 | |
|---|
| 8 | typedef struct { |
|---|
| 9 | short grp; |
|---|
| 10 | short hackkey; |
|---|
| 11 | long canonkey; |
|---|
| 12 | } KeyMap; |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | static long kbd_new_state[3]; |
|---|
| 16 | static long kbd_prev_state[3]; |
|---|
| 17 | static long kbd_mod_state[3]; |
|---|
| 18 | static KeyMap keymap[]; |
|---|
| 19 | static long last_kbd_key = 0; |
|---|
| 20 | static int usb_power=0; |
|---|
| 21 | static int remote_key, remote_count; |
|---|
| 22 | static int shoot_counter=0; |
|---|
| 23 | static int aCount=0; |
|---|
| 24 | extern long aHookList[]; |
|---|
| 25 | extern long aHookNum; |
|---|
| 26 | |
|---|
| 27 | #define DELAY_TIMEOUT 10000 |
|---|
| 28 | |
|---|
| 29 | #define KEYS_MASK0 (0x0000000F) |
|---|
| 30 | #define KEYS_MASK1 (0x00094800) |
|---|
| 31 | #define KEYS_MASK2 (0x00007041) |
|---|
| 32 | |
|---|
| 33 | #define SD_READONLY_FLAG (0x20000) // 1 << 0x11 |
|---|
| 34 | #define SD_READONLY_REG 2 |
|---|
| 35 | |
|---|
| 36 | #define USB_MASK (0x40000) |
|---|
| 37 | |
|---|
| 38 | volatile int jogdial_stopped=0; |
|---|
| 39 | |
|---|
| 40 | void kbd_fetch_data(long*); |
|---|
| 41 | long kbd_get_held_key(); |
|---|
| 42 | |
|---|
| 43 | long __attribute__((naked)) wrap_kbd_p1_f() ; |
|---|
| 44 | |
|---|
| 45 | void wait_until_remote_button_is_released(void) |
|---|
| 46 | { |
|---|
| 47 | int count1; |
|---|
| 48 | int count2; |
|---|
| 49 | int tick,tick2,tick3; |
|---|
| 50 | int nSW; |
|---|
| 51 | int prev_usb_power,cur_usb_power; |
|---|
| 52 | |
|---|
| 53 | // ------ add by Masuji SUTO (start) -------------- |
|---|
| 54 | static int nMode; |
|---|
| 55 | // ------ add by Masuji SUTO (end) -------------- |
|---|
| 56 | |
|---|
| 57 | asm volatile ("STMFD SP!, {R0-R11,LR}\n"); // store R0-R11 and LR in stack |
|---|
| 58 | |
|---|
| 59 | debug_led(1); |
|---|
| 60 | tick = get_tick_count(); |
|---|
| 61 | tick2 = tick; |
|---|
| 62 | static long usb_physw[3]; |
|---|
| 63 | 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))) |
|---|
| 64 | // if (conf.synch_enable && conf.ricoh_ca1_mode && conf.remote_enable) // synch mode enable so wait for USB to disconnect |
|---|
| 65 | { |
|---|
| 66 | // ------ add by Masuji SUTO (start) -------------- |
|---|
| 67 | nMode=0; |
|---|
| 68 | usb_physw[2] = 0; // makes sure USB bit is cleared. |
|---|
| 69 | _kbd_read_keys_r2(usb_physw); |
|---|
| 70 | if((usb_physw[2] & USB_MASK)==USB_MASK) nMode=1; |
|---|
| 71 | // ------ add by Masuji SUTO (end) -------------- |
|---|
| 72 | |
|---|
| 73 | if(conf.ricoh_ca1_mode && conf.remote_enable) |
|---|
| 74 | { |
|---|
| 75 | if(shooting_get_drive_mode() ==1 && state_shooting_progress == SHOOTING_PROGRESS_PROCESSING){ //continuous-shooting mode |
|---|
| 76 | if(conf.bracket_type>2){ |
|---|
| 77 | if(shoot_counter<2) shutter_int=3; |
|---|
| 78 | shoot_counter--; |
|---|
| 79 | } |
|---|
| 80 | else{ |
|---|
| 81 | prev_usb_power=0; |
|---|
| 82 | nSW = 0; |
|---|
| 83 | do |
|---|
| 84 | { |
|---|
| 85 | usb_physw[2] = 0; // makes sure USB bit is cleared. |
|---|
| 86 | _kbd_read_keys_r2(usb_physw); |
|---|
| 87 | cur_usb_power = (usb_physw[2] & USB_MASK)==USB_MASK; |
|---|
| 88 | if(cur_usb_power){ |
|---|
| 89 | if(!prev_usb_power){ |
|---|
| 90 | tick2 = get_tick_count(); |
|---|
| 91 | prev_usb_power=cur_usb_power; |
|---|
| 92 | } |
|---|
| 93 | else{ |
|---|
| 94 | if((int)get_tick_count()-tick2>1000) {debug_led(0);} |
|---|
| 95 | } |
|---|
| 96 | } |
|---|
| 97 | else{ |
|---|
| 98 | if(prev_usb_power){ |
|---|
| 99 | tick3 = (int)get_tick_count()-tick2; |
|---|
| 100 | if(nSW==10) { |
|---|
| 101 | if(tick3>50) shutter_int=1; |
|---|
| 102 | nSW=20; |
|---|
| 103 | } |
|---|
| 104 | if(nSW==0 && tick3>0) { |
|---|
| 105 | if(tick3<50) { |
|---|
| 106 | nSW=10; |
|---|
| 107 | } |
|---|
| 108 | else{ |
|---|
| 109 | if(tick3>1000) shutter_int=1; |
|---|
| 110 | nSW=20; |
|---|
| 111 | } |
|---|
| 112 | } |
|---|
| 113 | prev_usb_power=cur_usb_power; |
|---|
| 114 | } |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | if((int)get_tick_count()-tick >= DELAY_TIMEOUT) {nSW=20;shutter_int=2;} |
|---|
| 118 | } |
|---|
| 119 | while(nSW<20); |
|---|
| 120 | } |
|---|
| 121 | } //continuous-shooting mode |
|---|
| 122 | else{ //nomal mode |
|---|
| 123 | shoot_counter=0; |
|---|
| 124 | if(conf.bracket_type>2){ |
|---|
| 125 | shoot_counter=(conf.bracket_type-2)*2; |
|---|
| 126 | } |
|---|
| 127 | do |
|---|
| 128 | { |
|---|
| 129 | usb_physw[2] = 0; // makes sure USB bit is cleared. |
|---|
| 130 | _kbd_read_keys_r2(usb_physw); |
|---|
| 131 | } |
|---|
| 132 | // while(((usb_physw[2] & USB_MASK)==USB_MASK) && ((int)get_tick_count()-tick < DELAY_TIMEOUT)); |
|---|
| 133 | // ------ modif by Masuji SUTO (start) -------------- |
|---|
| 134 | 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)); |
|---|
| 135 | // ------ modif by Masuji SUTO (end) -------------- |
|---|
| 136 | } |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | else |
|---|
| 140 | { |
|---|
| 141 | |
|---|
| 142 | do |
|---|
| 143 | { |
|---|
| 144 | usb_physw[2] = 0; // makes sure USB bit is cleared. |
|---|
| 145 | _kbd_read_keys_r2(usb_physw); |
|---|
| 146 | |
|---|
| 147 | } |
|---|
| 148 | while((usb_physw[2]&USB_MASK) && ((int)get_tick_count()-tick < DELAY_TIMEOUT)); |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | if (conf.synch_delay_enable && conf.synch_delay_value>0) // if delay is switched on and greater than 0 |
|---|
| 154 | { |
|---|
| 155 | for (count1=0;count1<conf.synch_delay_value+(conf.synch_delay_coarse_value*1000);count1++) // wait delay_value * 0.1ms |
|---|
| 156 | { |
|---|
| 157 | for (count2=0;count2<1400;count2++) // delay approx. 0.1ms |
|---|
| 158 | { |
|---|
| 159 | } |
|---|
| 160 | } |
|---|
| 161 | } |
|---|
| 162 | |
|---|
| 163 | debug_led(0); |
|---|
| 164 | asm volatile ("LDMFD SP!, {R0-R11,LR}\n"); // restore R0-R11 and LR from stack |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | static void __attribute__((noinline)) mykbd_task_proceed() |
|---|
| 168 | { |
|---|
| 169 | while (physw_run){ |
|---|
| 170 | _SleepTask(10); |
|---|
| 171 | |
|---|
| 172 | if (wrap_kbd_p1_f() == 1){ // autorepeat ? |
|---|
| 173 | _kbd_p2_f(); |
|---|
| 174 | } |
|---|
| 175 | } |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | // no stack manipulation needed here, since we create the task directly |
|---|
| 179 | void __attribute__((naked,noinline)) |
|---|
| 180 | mykbd_task() |
|---|
| 181 | { |
|---|
| 182 | mykbd_task_proceed(); |
|---|
| 183 | |
|---|
| 184 | _ExitTask(); |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | |
|---|
| 188 | long __attribute__((naked,noinline)) wrap_kbd_p1_f() |
|---|
| 189 | { |
|---|
| 190 | |
|---|
| 191 | asm volatile( |
|---|
| 192 | "STMFD SP!, {R1-R5,LR}\n" |
|---|
| 193 | "MOV R4, #0\n" |
|---|
| 194 | "BL my_kbd_read_keys\n" |
|---|
| 195 | "B _kbd_p1_f_cont\n" |
|---|
| 196 | ); |
|---|
| 197 | return 0; // shut up the compiler |
|---|
| 198 | } |
|---|
| 199 | void save_rom_log() { |
|---|
| 200 | asm volatile( |
|---|
| 201 | "mov r0, #0 \n" |
|---|
| 202 | "mov r1, #1 \n" |
|---|
| 203 | "stmdb sp!, {r0, r1, lr}\n" |
|---|
| 204 | "mov r0, sp\n" |
|---|
| 205 | "BL 0xFF922E14\n" //GetLogToFile |
|---|
| 206 | "ldmia sp!, {r0, r1, lr}\n" |
|---|
| 207 | ); |
|---|
| 208 | } |
|---|
| 209 | |
|---|
| 210 | void dumpProps() { |
|---|
| 211 | short int avv; |
|---|
| 212 | int i; |
|---|
| 213 | char aStr[50]; |
|---|
| 214 | void* l; |
|---|
| 215 | |
|---|
| 216 | l=(void*)Fopen_Fut("A/PropDmp.txt","a"); |
|---|
| 217 | for (i=0;i<300;i++){ |
|---|
| 218 | _GetPropertyCase(i, &avv, sizeof(avv)); // 23 for DiGiC III |
|---|
| 219 | sprintf(aStr,"[%3d]=(%8x)\n",i,avv); |
|---|
| 220 | Fwrite_Fut(aStr,1,strlen(aStr),l); |
|---|
| 221 | } |
|---|
| 222 | Fflush_Fut(l); |
|---|
| 223 | Fclose_Fut(l); |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | int dump1900_SD780() { |
|---|
| 227 | |
|---|
| 228 | #define START_ADDRESS 0x1900 |
|---|
| 229 | #define FWSIZE 0x30 |
|---|
| 230 | |
|---|
| 231 | void* l; |
|---|
| 232 | int j,k; |
|---|
| 233 | int* myPtr, myPtr2; |
|---|
| 234 | char sampleChr[64]; |
|---|
| 235 | |
|---|
| 236 | myPtr = (int*)aHookList; |
|---|
| 237 | |
|---|
| 238 | //myPtr2 = (int*)*myPtr; |
|---|
| 239 | |
|---|
| 240 | //l=(void*)Fopen_Fut("A/0x1900.bin","ab"); |
|---|
| 241 | //Fwrite_Fut(START_ADDRESS,1,FWSIZE,l); |
|---|
| 242 | //Fwrite_Fut(0xFF814EC8,1,16,l); |
|---|
| 243 | //Fflush_Fut(l); |
|---|
| 244 | //Fclose_Fut(l); |
|---|
| 245 | j=0; |
|---|
| 246 | |
|---|
| 247 | l=(void*)Fopen_Fut("A/aHookList.txt","ab"); |
|---|
| 248 | |
|---|
| 249 | while (j<aHookNum) |
|---|
| 250 | { |
|---|
| 251 | j++; |
|---|
| 252 | myPtr=(int*)aHookList[j]; |
|---|
| 253 | myPtr=myPtr-0x18; |
|---|
| 254 | for (k=0;k<FWSIZE;k++) |
|---|
| 255 | { |
|---|
| 256 | if ((*myPtr > 0xff810000) && (*myPtr < 0xFFA00000)) |
|---|
| 257 | { |
|---|
| 258 | sprintf(sampleChr,"loc:%8x - data:%8x - *data:%16s\n",myPtr,*myPtr,*myPtr); |
|---|
| 259 | } |
|---|
| 260 | else |
|---|
| 261 | { |
|---|
| 262 | sprintf(sampleChr,"loc:%8x - data:%8x - *data:unsafe\n",myPtr,*myPtr);//*myPtr); |
|---|
| 263 | } |
|---|
| 264 | Fwrite_Fut(sampleChr,1,63,l); |
|---|
| 265 | myPtr++; |
|---|
| 266 | } |
|---|
| 267 | sprintf(sampleChr,"Next Hook\n",myPtr,*myPtr,*myPtr); |
|---|
| 268 | Fwrite_Fut(sampleChr,1,63,l); |
|---|
| 269 | Fflush_Fut(l); |
|---|
| 270 | } |
|---|
| 271 | Fflush_Fut(l); |
|---|
| 272 | Fclose_Fut(l); |
|---|
| 273 | return 0; |
|---|
| 274 | |
|---|
| 275 | //myPtr = (int*)0x1984; |
|---|
| 276 | //*myPtr = jF; |
|---|
| 277 | //myPtr = (int*)0x197C; |
|---|
| 278 | //*myPtr = jF; |
|---|
| 279 | // int fd; |
|---|
| 280 | |
|---|
| 281 | // script_console_add_line(buf); |
|---|
| 282 | // script_console_draw(); |
|---|
| 283 | |
|---|
| 284 | //char filen=malloc(16); |
|---|
| 285 | //int i; |
|---|
| 286 | //for (i=0x4; i>0; i = i << 1) { |
|---|
| 287 | // sprintf(filen, "A/crash_%i_.log", i); |
|---|
| 288 | // fd = open("A/crash.log", O_WRONLY|O_CREAT|O_APPEND, 0777); |
|---|
| 289 | // write(fd, buf, len); |
|---|
| 290 | // close(jF); |
|---|
| 291 | } |
|---|
| 292 | |
|---|
| 293 | |
|---|
| 294 | |
|---|
| 295 | |
|---|
| 296 | //int dumpFW_SD780() { |
|---|
| 297 | // |
|---|
| 298 | //#define MIN_ADDRESS 0xFF800000 |
|---|
| 299 | //#define FW_SIZE 0x7FFFFF |
|---|
| 300 | //#define START_SECTOR 2048 |
|---|
| 301 | // |
|---|
| 302 | //char j[]="A/test.bin"; |
|---|
| 303 | //char k[]="wb"; |
|---|
| 304 | //void* l; |
|---|
| 305 | // |
|---|
| 306 | //l=(void*)Fopen_Fut("A/test.bin","w"); |
|---|
| 307 | //Fwrite_Fut(MIN_ADDRESS,1,FW_SIZE,l); |
|---|
| 308 | //Fflush_Fut(l); |
|---|
| 309 | //Fclose_Fut(l); |
|---|
| 310 | // |
|---|
| 311 | //// wr=(f_w)*(unsigned int*)(0xFF903B38); |
|---|
| 312 | //// |
|---|
| 313 | //// int i; |
|---|
| 314 | //// unsigned long sa; |
|---|
| 315 | //// |
|---|
| 316 | //// sa = MIN_ADDRESS; |
|---|
| 317 | //// i=wr(1,2048,FW_SIZE/512,sa); |
|---|
| 318 | //// debug_led(1); |
|---|
| 319 | //// while(1); |
|---|
| 320 | // return 0; |
|---|
| 321 | //} |
|---|
| 322 | |
|---|
| 323 | |
|---|
| 324 | |
|---|
| 325 | |
|---|
| 326 | |
|---|
| 327 | void my_kbd_read_keys() |
|---|
| 328 | { |
|---|
| 329 | |
|---|
| 330 | static char osd_buf[64]; |
|---|
| 331 | volatile long *mmio2 = (void*)0xE240; //VERIFY_SD780 - Used to override long held DISP - Needs to be #DEFINE |
|---|
| 332 | int isHeldDisp = 0; |
|---|
| 333 | |
|---|
| 334 | kbd_prev_state[0] = kbd_new_state[0]; |
|---|
| 335 | kbd_prev_state[1] = kbd_new_state[1]; |
|---|
| 336 | kbd_prev_state[2] = kbd_new_state[2]; |
|---|
| 337 | kbd_fetch_data(kbd_new_state); |
|---|
| 338 | |
|---|
| 339 | // short xA; |
|---|
| 340 | // char aC[64]; |
|---|
| 341 | // get_property_case(223, &xA, sizeof(xA)); |
|---|
| 342 | // sprintf(aC,"223 - (%8x)",xA); |
|---|
| 343 | // draw_txt_string(15, 5, aC, conf.osd_color); |
|---|
| 344 | // get_property_case(102, &xA, sizeof(xA)); |
|---|
| 345 | // sprintf(aC,"102 - (%8x)",xA); |
|---|
| 346 | // draw_txt_string(15, 6, aC, conf.osd_color); |
|---|
| 347 | |
|---|
| 348 | /* |
|---|
| 349 | sprintf(aC,"physw_run - (%8x)",physw_run); |
|---|
| 350 | draw_txt_string(1, 3, aC, conf.osd_color); |
|---|
| 351 | sprintf(aC,"zoom_busy - (%8x)",zoom_busy); |
|---|
| 352 | draw_txt_string(1, 4, aC, conf.osd_color); |
|---|
| 353 | sprintf(aC,"focus_busy - (%8x)",focus_busy); |
|---|
| 354 | draw_txt_string(1, 5, aC, conf.osd_color); |
|---|
| 355 | sprintf(aC,"canon_menu_active - (%8x)",canon_menu_active); |
|---|
| 356 | draw_txt_string(1, 6, aC, conf.osd_color); |
|---|
| 357 | sprintf(aC,"canon_shoot_menu_active - (%8x)",canon_shoot_menu_active); |
|---|
| 358 | draw_txt_string(1, 7, aC, conf.osd_color); |
|---|
| 359 | sprintf(aC,"recreview_hold - (%8x)",recreview_hold); |
|---|
| 360 | draw_txt_string(1, 8, aC, conf.osd_color); |
|---|
| 361 | sprintf(aC,"some_flag_for_af_scan - (%8x)",some_flag_for_af_scan); |
|---|
| 362 | draw_txt_string(1, 9, aC, conf.osd_color); |
|---|
| 363 | */ |
|---|
| 364 | |
|---|
| 365 | /* |
|---|
| 366 | sprintf(osd_buf, "1: %8x --> %8x", physw_status[0],kbd_new_state[0]); |
|---|
| 367 | draw_txt_string(20, 10, osd_buf, conf.osd_color); |
|---|
| 368 | |
|---|
| 369 | sprintf(osd_buf, "2: %8x --> %8x", physw_status[1],kbd_new_state[1]); |
|---|
| 370 | draw_txt_string(20, 11, osd_buf, conf.osd_color); |
|---|
| 371 | |
|---|
| 372 | sprintf(osd_buf, "3: %8x --> %8x", physw_status[2],kbd_new_state[2]); |
|---|
| 373 | draw_txt_string(20, 12, osd_buf, conf.osd_color); |
|---|
| 374 | msleep(500); |
|---|
| 375 | */ |
|---|
| 376 | if (kbd_get_held_key() == KEY_PRINT) { |
|---|
| 377 | draw_txt_string(26, 14, "<DISP>", conf.osd_color); |
|---|
| 378 | isHeldDisp=1; |
|---|
| 379 | } |
|---|
| 380 | if (kbd_get_pressed_key() == KEY_UP) { |
|---|
| 381 | // volatile long *aVar = (void*)0x5AD8; |
|---|
| 382 | // volatile long *aVar2 = (void*)0x13614; |
|---|
| 383 | // char aStr2[64]; |
|---|
| 384 | // sprintf(aStr2,"[ x = %d ]",*(long*)(aVar+0x40)); |
|---|
| 385 | // draw_txt_string(15, 10, aStr2, conf.osd_color); |
|---|
| 386 | } |
|---|
| 387 | |
|---|
| 388 | // sprintf(aStr2,"[ y = %d ]",*(long*)(aVar-0x40)); |
|---|
| 389 | // draw_txt_string(15, 11, aStr2, conf.osd_color); |
|---|
| 390 | // sprintf(aStr2,"[ z = %d ]",*(long*)(aVar2+0x1C)); |
|---|
| 391 | // draw_txt_string(15, 12, aStr2, conf.osd_color); |
|---|
| 392 | // sprintf(aStr2,"[ a = %d ]",*(long*)(aVar2-0x20)); |
|---|
| 393 | // draw_txt_string(15, 13, aStr2, conf.osd_color); |
|---|
| 394 | // } |
|---|
| 395 | // short int avv; |
|---|
| 396 | // char aStr[50]; |
|---|
| 397 | // |
|---|
| 398 | // _GetPropertyCase(PROPCASE_AV, &avv, sizeof(avv)); // 23 for DiGiC III |
|---|
| 399 | // sprintf(aStr,"[ AV = %d ]",avv); |
|---|
| 400 | // draw_txt_string(26, 14, aStr, conf.osd_color); |
|---|
| 401 | // } |
|---|
| 402 | // |
|---|
| 403 | |
|---|
| 404 | // gui_compare_props(1); |
|---|
| 405 | // msleep(5000); |
|---|
| 406 | //dumpProps(); |
|---|
| 407 | // _ShowAllTaskInfo(); |
|---|
| 408 | //_qprintf("*"); |
|---|
| 409 | //dump1900_SD780(); |
|---|
| 410 | //_qprintf("1"); |
|---|
| 411 | //dump1900_SD780(); |
|---|
| 412 | //_qprintf("34"); |
|---|
| 413 | //dump1900_SD780(); |
|---|
| 414 | //_qprintf("s123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890b"); |
|---|
| 415 | //dump1900_SD780(); |
|---|
| 416 | //short jV; |
|---|
| 417 | //_GetPropertyCase(149, &jV, sizeof(jV)); |
|---|
| 418 | //jV=jV-20; |
|---|
| 419 | //_SetPropertyCase(149, &jV, sizeof(jV)); |
|---|
| 420 | //draw_txt_string(27, 12, "dumpProps()", conf.osd_color); |
|---|
| 421 | // } |
|---|
| 422 | /* if (kbd_get_pressed_key() == KEY_DOWN) { |
|---|
| 423 | short xA[301]; |
|---|
| 424 | int iS; |
|---|
| 425 | int iL; |
|---|
| 426 | |
|---|
| 427 | |
|---|
| 428 | for (iS=0;iS<300;iS++) |
|---|
| 429 | { |
|---|
| 430 | get_property_case(iS, &xA[iS], sizeof(xA[iS])); |
|---|
| 431 | } |
|---|
| 432 | iL=1; |
|---|
| 433 | for (iS=0;iS<300;iS=iS+20) |
|---|
| 434 | { |
|---|
| 435 | char outStr[128]; |
|---|
| 436 | sprintf(outStr,"[%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d]\n",xA[iS],xA[iS+1],xA[iS+2],xA[iS+3],xA[iS+4],xA[iS+5],xA[iS+6],xA[iS+7],xA[iS+8],xA[iS+9],xA[iS+10],xA[iS+11],xA[iS+12],xA[iS+13],xA[iS+14],xA[iS+15],xA[iS+16],xA[iS+17],xA[iS+18],xA[iS+19]); |
|---|
| 437 | draw_txt_string(1, iL, outStr, conf.osd_color); |
|---|
| 438 | iL++; |
|---|
| 439 | } |
|---|
| 440 | }*/ |
|---|
| 441 | |
|---|
| 442 | |
|---|
| 443 | // if (kbd_get_pressed_key() == KEY_DOWN) { |
|---|
| 444 | /* |
|---|
| 445 | #define PROPCASE_DRIVE_MODE 102 |
|---|
| 446 | #define PROPCASE_FOCUS_MODE 133 |
|---|
| 447 | #define PROPCASE_FLASH_MODE 143 |
|---|
| 448 | #define PROPCASE_FLASH_FIRE 122 |
|---|
| 449 | #define PROPCASE_FLASH_MANUAL_OUTPUT 141 |
|---|
| 450 | #define PROPCASE_FLASH_ADJUST_MODE 121 |
|---|
| 451 | #define PROPCASE_USER_TV 264 |
|---|
| 452 | #define PROPCASE_TV 262 |
|---|
| 453 | #define PROPCASE_USER_AV 26 |
|---|
| 454 | #define PROPCASE_AV 23 |
|---|
| 455 | #define PROPCASE_MIN_AV 25 |
|---|
| 456 | #define PROPCASE_SV 247 |
|---|
| 457 | #define PROPCASE_DELTA_SV 79 |
|---|
| 458 | #define PROPCASE_SV_MARKET 246 |
|---|
| 459 | #define PROPCASE_BV 34 |
|---|
| 460 | #define PROPCASE_SUBJECT_DIST1 245 |
|---|
| 461 | #define PROPCASE_SUBJECT_DIST2 65 |
|---|
| 462 | #define PROPCASE_ISO_MODE 149 |
|---|
| 463 | #define PROPCASE_SHOOTING 206 |
|---|
| 464 | #define PROPCASE_IS_FLASH_READY 208 |
|---|
| 465 | #define PROPCASE_OVEREXPOSURE 103 |
|---|
| 466 | #define PROPCASE_SHOOTING_MODE 49 |
|---|
| 467 | #define PROPCASE_IS_MODE 145 |
|---|
| 468 | #define PROPCASE_QUALITY 57 |
|---|
| 469 | #define PROPCASE_RESOLUTION 218 |
|---|
| 470 | #define PROPCASE_EV_CORRECTION_1 107 |
|---|
| 471 | #define PROPCASE_EV_CORRECTION_2 207 |
|---|
| 472 | #define PROPCASE_ORIENTATION_SENSOR 219 |
|---|
| 473 | #define PROPCASE_DIGITAL_ZOOM_STATE 94 |
|---|
| 474 | #define PROPCASE_DIGITAL_ZOOM_POSITION 95 |
|---|
| 475 | #define PROPCASE_DISPLAY_MODE 105 |
|---|
| 476 | #define PROPCASE_BRACKET_MODE 29 |
|---|
| 477 | #define PROPCASE_FLASH_SYNC_CURTAIN 64 |
|---|
| 478 | #define PROPCASE_METERING_MODE 155 |
|---|
| 479 | #define PROPCASE_WB_ADJ 269 |
|---|
| 480 | #define PROPCASE_ASPECT_RATIO 294 |
|---|
| 481 | #define ZOOM_OPTICAL_MIN 1 |
|---|
| 482 | #define ZOOM_OPTICAL_MAX 2 |
|---|
| 483 | #define ZOOM_OPTICAL_MEDIUM 3 |
|---|
| 484 | #define ZOOM_OPTICAL_IN 4 |
|---|
| 485 | #define ZOOM_OPTICAL_OUT 5 |
|---|
| 486 | #define ZOOM_OPTICAL_REACHED_MIN 7 |
|---|
| 487 | |
|---|
| 488 | #define ZOOM_DIGITAL_MAX 9 |
|---|
| 489 | #define ZOOM_DIGITAL_MEDIUM 10 |
|---|
| 490 | #define ZOOM_DIGITAL_IN 11 |
|---|
| 491 | #define ZOOM_DIGITAL_OUT 12 |
|---|
| 492 | #define ZOOM_DIGITAL_REACHED_MAX 13 |
|---|
| 493 | */ |
|---|
| 494 | |
|---|
| 495 | |
|---|
| 496 | |
|---|
| 497 | // get_property_case(PROPCASE_DIGITAL_ZOOM_STATE, &x, sizeof(x)); |
|---|
| 498 | // if (x) { |
|---|
| 499 | // get_property_case(PROPCASE_DIGITAL_ZOOM_POSITION, &x, sizeof(x)); |
|---|
| 500 | // if (x==0) zoom_status=ZOOM_OPTICAL_MEDIUM; |
|---|
| 501 | // } |
|---|
| 502 | //dump1900_SD780(); |
|---|
| 503 | //draw_txt_string(27, 9, "_DownKey", conf.osd_color); |
|---|
| 504 | // } |
|---|
| 505 | if (kbd_get_pressed_key() == KEY_UP) { |
|---|
| 506 | |
|---|
| 507 | |
|---|
| 508 | |
|---|
| 509 | //shooting_get_drive_mode(); |
|---|
| 510 | //draw_txt_string(conf.temp_pos.x-10, conf.temp_pos.y, "dumpProps()", conf.osd_color); |
|---|
| 511 | //draw_string(conf.temp_pos.x, conf.temp_pos.y, osd_buf, conf.osd_color); |
|---|
| 512 | } |
|---|
| 513 | // if (kbd_get_pressed_key() == KEY_UP) { |
|---|
| 514 | //_UnsetZoomForMovie(); |
|---|
| 515 | //_HdmiRegDump();_EdidDump(); |
|---|
| 516 | //_drvInfo(); |
|---|
| 517 | //_blah(); |
|---|
| 518 | //dump1900_SD780(); |
|---|
| 519 | //_MoveIrisFullClose(1); |
|---|
| 520 | //draw_txt_string(27, 12, "_ShowAllTaskInfo()", conf.osd_color); |
|---|
| 521 | // } |
|---|
| 522 | // if (kbd_get_pressed_key() == KEY_RIGHT) { |
|---|
| 523 | // _PutInNdFilter(); |
|---|
| 524 | // draw_txt_string(27, 12, "NdIn", conf.osd_color); |
|---|
| 525 | // } |
|---|
| 526 | |
|---|
| 527 | if (isHeldDisp != 1) |
|---|
| 528 | { |
|---|
| 529 | if (kbd_process() == 0) |
|---|
| 530 | { |
|---|
| 531 | physw_status[0] = kbd_new_state[0]; |
|---|
| 532 | physw_status[1] = kbd_new_state[1]; |
|---|
| 533 | physw_status[2] = (physw_status[2] & (~KEYS_MASK2)) | |
|---|
| 534 | (kbd_new_state[2] & KEYS_MASK2); |
|---|
| 535 | physw_status[2] = physw_status[2] & ~SD_READONLY_FLAG; |
|---|
| 536 | } |
|---|
| 537 | else |
|---|
| 538 | { |
|---|
| 539 | // override keys |
|---|
| 540 | physw_status[0] = (kbd_new_state[0] & (~KEYS_MASK0)) | |
|---|
| 541 | (kbd_mod_state[0] & KEYS_MASK0); |
|---|
| 542 | physw_status[1] = (kbd_new_state[1] & (~KEYS_MASK1)) | |
|---|
| 543 | (kbd_mod_state[1] & KEYS_MASK1); |
|---|
| 544 | physw_status[2] = (physw_status[2] & (~KEYS_MASK2)) | |
|---|
| 545 | (kbd_mod_state[2] & KEYS_MASK2); //fix needed as below |
|---|
| 546 | physw_status[2] = physw_status[2] & ~SD_READONLY_FLAG; |
|---|
| 547 | |
|---|
| 548 | // physw_status[2] = (kbd_new_state[2] & (~KEYS_MASK2)) | |
|---|
| 549 | // (kbd_mod_state[2] & KEYS_MASK2); |
|---|
| 550 | // if ((jogdial_stopped==0) && !state_kbd_script_run){ |
|---|
| 551 | // jogdial_stopped=1; |
|---|
| 552 | // get_jogdial_direction(); |
|---|
| 553 | // } |
|---|
| 554 | // else if (jogdial_stopped && state_kbd_script_run) |
|---|
| 555 | // jogdial_stopped=0; |
|---|
| 556 | // |
|---|
| 557 | } |
|---|
| 558 | } |
|---|
| 559 | else |
|---|
| 560 | { |
|---|
| 561 | // draw_txt_string(26, 14, " ", conf.osd_color); |
|---|
| 562 | isHeldDisp = 0; |
|---|
| 563 | *mmio2 = *mmio2 & ~(0x00000040); |
|---|
| 564 | } |
|---|
| 565 | /* |
|---|
| 566 | _kbd_read_keys_r2(physw_status); |
|---|
| 567 | |
|---|
| 568 | // physw_status[2] = physw_status[2] & ~SD_READONLY_FLAG; |
|---|
| 569 | |
|---|
| 570 | |
|---|
| 571 | remote_key = (physw_status[2] & USB_MASK)==USB_MASK; |
|---|
| 572 | if (remote_key) remote_count += 1; |
|---|
| 573 | else if (remote_count) { |
|---|
| 574 | usb_power = remote_count; |
|---|
| 575 | remote_count = 0; |
|---|
| 576 | } |
|---|
| 577 | |
|---|
| 578 | if (conf.remote_enable) { |
|---|
| 579 | physw_status[2] = physw_status[2] & ~(SD_READONLY_FLAG | USB_MASK); |
|---|
| 580 | } |
|---|
| 581 | else physw_status[2] = physw_status[2] & ~SD_READONLY_FLAG; |
|---|
| 582 | |
|---|
| 583 | //_kbd_pwr_off(); |
|---|
| 584 | */ |
|---|
| 585 | } |
|---|
| 586 | |
|---|
| 587 | |
|---|
| 588 | int get_usb_power(int edge) |
|---|
| 589 | { |
|---|
| 590 | int x; |
|---|
| 591 | |
|---|
| 592 | if (edge) return remote_key; |
|---|
| 593 | x = usb_power; |
|---|
| 594 | usb_power = 0; |
|---|
| 595 | return x; |
|---|
| 596 | } |
|---|
| 597 | |
|---|
| 598 | /****************/ |
|---|
| 599 | |
|---|
| 600 | |
|---|
| 601 | void kbd_key_press(long key) |
|---|
| 602 | { |
|---|
| 603 | int i; |
|---|
| 604 | for (i=0;keymap[i].hackkey;i++){ |
|---|
| 605 | if (keymap[i].hackkey == key){ |
|---|
| 606 | kbd_mod_state[keymap[i].grp] &= ~keymap[i].canonkey; |
|---|
| 607 | return; |
|---|
| 608 | } |
|---|
| 609 | } |
|---|
| 610 | } |
|---|
| 611 | |
|---|
| 612 | void kbd_key_release(long key) |
|---|
| 613 | { |
|---|
| 614 | int i; |
|---|
| 615 | for (i=0;keymap[i].hackkey;i++){ |
|---|
| 616 | if (keymap[i].hackkey == key){ |
|---|
| 617 | kbd_mod_state[keymap[i].grp] |= keymap[i].canonkey; |
|---|
| 618 | return; |
|---|
| 619 | } |
|---|
| 620 | } |
|---|
| 621 | } |
|---|
| 622 | |
|---|
| 623 | void kbd_key_release_all() |
|---|
| 624 | { |
|---|
| 625 | kbd_mod_state[0] |= KEYS_MASK0; |
|---|
| 626 | kbd_mod_state[1] |= KEYS_MASK1; |
|---|
| 627 | kbd_mod_state[2] |= KEYS_MASK2; |
|---|
| 628 | } |
|---|
| 629 | |
|---|
| 630 | long kbd_is_key_pressed(long key) |
|---|
| 631 | { |
|---|
| 632 | int i; |
|---|
| 633 | for (i=0;keymap[i].hackkey;i++){ |
|---|
| 634 | if (keymap[i].hackkey == key){ |
|---|
| 635 | return ((kbd_new_state[keymap[i].grp] & keymap[i].canonkey) == 0) ? 1:0; |
|---|
| 636 | } |
|---|
| 637 | } |
|---|
| 638 | return 0; |
|---|
| 639 | } |
|---|
| 640 | |
|---|
| 641 | long kbd_is_key_clicked(long key) |
|---|
| 642 | { |
|---|
| 643 | int i; |
|---|
| 644 | for (i=0;keymap[i].hackkey;i++){ |
|---|
| 645 | if (keymap[i].hackkey == key){ |
|---|
| 646 | return ((kbd_prev_state[keymap[i].grp] & keymap[i].canonkey) != 0) && |
|---|
| 647 | ((kbd_new_state[keymap[i].grp] & keymap[i].canonkey) == 0); |
|---|
| 648 | } |
|---|
| 649 | } |
|---|
| 650 | return 0; |
|---|
| 651 | } |
|---|
| 652 | |
|---|
| 653 | long kbd_get_pressed_key() |
|---|
| 654 | { |
|---|
| 655 | int i; |
|---|
| 656 | for (i=0;keymap[i].hackkey;i++){ |
|---|
| 657 | if ((kbd_new_state[keymap[i].grp] & keymap[i].canonkey) == 0){ |
|---|
| 658 | return keymap[i].hackkey; |
|---|
| 659 | } |
|---|
| 660 | } |
|---|
| 661 | return 0; |
|---|
| 662 | } |
|---|
| 663 | |
|---|
| 664 | long kbd_get_clicked_key() |
|---|
| 665 | { |
|---|
| 666 | int i; |
|---|
| 667 | for (i=0;keymap[i].hackkey;i++){ |
|---|
| 668 | if (((kbd_prev_state[keymap[i].grp] & keymap[i].canonkey) != 0) && |
|---|
| 669 | ((kbd_new_state[keymap[i].grp] & keymap[i].canonkey) == 0)){ |
|---|
| 670 | return keymap[i].hackkey; |
|---|
| 671 | } |
|---|
| 672 | } |
|---|
| 673 | return 0; |
|---|
| 674 | } |
|---|
| 675 | |
|---|
| 676 | void kbd_reset_autoclicked_key() { |
|---|
| 677 | last_kbd_key = 0; |
|---|
| 678 | } |
|---|
| 679 | |
|---|
| 680 | long kbd_get_autoclicked_key() { |
|---|
| 681 | static long last_kbd_time = 0, press_count = 0; |
|---|
| 682 | register long key, t; |
|---|
| 683 | |
|---|
| 684 | key=kbd_get_clicked_key(); |
|---|
| 685 | if (key) { |
|---|
| 686 | last_kbd_key = key; |
|---|
| 687 | press_count = 0; |
|---|
| 688 | last_kbd_time = get_tick_count(); |
|---|
| 689 | return key; |
|---|
| 690 | } else { |
|---|
| 691 | if (last_kbd_key && kbd_is_key_pressed(last_kbd_key)) { |
|---|
| 692 | t = get_tick_count(); |
|---|
| 693 | if (t-last_kbd_time>((press_count)?175:500)) { |
|---|
| 694 | ++press_count; |
|---|
| 695 | last_kbd_time = t; |
|---|
| 696 | return last_kbd_key; |
|---|
| 697 | } else { |
|---|
| 698 | return 0; |
|---|
| 699 | } |
|---|
| 700 | } else { |
|---|
| 701 | last_kbd_key = 0; |
|---|
| 702 | return 0; |
|---|
| 703 | } |
|---|
| 704 | } |
|---|
| 705 | |
|---|
| 706 | |
|---|
| 707 | } |
|---|
| 708 | |
|---|
| 709 | long kbd_get_held_key() { |
|---|
| 710 | static long last_kbd_time = 0, press_count = 0; |
|---|
| 711 | register long key, t; |
|---|
| 712 | |
|---|
| 713 | key=kbd_get_clicked_key(); |
|---|
| 714 | if (key) { |
|---|
| 715 | last_kbd_key = key; |
|---|
| 716 | press_count = 0; |
|---|
| 717 | last_kbd_time = get_tick_count(); |
|---|
| 718 | return 0; |
|---|
| 719 | } else { |
|---|
| 720 | if (last_kbd_key && kbd_is_key_pressed(last_kbd_key)) { |
|---|
| 721 | t = get_tick_count(); |
|---|
| 722 | if (t-last_kbd_time>((press_count)?175:500)) { |
|---|
| 723 | ++press_count; |
|---|
| 724 | last_kbd_time = t; |
|---|
| 725 | return last_kbd_key; |
|---|
| 726 | } else { |
|---|
| 727 | return 0; |
|---|
| 728 | } |
|---|
| 729 | } else { |
|---|
| 730 | last_kbd_key = 0; |
|---|
| 731 | return 0; |
|---|
| 732 | } |
|---|
| 733 | } |
|---|
| 734 | |
|---|
| 735 | |
|---|
| 736 | } |
|---|
| 737 | |
|---|
| 738 | #ifdef CAM_USE_ZOOM_FOR_MF |
|---|
| 739 | long kbd_use_zoom_as_mf() { |
|---|
| 740 | static long v; |
|---|
| 741 | static long zoom_key_pressed = 0; |
|---|
| 742 | |
|---|
| 743 | if (kbd_is_key_pressed(KEY_ZOOM_IN) && (mode_get()&MODE_MASK) == MODE_REC) { |
|---|
| 744 | get_property_case(PROPCASE_FOCUS_MODE, &v, 4); |
|---|
| 745 | if (v) { |
|---|
| 746 | kbd_key_release_all(); |
|---|
| 747 | kbd_key_press(KEY_RIGHT); |
|---|
| 748 | zoom_key_pressed = KEY_ZOOM_IN; |
|---|
| 749 | return 1; |
|---|
| 750 | } |
|---|
| 751 | } else { |
|---|
| 752 | if (zoom_key_pressed==KEY_ZOOM_IN) { |
|---|
| 753 | kbd_key_release(KEY_RIGHT); |
|---|
| 754 | zoom_key_pressed = 0; |
|---|
| 755 | return 1; |
|---|
| 756 | } |
|---|
| 757 | } |
|---|
| 758 | if (kbd_is_key_pressed(KEY_ZOOM_OUT) && (mode_get()&MODE_MASK) == MODE_REC) { |
|---|
| 759 | get_property_case(PROPCASE_FOCUS_MODE, &v, 4); |
|---|
| 760 | if (v) { |
|---|
| 761 | kbd_key_release_all(); |
|---|
| 762 | kbd_key_press(KEY_LEFT); |
|---|
| 763 | zoom_key_pressed = KEY_ZOOM_OUT; |
|---|
| 764 | return 1; |
|---|
| 765 | } |
|---|
| 766 | } else { |
|---|
| 767 | if (zoom_key_pressed==KEY_ZOOM_OUT) { |
|---|
| 768 | kbd_key_release(KEY_LEFT); |
|---|
| 769 | zoom_key_pressed = 0; |
|---|
| 770 | return 1; |
|---|
| 771 | } |
|---|
| 772 | } |
|---|
| 773 | return 0; |
|---|
| 774 | } |
|---|
| 775 | #endif |
|---|
| 776 | |
|---|
| 777 | |
|---|
| 778 | static KeyMap keymap[] = { |
|---|
| 779 | /* tiny bug: key order matters. see kbd_get_pressed_key() |
|---|
| 780 | * for example |
|---|
| 781 | */ |
|---|
| 782 | |
|---|
| 783 | //SD780 - Keymap |
|---|
| 784 | { 0, KEY_UP , 0x00000008 }, |
|---|
| 785 | { 0, KEY_DOWN , 0x00000004 }, |
|---|
| 786 | { 0, KEY_LEFT , 0x00000001 }, |
|---|
| 787 | { 0, KEY_RIGHT , 0x00000002 }, |
|---|
| 788 | |
|---|
| 789 | |
|---|
| 790 | { 1, KEY_SET , 0x00004000 }, |
|---|
| 791 | // { 1, KEY_PLAY , 0x00080000 }, //SD780 Play button |
|---|
| 792 | { 1, KEY_MENU , 0x00000800 }, |
|---|
| 793 | // { 1, KEY_POWER , 0x00010000 }, //SD780 Power button |
|---|
| 794 | |
|---|
| 795 | //xxxf --> xxxd when in movie mode by switch |
|---|
| 796 | //xxxxxxx4 --> xxxxxxx5 when in lens extended recording mode |
|---|
| 797 | |
|---|
| 798 | |
|---|
| 799 | { 2, KEY_SHOOT_FULL , 0x00001001 }, |
|---|
| 800 | { 2, KEY_SHOOT_HALF , 0x00000001 }, |
|---|
| 801 | { 2, KEY_ZOOM_IN , 0x00004000 }, |
|---|
| 802 | { 2, KEY_ZOOM_OUT , 0x00002000 }, |
|---|
| 803 | { 2, KEY_PRINT , 0x00000040 }, //doesn't exist |
|---|
| 804 | { 2, KEY_DISPLAY , 0x00000040 }, //swapped for print atm |
|---|
| 805 | //We will see if I can make KEY_DISPLAY a long KEY_DISPLAY... |
|---|
| 806 | { 0, 0, 0 } |
|---|
| 807 | }; |
|---|
| 808 | |
|---|
| 809 | |
|---|
| 810 | void kbd_fetch_data(long *dst) |
|---|
| 811 | { |
|---|
| 812 | //SD780 0xFF8431EC GetKbdState |
|---|
| 813 | volatile long *mmio0 = (void*)0xc0220200; |
|---|
| 814 | volatile long *mmio1 = (void*)0xc0220204; |
|---|
| 815 | volatile long *mmio2 = (void*)0xc0220208; |
|---|
| 816 | |
|---|
| 817 | dst[0] = *mmio0; |
|---|
| 818 | dst[1] = *mmio1; |
|---|
| 819 | dst[2] = *mmio2 & 0xffff; |
|---|
| 820 | } |
|---|