I'm just making first experience with the API function "Game Controller". I use the function to read out the trimswitch on the flightyoke to implement it to my trimsystem. Everything is working fine as long as I start the "instrument" with Air Manager. When starting it with Air Player nothing happens.
I've no clue to solve the problem.
Code: Select all
-- Create a new variables
trimUp_id = si_variable_create("trim_up", "BOOL", false)
trimDown_id = si_variable_create("trim_down", "BOOL", false)
function callback(type, index, value)
print("type = " .. type .. ", index = " .. index .. ", value = " .. tostring(value))
if type == 1 then
if index == 4 then
if value == true then
-- print("trim down pressed")
si_variable_write(trimDown_id, true)
elseif value == false then
-- print("trim down released")
si_variable_write(trimDown_id, false)
end
elseif index == 2 then
if value == true then
-- print("trim up pressed")
si_variable_write(trimUp_id, true)
elseif value == false then
-- print("trim up released")
si_variable_write(trimUp_id, false)
end
end
end
end
function new_data_callback(data1, data2)
print("New data1: "..tostring(data1))
print("New data2: "..tostring(data2))
end
si_variable_subscribe("trim_up", "BOOL",
"trim_down", "BOOL", new_data_callback)
list = game_controller_list()
for k, v in pairs(list) do
game_controller_add(v, callback)
end