Not sure if 'kbd_is_blocked()' is a reliable indicator of ALT mode.
At the time I was doing the "N" ports, I looked for a way to detect if CHDK was in ALT mode. I was somewhat surprised to find there was no flag or state variable indicating that. But quick look at the
enter_alt() and
exit_alt() functions showed the kbd_blocked flag seeming to say the same thing so that's what I used (in part because I had a million bigger problems with that port). Seems to have worked pretty well so far but that's not to say it's had a ton of diverse user testing or that there are not side effects.
The kbd_process() code seems to set the 'kbd_blocked' flag on and off when using a USB remote - even when not in ALT mode.
Unfortunately, that part of the code is mostly mine from back when I did the USB Remote 2.0 code. I can clearly remember struggling with why things were certain ways in the existing kbd_process() code (scan the 1.0.0 version of kbd.c if you are curious) and that little bit of code you noticed is what the mess of funny states eventually reduced to. I'll spend a little time trying to figure out why I left it that way (the part that says "Deal with the rest") as I recall hoping at the time that someone else would point ouf if that part was botched.
@philmoz : Irrespective of the above, I guess it would also be cleaner to add an
alt_state flag that gets set & cleared by
enter_alt() and
exit_alt() ? (the CHDK C functions - not the script ones). Then change the patch (and the Powershot N code) to use that? Is it worth wrapping that in a
get_alt_mode() function rather than making the variable global?