Leostick Joystick? Yes, and here's how.
-
- Freetronics Staff
- Posts: 853
- Joined: Tue Apr 09, 2013 11:19 pm
- Location: Melbourne, Australia
- Contact:
Re: Leostick Joystick? Yes, and here's how.
Awesome, thanks for sharing that Ashley!
Re: Leostick Joystick? Yes, and here's how.
Hay drake250 is it possible to emulate 2 joysticks, 20+ buttons and a 8way hat switch at the same time? cos i really would like to..... plez tell me. if you want more info just ask.
edit: it seems that some thing went wrong and my code throws errors whenever i use any of the keyboard or mouse commands.
see the code here: https://drive.google.com/open?id=0B6rm4 ... 0lUaU5OSzA
reference pic:
edit: it seems that some thing went wrong and my code throws errors whenever i use any of the keyboard or mouse commands.
see the code here: https://drive.google.com/open?id=0B6rm4 ... 0lUaU5OSzA
reference pic:
Re: Leostick Joystick? Yes, and here's how.
Spent several days putting this together and since most of the knowledge I used came from here. It's good to give back to the community.
8 Axis, 10bits per axis
8 Buttons (active low)
Used to upgrade Logitech G25/G27 Pedals from 8bit to 10bit resolution. Works great. Please read the comments in the file if your unsure. And note that you need to put the USBAPI.h file in the correct place as it doesn't seem to override from within the IDE... also the HID.cpp file works fine from the sketch folder... odd..
Anywho... here is what I have been working on.
Enjoy
Ramjet.
8 Axis, 10bits per axis
8 Buttons (active low)
Used to upgrade Logitech G25/G27 Pedals from 8bit to 10bit resolution. Works great. Please read the comments in the file if your unsure. And note that you need to put the USBAPI.h file in the correct place as it doesn't seem to override from within the IDE... also the HID.cpp file works fine from the sketch folder... odd..
Anywho... here is what I have been working on.
Enjoy

Ramjet.
- Attachments
-
- leoJoy10bit_RamjetX.zip
- (10.51 KiB) Downloaded 253 times
-
- Freetronics Staff
- Posts: 853
- Joined: Tue Apr 09, 2013 11:19 pm
- Location: Melbourne, Australia
- Contact:
Re: Leostick Joystick? Yes, and here's how.
Excellent, thanks for sharing that Ramjet!
-
- Posts: 4
- Joined: Mon Oct 26, 2015 7:40 pm
Re: Leostick Joystick? Yes, and here's how.
Thanks Ramjet.
I found your code really useful.
I am a beginner coder, so bear with me. I am building a Controller for my stationary bike, currently the brake leaver is the throttle.
I would like to use a hall effect sensor to measure the crank speed as a throttle (below 60rpm = stop 90rpm and up = max speed).
do you think the arduino will be able to handle all the instructions and watch the RPM. I have found some code to do the rpm measurement I just dont know where and how to add it to your code.
I found your code really useful.
I am a beginner coder, so bear with me. I am building a Controller for my stationary bike, currently the brake leaver is the throttle.
I would like to use a hall effect sensor to measure the crank speed as a throttle (below 60rpm = stop 90rpm and up = max speed).
do you think the arduino will be able to handle all the instructions and watch the RPM. I have found some code to do the rpm measurement I just dont know where and how to add it to your code.
Re: Leostick Joystick? Yes, and here's how.
Hi RamjetR I am building a set of diy rudder pedals and I want to use a Arduino micro for this. The 10bit code you have created is perfect for what I want. Would it be difficult to modify the code to only have Z axis? I plan on using a hall sensor as the input as shown here http://www.simpits.org/geneb/?p=299RamjetR wrote:Spent several days putting this together and since most of the knowledge I used came from here. It's good to give back to the community.
8 Axis, 10bits per axis
8 Buttons (active low)
Used to upgrade Logitech G25/G27 Pedals from 8bit to 10bit resolution. Works great. Please read the comments in the file if your unsure. And note that you need to put the USBAPI.h file in the correct place as it doesn't seem to override from within the IDE... also the HID.cpp file works fine from the sketch folder... odd..
Anywho... here is what I have been working on.
Enjoy![]()
Ramjet.
Any info or help will be gratefully received!
-
- Posts: 4
- Joined: Mon Oct 26, 2015 7:40 pm
Re: Leostick Joystick? Yes, and here's how.
Hi,
Since I'm not a professional coder I will try to answer
In the original code (leoJoy10bit_RamjetX.ino) in line 49-59 you can set all the Axis to false except the zAxis. as shown below.
Since I'm not a professional coder I will try to answer

