1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Updated LUA Events (markdown)

Robert Beekman 2017-09-12 14:15:27 +02:00
parent bd60893084
commit 3a248b86f1

@ -27,17 +27,17 @@ profile profile, profileUpdatingEventArgs eventArgs
-- This function will be called after every profile update, before every profile draw. -- This function will be called after every profile update, before every profile draw.
function updateHandler(profile, eventArgs) function updateHandler(profile, eventArgs)
-- In this example we only want to update once per frame when the keyboard is updated -- In this example we only want to update once per frame when the keyboard is updated
if eventArgs.DeviceType != "keyboard" then if not (eventArgs.DeviceType == "keyboard") then
return return
end end
-- The Event Arguments are inside the eventArgs parameter -- The Event Arguments are inside the eventArgs parameter
-- In a Windows Profile, you could do this: -- In a Windows Profile, you could do this:
local currentSong = eventArgs.DataModel.Spotify.SongName; local currentSong = eventArgs.DataModel.Spotify.SongName
end end
-- Subscribe to the event AFTER defining the function which must be subscribed. -- Subscribe to the event AFTER defining the function which must be subscribed.
Events.DeviceDrawing.add(updateHandler); Events.DeviceDrawing.add(updateHandler)
``` ```
--- ---
@ -60,17 +60,17 @@ profile profile, profileDrawingEventArgs eventArgs
-- This function will be called after every profile draw. -- This function will be called after every profile draw.
function drawHandler(profile, eventArgs) function drawHandler(profile, eventArgs)
-- In this example we only want to draw to the keyboard -- In this example we only want to draw to the keyboard
if eventArgs.DeviceType != "keyboard" then if not (eventArgs.DeviceType == "keyboard") then
return return
end end
-- The Event Arguments are inside the eventArgs parameter -- The Event Arguments are inside the eventArgs parameter
-- In a Windows Profile, you could do this: -- In a Windows Profile, you could do this:
local currentSong = eventArgs.DataModel.Spotify.SongName; local currentSong = eventArgs.DataModel.Spotify.SongName
end end
-- Subscribe to the event AFTER defining the function which must be subscribed. -- Subscribe to the event AFTER defining the function which must be subscribed.
Events.DeviceDrawing.add(drawHandler); Events.DeviceDrawing.add(drawHandler)
``` ```
--- ---
@ -89,9 +89,9 @@ profile profile, keyPressEventArgs eventArgs
```lua ```lua
-- This function will be called after every key press. -- This function will be called after every key press.
function keyHandler(profile, eventArgs) function keyHandler(profile, eventArgs)
print("You pressed: " .. eventArgs.Key); print("You pressed: " .. eventArgs.Key)
end end
-- Subscribe to the event AFTER defining the function which must be subscribed. -- Subscribe to the event AFTER defining the function which must be subscribed.
Events.KeyboardKeyPressed.add(keyHandler); Events.KeyboardKeyPressed.add(keyHandler)
``` ```