Hi reyalp,
first I want to thank for your answer. But I did already. The problem is that I get the debug messages only if I press half the shutter button or release it. If I press it full, the display gets black and I cannot see the debug value. Fortunately my battery was empty and then the camera told me to replace it. During this low battery period the debug window is visible also if I full press the button.
Here the result of physw_status[2] for shutter button:
Released: 0x408FFF
Half pressed: 0x40AFFE // A is flickering and replaced by 8 sometimes
Full pressed: 0x408FFC
I used a mask of 0x3 to check if released or pressed but it does not exit the loop.
Then I did some further tests, I used a part of he origin usb-switch function to test if the loop executes the code between the do..while loop brackets, here is what I used:
debug_led(1);
_kbd_pwr_on();
tick=get_tick_count();
do
{
usb_physw[2] = 0;
_kbd_read_keys_r2(usb_physw);
debug_led(usb_physw[2] & USB_MASK); // USB_MASK = 0x40000
}
while((int)get_tick_count()-tick < 10000); // just wait 10 seconds
If I press the shutter button full and then press the external USB switch the blue LED switches on. If I release it the blue LED switches off. So with this test I know the part between the brackets of the do loop gets executed well.
Then I replaced the inner part of the do..while loop by:
_kbd_read_keys_r2(physw_status);
debug_led(physw_status[2] & KBD_MASK); // KBD_MASK = 0x3 // IXUS 860 KEY_SHOOT_FULL
to wait for a key pressed/released instead of external USB switch.
I pressed the shutter button, then released it, but the blue LED swtiches only off.
Releasing it does not switch on the blue LED again. I also tested with different keys / KEY_MASKs like up/down/set, but always the same.
It seems that the physw_status[2] is not updated somehow for internal keys within the do..while loop.
Then I just replaced the KBD_MASK (but still used physw_status instead of usb_physw) by 0x40000 (USB_MASK), then I can use the external USB switch to turn off and on the blue LED again.
So the loop is OK, but CHDK does not recognize any internal key-press, during the loop, only external USB switch.
It is really strange, still need help!