Magic Lantern Forum

Developing Magic Lantern => Reverse Engineering => Topic started by: nanomad on October 17, 2012, 10:08:23 PM

Title: Button Interrupt?
Post by: nanomad on October 17, 2012, 10:08:23 PM
So, I was wondering how the hell does canon know about keypresses. If it were me, I'd use an external interrupt driven by the TX chip and then run the appropriate handlers.
Does anyone know if it works like this?
Title: Re: Button Interrupt?
Post by: a1ex on October 17, 2012, 10:15:53 PM
Yes.

My theory:

- button presses originate from the MPU, via SIO3/MREQ: http://magiclantern.wikia.com/wiki/SIO3_MREQ
- 5Dc: bindGUISwitchCBR; on newer cameras it's more complicated, but along the same lines
- the bind function sends GUI events via GUI_Control (ML name: fake_simple_button).

In 5Dc, bindGUISwitchCBR is overriden to figure out which wheel was turned, because they both send the same GUI event (see gui.c).

However, I had no success porting this trick on 5D3 to figure out unhandled buttons that have all the same event code ( GUICMD_PRESS_BUTTON_SOMETHING ).

Title: Re: Button Interrupt?
Post by: g3gg0 on October 17, 2012, 10:43:35 PM
you can add a watchpoint to GUI_CONTROL function and look at the call trace if that helps
Title: Re: Button Interrupt?
Post by: a1ex on October 17, 2012, 10:54:24 PM
GUI_CONTROL processes the event in gui_main_task (Canon's button handler), and GUI_Control sends it to gui_main_task. Small difference, but kinda important.
Title: Re: Button Interrupt?
Post by: nanomad on October 17, 2012, 11:24:38 PM
Thanks for the info, I really hope I can manage to fix the damn button codes once and for all :P
Title: Re: Button Interrupt?
Post by: a1ex on October 17, 2012, 11:25:29 PM
You are talking about AV button, right?

That one is tricky, as the MPU sends something like OLC_INFO_CHANGED...
Title: Re: Button Interrupt?
Post by: nanomad on October 18, 2012, 12:25:21 AM
Not only the AV button, but also SET and other stuff.