How to unplug a method attached to a controller

Hi!
I’m using the Game Control Plus library to configure a game pad to control a Processing GUI. It’s working good and I’m happy with it but I’m stuck now. I would like to change the behavior of the game pad buttons pressing the Select button, one behavior to navigate into menu options and one behavior to control some stepper motors.
I want to plug the button to a method for one behavior, unplug it, and plug the button to another method for another behavior, but I don’t know how to unplug the button from the first method.
Next code works well:

import org.gamecontrolplus.*;
import org.gamecontrolplus.gui.*;
import controlP5.*;
ControlP5 cp5;

ControlIO control;
ControlDevice gPad;

void setup ()
{
  control = ControlIO.getInstance(this);
  gPad = control.getMatchedDeviceSilent("Dragon");
  if (gPad == null) 
      {
        println("Joystick not connected.");
        System.exit(-1); // End the program NOW!
      }  

  gPad.getButton("btnRUp").plug(this,"getbtnRUp1", ControlIO.ON_RELEASE);
}

But I don know how to unplug it :frowning:

Please, help me to unplug this method from my btnRUp button. Thx!!

I am not a GCP expert. Did you look at the examples such as Gcp_Joystick.pde, did you browse the reference for plug under e.g. Processing/libraries/GameControlPlus/reference/org/gamecontrolplus/ControlButton.html and did you look at the three video guides on the library homepage? They might have answers.

Hi Jeremy,

Yes, I read the ControlButton.html, I found the method plug() but there is not a method unplug(). My level programming is low and I understand the code of the method plug() but I’m not enough proficient to create a unplug() method by myself, I do not even know if it can be done.
I got over the problem writing switch sentences in the code of each button method.

Thanks for your help!

1 Like