411
Mach4 Plugins / Re: mcX360 Plugin for Lua
« on: November 07, 2017, 01:36:43 PM »
Daz, sage advice as always.
One correction for anyone following this thread:
if GetXin("Btn_A") == "1" then
should read:
if GetXin("Btn_A") == 1 then
After rethinking how I want to use the controller I want to toggle the controller on/off (xEnabled) using the start button.
The following code does what I want but the first press shows 'Pendant Disabled' rather than my expected 'Pendant Enabled'. Where did I err in my code/logic?
TIA
RT
One correction for anyone following this thread:
if GetXin("Btn_A") == "1" then
should read:
if GetXin("Btn_A") == 1 then
After rethinking how I want to use the controller I want to toggle the controller on/off (xEnabled) using the start button.
The following code does what I want but the first press shows 'Pendant Disabled' rather than my expected 'Pendant Enabled'. Where did I err in my code/logic?
Code: [Select]
-----------------Event Timers
X360_Timer:Start(100)
local StartVal=0
X360_Panel:Connect(wx.wxEVT_TIMER, function (event)
-- Toggle xEnabled when Start Button is depressed
if GetXin("Btn_START") == 1 then
if StartVal==1 then --more than one start signal received before release
return
end
if xEnabled == false then
-- Btns_Timer:Start(50)
mc.mcCntlSetLastError(mInst,"Pendant Enabeled")
xEnabled=true
else
-- Btns_Timer:Stop()
mc.mcCntlSetLastError(mInst,"Pendant Disabeled")
xEnabled=false
end
StartVal=1
else
StartVal=0
end
end)
TIA
RT