How to map the MasterCue button?

I am trying to map the MasterCue button of the Pioneer DDJ-200.
It is labeled as such in Rekordbox Midi Settings.

I believe in Mixxx it corresponds to the HeadMix key.
From the learning feature I obtained this code in my XML mapping.

        <control>
            <group>[Master]</group>
            <key>headMix</key>
            <description>MIDI Learned from 2 messages.</description>
            <status>0x96</status>
            <midino>0x63</midino>
            <options>
                <normal/>
            </options>
        </control>

Now, when I press the Master button, the Cue/Mst knob in Mixxx turns from left to right, but as soon as I release it, it turns back to left.
However, it should stay right until I press the button again.
Moreover I would like the LED to turn on.

How can I do this?

headMix is a knob, not a button. Are you sure you’re not looking for pfl?

pfl is already working.
This is how it looks like and I am talking about the button labeled master:

image

What is it supposed to do? Toggle between Cue-only and 50% cue + 50% master? I don’t think it’s possible to map this in XML, you probably need to use JavaScript.

Yes, I think it is supposed to toggle this knob between right and left.
How would a simple JavaScript look like?

You need to create a toggleMasterCue() function in your script and bind your Master Cue button to it.
I suggest you read https://github.com/mixxxdj/mixxx/wiki/Midi-Scripting#link-midi-input-signals-to-javascript as we can point you in the right direction, but we’re not going to do the work for you :wink:
have a look how other scripts use this.

In your script you also need an (internal) boolean variable like headMixState that stores the last-set state of your button.
The toggleMasterCue() function would simply look if you last set headMix to 0 or 1 (on/off) and do the oppsite every time you press it via engine.setvalue("[Master]", "headMix", [0, 1]);, and at the same time send the respective On/Off message to the LED via midi.sendShortMsg(channel, midinote, value)
see https://github.com/mixxxdj/mixxx/wiki/Midi-Scripting#send-midi-output-to-the-controller

Good luck!

Alright. Thank you very much!
I got it working:

This is the function, just for the record:

DDJ200.headmix = function (channel, control, value, status, group) {
if (value == 0) { return; }
DDJ200.headMix_val = 1 - DDJ200.headMix_val;
engine.setValue("[Master]", "headMix", 2 * DDJ200.headMix_val - 1);
// headMix knob has values from -1 to 1

DDJ200.headMix_LED = 0x7F - DDJ200.headMix_LED;
midi.sendShortMsg(0x90+channel, control, DDJ200.headMix_LED);  // headMix
//midi.sendShortMsg(0x96, 0x63, 0x7F);  // headMix button
};