Long key press emulation problems

Started by garry23, October 31, 2016, 12:19:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

garry23

I hope one of the Lua experts can help me out as I struggle to get a long key press working with the SET button.

Here is the test code:

function hfd_test(key)
if keymenu.submenu["Turn On/Off"].value == "Off" then
return true -- key works as normal
elseif key == KEY.SET and lv.enabled then -- user may be asking for an HFD move, so register dryos time
timer = dryos.ms_clock
return true
    elseif key == KEY.UNPRESS_SET and lv.enabled then -- test is HFD move requested
if dryos.ms_clock - timer > 3000 then
move()
return true
else
return true
end
end
end

event.keypress = hfd_test


If I'm in the ML menu and press SET, then SET seems to work as expected, ie if I hold SET for longer than 3000 ms, them my move function works, ie moving the lens. Also less than 3000ms SET works as normal, ie changing ML menu items.

If I leave the ML menu and go to LV, I seem to lose the 3000ms functionality, ie the long key press emulation.

Can some kind soul point out what I'm doing wrong?

Cheers

Garry

a1ex

In LiveView, SET does not always send unpress events (IIRC the exact behavior is model-dependent).

Similar to http://www.magiclantern.fm/forum/index.php?topic=17616.0

garry23

@A1ex

Thanks for the reminder  ;D

Is there anyway, in Lua, coding a key to function normally, if pressed 'quickly', and be programmable for a long press.

I've looked at various options and can't find a way round this.

It would be a great 'feature' in Lua, ie long press functionality, ie greatly extending the use of the keys/buttons.

Cheers

Garry

a1ex

That's a good idea. There are some long-press implementations for getting into ML menu on some models, but nothing generic yet.

garry23

@A1ex

Good ideas are easy :-)

Coding them in C++ is beyond me  >:(

Cheers

Garry