# Gamepad Integration

The **Gamepad Integration** addon bridges the gap between standard game controllers (Xbox, PS4/PS5, etc.) and your SimLab Composer VR experience. This allows users to navigate or interact with the scene using a familiar gamepad instead of traditional VR controllers.

---

### How It Works: The Logic

The addon translates physical button presses into **Variables** within SimLab Composer.

- **The Input:** Pressing a button sends a signal (e.g., "Pressed/Released" or a pressure value from 0.0 to 1.0).
- **The Response:** In the **Training Builder**, you use nodes like  **Watch Boolean Expression** or **Branch on Expression** to monitor these variables and trigger specific actions in your scene.

---

### Setup Guide

#### 1. Discovering Your Controller

Once you launch the addon, it will detect any connected controllers.

- **Discover:** If you connect your controller after the addon is open, click **Discover**. A popup will appear showing the controller’s name and image.
- **Mapping Buttons:** While the Discover dialogue is open, press any button on your gamepad. The variable name and its current value will appear in the list.
- **Add Variable:** Click the **Add Variable** button next to the desired input. This automatically creates that variable in the Training Builder for you to use.

#### 2. Linking the System

After mapping your variables, close the Discover dialogue to return to the main menu.

- **Link VR Experience:** Click this to generate the internal Training Builder system that allows SimLab to talk to the controller server.
- **Connect to VR:** Click this to establish the live connection. This step starts a local server that handles the communication.

#### 3. Running the Experience

Because the addon uses a server-based connection, your gamepad input can be sent to multiple platforms:

- **PC VR:** Standard wired or wireless connection.
- **Mobile &amp; Standalone Headsets:** Since the connection happens via a server, you can control experiences running on mobile devices or headsets like the Meta Quest.

---

### Input Types Reference

<table data-path-to-node="19" id="bkmrk-input-type-value-ran"><thead><tr><td>**Input Type**</td><td>**Value Range**</td><td>**Best Use Case**</td></tr></thead><tbody><tr><td><span data-path-to-node="19,1,0,0">**Discrete (Buttons)**</span></td><td><span data-path-to-node="19,1,1,0">Pressed / Released</span></td><td><span data-path-to-node="19,1,2,0">Toggling lights, opening doors, or teleporting.</span></td></tr><tr><td><span data-path-to-node="19,2,0,0">**Analog (Triggers/Sticks)**</span></td><td><span data-path-to-node="19,2,1,0">0.0 to 1.0</span></td><td><span data-path-to-node="19,2,2,0">Controlling movement speed or dimming lights.</span></td></tr></tbody></table>

---

### Closing the Session

When you are finished testing or presenting, click **Disconnect from VR**. This terminates the server connection and stops the variable tracking.

---

### Workflow Summary

1. **Discover:** Connect and identify your gamepad.
2. **Map:** Press buttons and click **Add Variable** to send them to Training Builder.
3. **Link:** Use **Link VR Experience** to build the connection logic.
4. **Connect:** Hit **Connect to VR** and launch your scene.

Watch this tutorial to learn more

<iframe allowfullscreen="allowfullscreen" height="314" src="https://www.youtube.com/embed/wrKuLXasTBs" width="560"></iframe>