Main > Driving & Racing Cabinets

Maximum Tune 3 (WMMT 3DX) - Cab Conversion Help

<< < (3/5) > >>

Here is the code so far so for Steering, Accelerator and Brake (thanks again to baritonomarchetto and PL1) - I'm still testing this out and still unsure about the pots for the Accel and Brake if they are working properly, would it be normal to have ranges of Brake - 350 to 765 and Accel - 490 to 915.

I would have though they would act similar to the Wheel pot and go from 0 - 1000, or are they designed like that so the react quicker to inputs?? :dizzy:

--- Code: ---/* ArcadeHID - steering wheel handling example
 * gamepad emulation
 * by Barito, 2021
 * Rev-2 - Steering, Accelerator and Brake

#include <Joystick.h>

0, 0,                  // Button Count, Hat Switch Count
false, false, false,    // X, Y, Z Axis
false, false, false,   //Rx, Ry, Rz
false, false,          //rudder, throttle
true, true, true);   //accelerator, brake, steering
const int steerPin = A0;
const int brakePin = A1;
const int accelPin = A2;
int steerValue;
int brakeValue;
int accelValue;

void setup() {
//Steering Options - X Axis or Steering
//Joystick.setXAxisRange(0, 1023); //Steering Wheel - Joystick.setXAxisRange(min, max);
Joystick.setSteeringRange(0, 960);

//Brake Options - Y Axis or Brake
//Joystick.setYAxisRange(0, 1023); //Brake Pedal - Joystick.setYAxisRange(min, max);
Joystick.setBrakeRange(366, 767);
Serial.begin(9600); // Testing analog input

//Accelerator Options - Z Axis or Acceleratro
//Joystick.setZAxisRange(0, 1023); //Accel Pedal - Joystick.setZAxisRange(min, max);
Joystick.setAcceleratorRange(490, 915);

//Start Joystick

void loop() {

void SteerWheel(){
steerValue = analogRead(steerPin);

void BrakePedal(){
brakeValue = analogRead(brakePin);
Serial.println(brakeValue); // Testing analog input

void AccelPedal(){
accelValue = analogRead(accelPin);
--- End code ---

This code is working with Teknoparrot 1.53 running Maximum Tune 5 the inputs all seem to registering and working. I have everything dismantled on a table so its bit hard to test to see if its all working properly but it seems ok.

Now to add in the buttons, any feed back on the code or info around the Accel and Brake pots would be awesome.

Cheers  :cheers:


--- Quote from: Vee21 on November 13, 2021, 10:03:58 am ---The strange thing is when I Serial Print the Accel and Brake pedals they read in a weird range and do not start from 0, for example the Accel pedal reads from 490 - 920 (pedal fully compressed). Would this be an indicator of bad wiring/ground or something else??

--- End quote ---
It's not that unusual for pedals to have a limited range of motion resulting in a limited range of values.

As long as the values aren't jumpy/jittery as you move through the range, it should work fine.

Calibrate the pedals in Windows Control Panel and in the in-game calibration menu and you should be fine.   :cheers:

--- Quote from: Vee21 on November 13, 2021, 11:22:48 pm ---Now to add in the buttons, any feed back on the code or info around the Accel and Brake pots would be awesome.

--- End quote ---
Baritonomarchetto also wrote ArcadeHID-Buttons.ino if you want to use keyboard keystrokes, but that could cause problems if the shifter is left in gear while the PC is booting.   :banghead:
- The "INPUT_PULLUP" command makes the input "active low" so ground applied to the input triggers the output.

I don't know how difficult it would be to make a composite HID device that is both gamepad and keyboard.   :dunno
- That would allow you to have keystrokes like ESC for exiting games in a multi-racer setup and allow you to keep the shifter on gamepad buttons so the PC doesn't think there's a stuck key while booting up.
- This might also help for some stand-alone games that only accept inputs from a single controller.


Joystick library is compatibile with keyboard (built-in) library, so a composite HID is absolutely possible (and it's the point under Arcade HID vs most commercial interfaces)


--- Quote from: baritonomarchetto on November 14, 2021, 11:45:07 am ---Joystick library is compatibile with keyboard (built-in) library, so a composite HID is absolutely possible (and it's the point under Arcade HID vs most commercial interfaces)

--- End quote ---
Excellent.   :cheers:

Could I just merge the code from the "potentiometers.ino" and "ArcadeHID-Buttons.ino" sketches to make a composite HID or is there something else that needs to be added?

I assume that gamepad buttons can be added to the "potentiometers.ino" sketch like in this example, right?
- Please consider adding one or two buttons to your "potentiometers.ino" sketch since it seems like that would be a very widely-used feature.

Can the shifter decoding logic I described earlier work?
- I figured that it would be possible to read the four input pins to one set of variables then use "if-else" logic (or a truth table?) to determine the gear and pass the necessary info (one button pressed, the others not pressed) to a second set of variables that the joystick library would then use to output the button press.


If I add two buttons I also have to change the sketch name :D
Jokes apart, those sketches are only feasibility examples. The number of lines are kept at a minimum to help people figure how specific tasks can be approached and give a "kick" to start. They are based on well documented libraries and examples on how to use the joystick library, keyboard and mouse in full are all over the net. You only uave to start toying with them ;)
You can merge those codes and it will very likely work. In case of errors I am here :)
About the shifter decoding logic: as far as you have enought inputs for your switches, you can literally do everithing comes to your mind with those microcontroller boards


[0] Message Index

[#] Next page

[*] Previous page

Go to full version