bitSet = 0 bitReset = 1 --------------------------------------------------------------- -- Signal Library --------------------------------------------------------------- SigLib = { -------------------------------------- -- 3D Joystick -- -------------------------------------- -- These simply updates the Joystick values if its bitstates are changing. [mc.ISIG_INPUT0] = function (state) if (state == 1) then bitpattern("iRegs0/JogXValue", 0x1, bitSet) else bitpattern("iRegs0/JogXValue", 0xE, bitReset) end end, [mc.ISIG_INPUT1] = function (state) if (state == 1) then bitpattern("iRegs0/JogXValue", 0x2, bitSet) else bitpattern("iRegs0/JogXValue", 0x2, bitReset) end end, -- here are the other 10 signals defined -- Bits 0x1, 0x2, 0x4 or 0x8 will be set or reset for each register value } function bitpattern(regname, pattern, bitFunc) -- local inst=mc.mcGetInstance() local hreg = mc.mcRegGetHandle(inst, regname) local XJogValue = mc.mcRegGetValue(hreg) if bitFunc == bitSet then mc.mcRegSetValue(hreg, bit32.bor(XJogValue,pattern)) elseif bitFunc == bitReset then mc.mcRegSetValue(hreg, bit32.band(XJogValue,bit32.bnot(pattern))) end end