# How to unplug a method attached to a controller

**URL:** https://discourse.processing.org/t/how-to-unplug-a-method-attached-to-a-controller/7122
**Category:** Libraries
**Created:** [January 2, 2019, 10:24pm UTC](https://discourse.processing.org/t/how-to-unplug-a-method-attached-to-a-controller/7122 "2019-01-02T22:24:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![robotijo](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@robotijo](https://discourse.processing.org/u/robotijo)
#### Post date: [January 2, 2019, 10:24pm UTC](https://discourse.processing.org/t/how-to-unplug-a-method-attached-to-a-controller/7122/1 "2019-01-02T22:24:00Z")

</div>

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:

```auto
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 ☹

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

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [January 17, 2019, 7:57pm UTC](https://discourse.processing.org/t/how-to-unplug-a-method-attached-to-a-controller/7122/2 "2019-01-17T19:57:18Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![robotijo](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@robotijo](https://discourse.processing.org/u/robotijo)
#### Post date: [January 17, 2019, 10:10pm UTC](https://discourse.processing.org/t/how-to-unplug-a-method-attached-to-a-controller/7122/3 "2019-01-17T22:10:07Z")

</div>

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!
