So the new Quick Launch Menu built into Myo Connect is pretty sweet. Easy access to Myo Keyboard, Myo Mouse, and a whole bunch of very useful applications. It also exposes a bug present in a few scripts. Specifically, related to how they clean up when their script is deactivated.

What I mean is if you have mouse control active, open the quick launch menu, and close it again, mouse control will still be active. That may be what you want, but if you are using the standard locking policy, the Myo will also be locked again, meaning you may be moving the cursor but unable to press any buttons. You could definitely have run into this bug in the script before, but it's likely to be come a lot more prevalent with such easy access to the Quick Launch Menu.

Fortunately, it's also very easy to fix. Just make proper use of onActiveChange:

  


-- Make sure mouse control is correctly disabled and re-enabled if the Quick Launch Menu is toggled
    wasUnlocked = false  
    wasMouseControl = false  
    function onActiveChange(isActive)  
        if (isActive == false) then
            wasUnlocked = myo.isUnlocked()
            wasMouseControl = myo.mouseControlEnabled()
            myo.controlMouse(false)
        elseif wasUnlocked then
            myo.unlock("hold")
            myo.controlMouse(wasMouseControl)
        end
    end  

You may want to call myo.unlock("timed"), or skip the elseif and just disable mouse control. Or there could be other things you need to clean up, like sending "up" for any keyboard or mouse buttons you've only sent "down" for. Depends on the specifics of your script. Just make sure to think about it!

It's easy to do, but also easy to forget. Don't! Always clean up in onActiveChange.

Newsletter

Enter your email address and get all latest content delivered to your inbox every now and then.