In the original code (leoJoy10bit_RamjetX.ino) in line 49-59 you can set all the Axis to false except the zAxis. as shown below.
Code: Select all
*/
bool xAxis_Enable = false;
bool yAxis_Enable = false;
bool zAxis_Enable = true;
bool xRotAxis_Enable = false;
bool yRotAxis_Enable = false;
bool zRotAxis_Enable = false;
bool throttle_Enable = false;
bool rudder_Enable = false;
bool hatSw1_Enable = false;
bool hatSw2_Enable = false;
bool buttons_Enable = false;
Re: Leostick Joystick? Yes, and here's how.
Yeah just as Piccolo said, just make true or false which axis you want to use..nimrod77 wrote: Hi RamjetR I am building a set of diy rudder pedals and I want to use a Arduino micro for this. The 10bit code you have created is perfect for what I want. Would it be difficult to modify the code to only have Z axis? I plan on using a hall sensor as the input as shown here http://www.simpits.org/geneb/?p=299
Any info or help will be gratefully received!
Also, I think I left in there a Invert option to swap the input depending on how you wire up your rudder pedals. Sometimes it's just easier to invert it in software than to rewire something.
I haven't used any hall effect sensors in years... last time I did it was a Allegro 3144 Hall effect switch (schmitt triggered). It worked great as a switch but you want an analogue output from a hall effect sensor.
So take a look in the code and you'll see where each axis does a analogRead(A0). Just change the A0 to match the pin your putting your hall effect sensor on. It's an analog pin so as long as your sensor is giving out a range of 0V to 5V you are good to go. You may just want to take out the PULLUP declaration in the pin setup. What the PULLUP does is enable the internal pull up resistor... I think from memory it's about 22Kohm and shouldn't effect your external sensor voltage input. But if it is, just make that an INPUT, not INPUT_PULLUP.
I'll look at the link as it's something I could also use to with my racing sim stuff so definitely interested to read up and have a go myself.
Re: Leostick Joystick? Yes, and here's how.
I'm glad you could follow it and it's helping peoplepiccolo456 wrote:Thanks Ramjet.
I found your code really useful.
I am a beginner coder, so bear with me. I am building a Controller for my stationary bike, currently the brake leaver is the throttle.
I would like to use a hall effect sensor to measure the crank speed as a throttle (below 60rpm = stop 90rpm and up = max speed).
do you think the arduino will be able to handle all the instructions and watch the RPM. I have found some code to do the rpm measurement I just dont know where and how to add it to your code.

Okay, check out where each axis does it's analogRead(A0)? Well that is where you would assign the value of your RPM...
Say for example, you have a piece of code which is taking an input from your sensor. I'm guessing a pulse of some sort? And you end up with a variable with the current value of the RPM in it?
Take a look at how I would integrate it below. Keep in mind I don't know the code your using to read an RPM value so I just made the assumption that you have some code and end up with a variable which has the value ready to put into the gamepad code.
Code: Select all
joySt.throttle = 512; // Presets this value i.e. Defaults to 512 value if it is not enabled.
if(throttle_Enable) { // If enabled then update the value from the analog pin
if(rpm < 90){ // if rpm is less than 90, set the throttle to zero.
joySt.throttle = 0;
}
if (rpm >= 90){ // if rpm is greater than 90rpm then we want to tell the PC we are moving ... and scale it nicely too :)
//normal output?
int throttleVal = (map(rpm,minRPM,maxRPM,0,1023));
// Invert the output?
if(throttle_Invert) { // If Invert is enabled, then update the value inverted... ie swap max/min value
int throttleVal = (1023) - (map(rpm,minRPM,maxRPM,0,1023)); // scales the throttle value of rpm between the minRPM and maxRPM to to the scale needed by the throttle axis in game
}
joySt.throttle = constrain(throttleVal,0,1023);// Final constrain to make sure the output to the game is correctly limited to 10bits.
}
}
Re: Leostick Joystick? Yes, and here's how.
nimrod77 wrote:Hi RamjetR I am building a set of diy rudder pedals and I want to use a Arduino micro for this. The 10bit code you have created is perfect for what I want. Would it be difficult to modify the code to only have Z axis? I plan on using a hall sensor as the input as shown here http://www.simpits.org/geneb/?p=299RamjetR wrote:Spent several days putting this together and since most of the knowledge I used came from here. It's good to give back to the community.
8 Axis, 10bits per axis
8 Buttons (active low)
Used to upgrade Logitech G25/G27 Pedals from 8bit to 10bit resolution. Works great. Please read the comments in the file if your unsure. And note that you need to put the USBAPI.h file in the correct place as it doesn't seem to override from within the IDE... also the HID.cpp file works fine from the sketch folder... odd..
Anywho... here is what I have been working on.
Enjoy![]()
Ramjet.
Any info or help will be gratefully received!
Thanks for the reply Ramjet. All very clear and after playing with the sketch you provided. I can not see any inversion code however. Where would I put that code if I needed to?
Thanks for all your work.