Generate sustain pedal event from button?

I’d like to generate a sustain pedal event from a button press in my plugin’s UI. Is there a simple way to do that and send to the host? Or, in this case, my standalone app/plugin?

I would have in the processor a queue/list of midi events recieved from the UI, and then the processor can inject those midi events into the next I/O MidiBuffer sent to the next processBlock() call

Yes, thanks. Here’s a snippet for those who might want to do this:

This goes in the processor’s processBlock.

        int channel = 0;           // 0-15, not 1-16
		int controller = 64;       // sustain pedal
		int value = 64;            // 64 = down, 0 = up
		int b0 = 0xB0 + channel;
		int b1 = controller;
		int b2 = value;
		auto m = MidiMessage(b0, b1, b2);
		midiMessages.addEvent(m, 0);