-
Notifications
You must be signed in to change notification settings - Fork 0
Function Macro
This macro lets you run an arbitrary lua function.
type value func or f
{ type="func"|"f", <function/name> [, <arguments[]> , async=<boolean>] }
--This enables access to the lua libraries and logitech API
rv.utils.developerMode()
-- A simple global function that logs a message to the Logitech lua window
function customFunction()
OutputLogMessage("Hello World")
end
-- Passing the function as a name
k.m3 = { type="func", "customFunction" }
The macro receives one or two commands. The first being either the name of a global function or simply a directly defined function. The second command is an table of arguments that will be passed to the function when it is called.
--This enables access to the lua libraries and logitech API
rv.utils.developerMode()
-- Defining a function directly on the macro
k.m3 = { type="func", function() OutputLogMessage("direct function") end }
-- Another simple function
function addingFunction(a,b)
OutputLogMessage("I am doing maths: "..a.. "+"..b.."="..(a+b))
end
-- Passing a list of 2 parameters as the second command
-- This will output ""I am doing maths: 2+4=6"
k.m4 = { type="func", "addingFunction", {2,4} }
Besides the General Macro Options the Function Macro offers the following options to customize behavior:
For functions that involve complex or continuos computations, we can run a function asynchronous (for lua that means in a coroutine), so that the rest of the profile won't be blocked from receiving events and running other macros.
Interruptions can be implemented with the rv.threading:wait method or directly with coroutine.yield (revenant expects yield to return a number which will be interpreted as the number of milliseconds to wait) .
Default value: false
--This enables access to the lua libraries and logitech API
rv.utils.developerMode()
-- A directly defined async function.
k.m3 = {
type="func"
function()
OutputLogMessage("this is logged immediately")
rv.threading:wait(500)
OutputLogMessage("this is logged after 500ms")
rv.threading:wait(0)
OutputLogMessage("This is logged as soon as possible but other logic could run in-between")
end,
async=true
}
- Key Macro
- Sequence Macro
- Cycle Macro
- Group Macro
- Multiclick Macro
- Hold Key Macro
- Mouse Position Macro
- Mouse Wheel Macro
- Mode Change Macro
- Backlight Macro
- DPI Macro
- External Macro
- Log Macro
- Documentation Macro
- Pagination Macro
- Control Macro
- Key Buffer Macro
- Wrap Key Macro
- Link Macro
- Instance Macro
- Flag Macro
- Function Macro
- Alter History Macro