Magic Lantern Forum

Developing Magic Lantern => Scripting Corner => Scripting Q&A => Topic started by: garry23 on June 07, 2016, 10:40:08 PM

Title: More Lua 'strangeness'
Post by: garry23 on June 07, 2016, 10:40:08 PM
David (assuming you pick up on this)\

I trying to intercept the wheel (that changes the aperture on my 5D3), but can't seem to get it going.

I've been using this test script to explore the problem:

test_menu = menu.new
{
    name = "Test",
    choices = { "Off", "On" },
    value = "On",
}

function event.keypress(key)
    if key == KEY.WHEEL_RIGHT and test_menu.value == "On" then
menu.set("Expo","ISO",400)
return false
elseif key == KEY.WHEEL_LEFT and test_menu.value == "On" then
menu.set("Expo","ISO",100)
return false
else
return true
end
end


If I replace the two WHEEL constants with, say, INFO and RATE, then the ISO changes OK as expected.

If I use the above code, then all I get is the aperture changes, ie keypress is ignoring the wheel key returns.

Any ideas as to what is happening?

Cheers

Garry
Title: Re: More Lua 'strangeness'
Post by: dmilligan on June 08, 2016, 03:14:49 AM
You can try printing the key code to see what is going on. Not all button events can be intercepted in all modes and every camera is different. I don't know much about 5D3. Canon firmware is peculiar and we don't intercept button presses at a low level (it appears that some amount of button processing happens on an external MPU that we can't control and don't know a whole lot about).

In general you should just expect some amount of 'strangeness'. While you have a nice, clean, organized, relatively well documented API to use, that API is built on a jumbled mess of quirky, undocumented, and sometimes poorly understood functions in Canon firmware, which in turn is running on an undocumented and sometimes poorly understood hardware. There is bound to be strangeness that creeps up through the cracks.
Title: Re: More Lua 'strangeness'
Post by: garry23 on June 08, 2016, 07:26:36 AM
David

I had already confirmed that the wheel right and left was returning a unique integer and had used that in the script, rather than the Lua constant ref.

Thus, talking to your response, I can confirm that keypress event handler does not handle the wheel. In other words wheel carries on 'just' driving aperture.

Thanks for clarifying the 'strangeness'.

Cheers

Garry