Author Topic: Lua key press redirect  (Read 3678 times)

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 2217
Lua key press redirect
« on: March 18, 2016, 10:44:18 PM »
David (if your watching :) )

I'm trying to be clever and redirect a key press. The following script is meant to intercept the press of the play button and turn this into a half shutter press. But it doesn't seem to work. The play button responds as if play was pressed. Any ideas where I'm going wrong in this test script?

Code: [Select]
test_menu = menu.new
{
    name = "Show keypress",
    choices = { "Off", "On" },
    value = "On",
}

function event.keypress(key)
    if key == KEY.PLAY and test_menu.value == "On" then
key = UNPRESS_HALFSHUTTER
return true
end
end

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3218
  • 60Da / 1100D / EOSM
Re: Lua key press redirect
« Reply #1 on: March 19, 2016, 12:00:26 AM »
Function parameters are "pass by value". Setting them will have no effect on the caller.

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 2217
Re: Lua key press redirect
« Reply #2 on: March 19, 2016, 04:51:30 AM »
David

Thanks. BTW is the custom_picture_taking (arg) functionality working in the Lua event module?

If so how do I use this within a Lua script?

Finally, I assume this is the correct use of the press function in the Lua key module?

Code: [Select]
key.press(HALFSUTTER)
Cheers

Garry