Arduino Micro as a game controller. Confused about how to use the Xinput library to make this code

Okay, noob here. Sorry for how dumb my questions will sound. I've got a simple task, I'm pretty sure. Basically just want to get Steam to recognize my HX711 load cell sensor / Arduino micro as a game controller / joystick input. I'm going to use it as a brake pedal for my racing sim.

Code:

#include "Joystick.h" //https://github.com/MHeironimus/ArduinoJoystickLibrary
#include "HX711.h" //https://github.com/bogde/HX711

#define DOUT  3
#define CLK  2
HX711 scale;
float calibration_factor = -300; //this controls how sensitive the pedal is

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, 
  JOYSTICK_TYPE_JOYSTICK, 0, 0,
  false, false, false, false, false, false,
  false, false, false, true, false);

int brake = 0;
int lastBrakeValue = 0;

void setup() {
  //Serial.begin(9600);

  scale.begin(DOUT, CLK);
  scale.set_scale();
  scale.tare(); //Reset the scale to 0
  long zero_factor = scale.read_average(); //Get a baseline reading
  scale.set_scale(calibration_factor);
  Joystick.setBrakeRange(0, 1023);
  Joystick.begin();
}

void loop() {
  int brake = scale.get_units();
  //Serial.print(String(brake) + " >> ");
  if(brake > 1023){
    brake = 1023;
  }else if(brake < 10){
    brake = 0;
  }
  //Serial.println(brake);
  if (lastBrakeValue != brake) {
     Joystick.setBrake(brake);
     lastBrakeValue = brake;
  }
  delay(1);
}

But, from what I'm reading... it sounds like I'm going to have to use the xinput library to make this work, at least if I want Steam to handle the controller inputs for my game.

There's a wonderful guide here on using xinput: How to Emulate an Xbox Controller with Arduino (XInput) - Parts Not Included

But I'm dumb. What aspects of xinput beyond "xinput.begin();" do I need to include with the code from my first link?

In my mind, I don't really need any of the xinput functions, I'm mostly just using HX711 functions and all I need from xinput is for Steam / Windows to recognize it as a game controller instead of emulating actual buttons etc.

Thank you to any kind soul that can help my tiny brain comprehend what I need to do hah.

This probably will not be your solution, but you might be interested in this topic...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.