initial commit OSC Keys
This commit is contained in:
parent
724be08130
commit
27f86f7909
2 changed files with 118 additions and 0 deletions
6
OSC Keys/RBOSCKeys.xml
Normal file
6
OSC Keys/RBOSCKeys.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GMA3 DataVersion="2.3.2.0">
|
||||
<UserPlugin Name="RBOSCKeys" Guid="18 B0 3F 3B DE 5C 0C 04 5E 21 34 0A 72 DB C8 0E" Author="Rik Berkelder" Version="0.1.0.0" UserRights="View">
|
||||
<ComponentLua Name="[RB_OSC_Keys_v0_1_lua]" Guid="18 B0 3F 3B 0F 54 0C 04 28 2C E5 00 64 9F E0 0E" FileName="RB_OSC_Keys_v0.1.lua" UserRights="View"/>
|
||||
</UserPlugin>
|
||||
</GMA3>
|
||||
112
OSC Keys/RB_OSC_Keys_v0.1.lua
Normal file
112
OSC Keys/RB_OSC_Keys_v0.1.lua
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
-- !! On any showfile, make sure to run the plugin from the pool once before using it over OSC !!
|
||||
-- !! Also do this after changing the settings below !!
|
||||
|
||||
-- Edit the variables below to set your preferences for where things are stored
|
||||
|
||||
-- The plugin uses and re-assigns 10 quickey pool items.
|
||||
-- this should be set so they don't interfere with the rest of your show
|
||||
local first_quickey = 101;
|
||||
|
||||
-- The plugin also uses 10 blank execs. As with the quickeys, make sure these are somewhere out of the way
|
||||
local exec_page = 200;
|
||||
local first_exec = 181;
|
||||
|
||||
-- No need to edit anything underneath this line,
|
||||
-- unless you want to change how the plugin actually functions
|
||||
|
||||
local RB_OSCKeys_map = {}
|
||||
|
||||
local function setup()
|
||||
RB_OSCKeys_map = {}
|
||||
local obj = Pult():Children()[1]:Children()[2]
|
||||
obj:Dump()
|
||||
Cmd("Store quickey " .. first_quickey .. " thru " .. first_quickey + 9)
|
||||
Cmd("Store page " .. exec_page)
|
||||
Cmd("Assign quickey " .. first_quickey .. " thru " .. first_quickey + 9 .. " at page " .. exec_page .. " exec " .. first_exec .. " thru " .. first_exec + 9)
|
||||
end
|
||||
|
||||
local function tableLength(T)
|
||||
local count = 0
|
||||
for _ in pairs(T) do count = count + 1 end
|
||||
return count
|
||||
end
|
||||
|
||||
local function findPressed(keycode)
|
||||
for index, code in ipairs(RB_OSCKey_map) do
|
||||
if(code == keycode) then
|
||||
return index
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
local function findFreeIndex()
|
||||
local length = tableLength(RB_OSCKey_map)
|
||||
Printf("length " .. length)
|
||||
|
||||
for i=1,(length + 1),1 do
|
||||
if(RB_OSCKey_map[i] == nil or RB_OSCKey_map[i] == "") then
|
||||
return i
|
||||
end
|
||||
end
|
||||
|
||||
Printf('default')
|
||||
return length + 1
|
||||
end
|
||||
|
||||
local function printMap()
|
||||
Printf("=== map ===")
|
||||
for index, val in ipairs(RB_OSCKey_map) do
|
||||
local printval = val
|
||||
if(val == nil) then
|
||||
printval = "nil"
|
||||
end
|
||||
Printf(index .. ":" .. printval)
|
||||
end
|
||||
Printf("===========")
|
||||
end
|
||||
|
||||
local function main(display, rawArgs)
|
||||
if(rawArgs == "print") then
|
||||
printMap()
|
||||
return
|
||||
end
|
||||
|
||||
if(rawArgs == "reset") then
|
||||
RB_OSCKey_map = nil
|
||||
return
|
||||
end
|
||||
|
||||
if(rawArgs == nil) then
|
||||
setup()
|
||||
return
|
||||
end
|
||||
|
||||
if(RB_OSCKey_map == nil) then
|
||||
setup()
|
||||
end
|
||||
|
||||
local args = {}
|
||||
|
||||
for arg in string.gmatch(rawArgs, '[^ ]+') do
|
||||
args[#args+1] = arg
|
||||
end
|
||||
|
||||
|
||||
local keycode = args[1]
|
||||
local state = args[2] -- "press"/"release"
|
||||
local pressedIndex = findPressed(keycode)
|
||||
|
||||
if(state == "press" and pressedIndex == nil) then
|
||||
local index = findFreeIndex()
|
||||
RB_OSCKey_map[index] = keycode
|
||||
GetObject("Quickey " .. first_quickey + index - 1)['CODE'] = keycode
|
||||
CmdIndirect("Press Page ".. exec_page .." Exec " .. first_exec - 1 + index)
|
||||
elseif (state == "release" and pressedIndex ~= nil) then
|
||||
CmdIndirect("Unpress Page ".. exec_page .." Exec " .. first_exec - 1 + pressedIndex)
|
||||
RB_OSCKey_map[pressedIndex] = ""
|
||||
end
|
||||
end
|
||||
|
||||
return main
|
||||
Loading…
Add table
Add a link
Reference in a new issue