20 April 2025

Rocke League Controller

 Rocket League Controller





For our project, we decided to create a controller for the game Rocket League. It was essential to us when coming up with concepts to create something as close as possible to the cars in the game. In looking for inspiration we came across a Fast and Furious collaboration with the game. This inspired us to make the Nissan Skyline GTR since we are both cars and fast and furious fans. To bring this to life we used Maya to model a shell of the Skyline to then 3D print. We made various test prints to modify the shell to accommodate the switches and sensors needed for the controller. In the end, it was very successful and very fun to together and paint. 


Early on, we encountered connectivity issues with the Circuit Playground, as the board would intermittently connect and disconnect. Although we had access to another Circuit Playground, we opted to use an ESP32 board, which was readily available on my desk. While the ESP32 shares compatibility with the same IDE, it does not support HID over USB. However, it does provide HID functionality over Bluetooth, allowing for a wireless controller. Our setup integrates two potentiometers for acceleration/braking and steering, a microphone for boost activation, and a tilt sensor mounted in the door to enable jumping. Once Windows detects the device, it interfaces through an Xbox 360 controller emulator, ensuring compatibility with Steam.


What other sensors would you add?



Circuit:





Brief summary of contributions:

Jack: All code, supplies (ESP32, linear potentiometer, mic)
Fabiana: All 3d modeling, 3d printing and painting


Video:




Code:

```#include <BleGamepad.h>

BleGamepad bleGamepad;

#define POTENTIOMETER_PIN1 34 //Steering
#define POTENTIOMETER_PIN2 32 //Throttle
#define MIC_PIN 25 //Mic
#define BUTTON_PIN 14 //Tilt Switch

void setup() {
    Serial.begin(115200);
    bleGamepad.begin();

    //Establish inputs
    pinMode(POTENTIOMETER_PIN1, INPUT);
    pinMode(POTENTIOMETER_PIN2, INPUT);
    pinMode(MIC_PIN, INPUT);
    pinMode(BUTTON_PIN, INPUT);
}

void loop() {
    // Read input values
    int steering = analogRead(POTENTIOMETER_PIN1);
    int throttle = analogRead(POTENTIOMETER_PIN2);
    int mic = analogRead(MIC_PIN);


    // Map values to x/z axis
    int xAxis = map(steering, 1200, 2900, -32767, 32767);
    int zAxis = map(throttle, 0, 4100, -32767, 32767);
    // Constrain values
    xAxis = constrain(xAxis, -32767, 32767);
    zAxis = constrain(zAxis, -32767, 32767);
    //Set Mic activation threshold
    bool micActivated = mic > 2000;

    //Tilt Switch
    bool buttonState = digitalRead(BUTTON_PIN) == HIGH;

    // Send axis values via BleGamepad
    bleGamepad.setAxes(xAxis, 16384, zAxis, 0, 0, 0, 0, 0);

    //Press A for tilt switch
    if (buttonState) {
        bleGamepad.press(1);
    } else {
        bleGamepad.release(1);
    }

    //Press B on mic activation
    if (micActivated) {
        bleGamepad.press(2);
    } else {
        bleGamepad.release(2);
    }
    delay(50);
}```









No comments:

Post a Comment

Note: Only a member of this blog may post a comment.