Latching Footswitch to MIDI Converter

You don't say what the problem actually is

What should the code do ?
What does it actually do ?