> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dairy.foundation/llms.txt
> Use this file to discover all available pages before exploring further.

# Gamepads

Mercurial's gamepads are a thin wrapper over [Pasteurized
Gamepads](/Pasteurized). Go give the Pasteurized docs a look first.

The basic differences are:

* Mercurial gamepads have support for command bindings.
* Mercurial gamepads are obtained from Mercurial, rather than from Pasteurized.

<CodeGroup>
  ```java Java theme={null}
  BoundGamepad g1 = Mercurial.gamepad1();
  Mercurial.gamepad2();

  // remember, we can set the whole gamepad at once
  Mercurial.gamepad2(Mercurial.gamepad1());
  ```

  ```kt Kotlin theme={null}
  val g1: BoundGamepad = Mercurial.gamepad1
  Mercurial.gamepad2

  // remember, we can set the whole gamepad at once
  Mercurial.gamepad2 = Mercurial.gamepad1
  ```
</CodeGroup>

Mercurial's `BoundBooleanSupplier` and `BoundDoubleSupplier` can both be built
from wrapping their Enhanced equivalents, or directly, see bindings for
examples.

You can combine buttons, sticks, triggers in the same ways as you can in
Pasteurized.

Additionally, the layering systems will work as well:

<CodeGroup>
  ```java Java theme={null}
  BoundGamepad teleopGamepad = new BoundGamepad(new SDKGamepad(gamepad1));
  BoundGamepad endgameGamepad = new BoundGamepad(new SDKGamepad(gamepad1));

  Map<Layers, BoundGamepad> mercurialGamepadMap = new HashMap<Layers, BoundGamepad>(){{
  	put(Layers.TELEOP, teleopGamepad);
  	put(Layers.ENDGAME, endgameGamepad);
  }};
  MapLayeringSystem<Layers, BoundDoubleSupplier, BoundBooleanSupplier, BoundGamepad> enumLayeringSystem = new MapLayeringSystem<>(Layers.TELEOP, pasteurizedGamepadMap);

  // LayeredGamepad takes a LayeringSystem and makes a gamepad from it
  LayeredGamepad<BoundDoubleSupplier, BoundBooleanSupplier, BoundGamepad> layeredGamepad = new LayeredGamepad<>(enumLayeringSystem);

  // now, modify teleop and endgame gamepads,
  // then bind commands to them individually
  // don't bind commands to the layered gamepad,
  // as this will not do what you expect
  ```

  ```kt Kotlin theme={null}
  val teleopGamepad = BoundGamepad(SDKGamepad(gamepad1))
  val endgameGamepad = BoundGamepad(SDKGamepad(gamepad1))

  val mercurialGamepadMap = mapOf(
  	Layers.TELEOP to teleopGamepad,
  	Layers.ENDGAME to endgameGamepad,
  )

  val enumLayeringSystem = MapLayeringSystem(Layers.TELEOP, pasteurizedGamepadMap)

  // LayeredGamepad takes a LayeringSystem and makes a gamepad from it
  val layeredGamepad = LayeredGamepad(enumLayeringSystem)

  // now, modify teleop and endgame gamepads,
  // then bind commands to them individually
  // don't bind commands to the layered gamepad,
  // as this will not do what you expect
  ```
</CodeGroup>

Overall, not too different from Pasteurized.
