#
hs.blackmagic
Support for the Blackmagic DaVinci Resolve Speed Editor Keyboard and Editor Keyboard.
Example Usage:
blackmagic = nil
local callback = function(obj, buttonID, pressed, mode, value)
if buttonID == "JOG WHEEL" then
print("Jog Wheel Mode " .. mode .. ", value: " .. value)
else
-- If Jog Wheel button pressed, change jog wheel mode
-- and activate the LED for that job wheel mode:
if buttonID == "SHTL" or buttonID == "JOG" or buttonID == "SCRL" then
local jogMode
if buttonID == "SHTL" then jogMode = "RELATIVE" end
if buttonID == "JOG" then jogMode = "ABSOLUTE" end
if buttonID == "SCRL" then jogMode = "ABSOLUTE ZERO" end
blackmagic:jogMode(jogMode)
blackmagic:led({
["SHTL"] = buttonID == "SHTL",
["JOG"] = buttonID == "JOG",
["SCRL"] = buttonID == "SCRL"
})
return
end
-- If a normal button is pressed:
if pressed then
print(buttonID .. " pressed")
blackmagic:led({[buttonID] = true})
else
print(buttonID .. " released")
hs.timer.doAfter(5, function()
blackmagic:led({[buttonID] = false})
end)
end
end
end
local discoveryCallback = function(connected, device)
if connected then
print(string.format("Device Connected: %s - %s", device:deviceType(), device:serialNumber()))
blackmagic = device
blackmagic:led({["SHTL"] = true}) -- Defaults to SHTL jog mode
blackmagic:jogMode("RELATIVE")
blackmagic:callback(callback)
else
print(string.format("Device Disconnected: %s - %s", device:deviceType(), device:serialNumber()))
end
end
hs.blackmagic.init(discoveryCallback)
This extension was thrown together by Chris Hocking for CommandPost.
This extension would not be possible without Sylvain Munaut's genius work figuring out the authentication protocol.
This extension is based off Chris Jones' hs.streamdeck extension.
Special thanks to David Peterson, Morten Bentsen, Håvard Njåstad and Sondre Tungesvik Njåstad.
This extension uses code based off Sylvain Munaut's Python Scripts under the following license:
Copyright 2021 Sylvain Munaut [email protected]
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
#
API Overview
Constants - Useful values which cannot be changed
buttonNames deviceTypes jogModeNames ledNames
Functions - API calls offered directly by the extension
discoveryCallback getDevice init numDevices
Methods - API calls which can only be made on an object returned by a constructor
battery callback deviceType jogMode led serialNumber
#
API Documentation
#
Constants
#
buttonNames
#
deviceTypes
#
jogModeNames
#
ledNames
#
Functions
#
discoveryCallback
| | |
| --------------------------------------------|-------------------------------------------------------------------------------------|
| Signature | hs.blackmagic.discoveryCallback(fn) -> none
|
| Type | Function |
| Description | Sets/clears a callback for reacting to device discovery events. |
| Parameters |
- fn - A function that will be called when a Blackmagic device is connected or disconnected. It should take the following arguments:
A boolean, true if a device was connected, false if a device was disconnected.
An
hs.blackmagic
object, being the device that was connected/disconnected.
- None
#
getDevice
#
init
| | |
| --------------------------------------------|-------------------------------------------------------------------------------------|
| Signature | hs.blackmagic.init(fn) -> none
|
| Type | Function |
| Description | Initialises the Blackmagic driver and sets a discovery callback. |
| Parameters |
- fn - A function that will be called when a Blackmagic device is connected or disconnected. It should take the following arguments:
A boolean,
true
if a device was connected,false
if a device was disconnected. Anhs.blackmagic
object, being the device that was connected/disconnected.
- None
- This function must be called before any other parts of this module are used.