Leostick Joystick? Yes, and here's how.

A shrunk down Leonardo-compatible board, thumb drive sized with native USB support. [Product info]
RamjetR
Posts: 5
Joined: Wed Jan 02, 2013 10:44 am

Re: Leostick Joystick? Yes, and here's how.

Post by RamjetR » Sun Nov 01, 2015 4:05 am

nimrod77 wrote:
nimrod77 wrote:
RamjetR 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.
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!

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.
How to invert the input to the output...

Code: Select all

        
        joySt.rudder = 512; // Defaults to centre value if it is not enabled.
        if(rudder_Enable) { // If enabled then update the value from the analog pin
          joySt.rudder = analogRead(A0); // Default A1 pin
          if(rudder_Invert) { // If Invert is enabled, then update the value inverted... ie swap max/min value
            joySt.rudder = (1023) - analogRead(A0); // Default A0 pin
          }
        }

piccolo456
Posts: 4
Joined: Mon Oct 26, 2015 7:40 pm

Re: Leostick Joystick? Yes, and here's how.

Post by piccolo456 » Tue Nov 03, 2015 1:51 pm

RamjetR wrote:
piccolo456 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.
I'm glad you could follow it and it's helping people :)

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. 
          }
        
        }
So from your spec, I figured anything less than 90rpm was essentially zero... and anything 90 or more is some kind of throttle. Also you can scale the minimum and maximum value of RPM to scale it nicely to 0-1023

Thanks, I will see if I can implement that part into my code.
Do you think I should use an interrupt for the RPM sensor so that I don't miss a pulse, or will that mess up the rest of the code.
I assume I can just try and see what happens.

RamjetR
Posts: 5
Joined: Wed Jan 02, 2013 10:44 am

Re: Leostick Joystick? Yes, and here's how.

Post by RamjetR » Wed Nov 04, 2015 12:14 pm

piccolo456 wrote: Thanks, I will see if I can implement that part into my code.
Do you think I should use an interrupt for the RPM sensor so that I don't miss a pulse, or will that mess up the rest of the code.
I assume I can just try and see what happens.
I'm assuming your not doing much in the interrupt other than incrementing your counter in your global variable keeping count of the RPMs? It should cause any problems. Just try not to use delays in your interrupts to make your that your in and out of the interrupt as fast as you can and can get back to the main loop.

Worst case scenario, if you're doing too much away from the main loop. You might see a small delay in getting the updates to the PC.

For a point of reference, the final version of my 10Bit pedal adaptor I made for a few of my OZNZSimRacing.com forum members Logitech pedals. I am able to update the PC at over 400fps whilst still sending data out of the serial port. So, it should be fine.

piccolo456
Posts: 4
Joined: Mon Oct 26, 2015 7:40 pm

Re: Leostick Joystick? Yes, and here's how.

Post by piccolo456 » Fri Nov 06, 2015 1:27 pm

thanks for all your help. That racing forum looks like fun.

auron-muc
Posts: 1
Joined: Sat Dec 19, 2015 1:48 pm

Re: Leostick Joystick? Yes, and here's how.

Post by auron-muc » Sat Dec 19, 2015 3:09 pm

I took the liberty and converted the code to a library working with the newest Arduino-IDE which includes the Pluggable HID classes.

See https://github.com/auron-muc/arduino-leonardo-joystick

I heavily modified the HID Descriptor- basically rewrote it from scratch - and allow a variabe (compile time defines) amount of axes, buttons and hats.

please let me know what you think.

Cheers,
Tobias

waveform
Posts: 1
Joined: Tue Apr 12, 2016 9:27 pm

Re: Leostick Joystick? Yes, and here's how.

Post by waveform » Tue Apr 12, 2016 9:36 pm

RamjetR 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.

Used to upgrade Logitech G25/G27 Pedals from 8bit to 10bit resolution.
Thanks a lot for sharing this Ramjet, I also will be using this for my G27 plus a hydraulic handbrake when I have it built.

Have you got another .ino file with code that you specifcally use for your G25/G27 Pedals?

The reason I ask is because each pedal has a deadzone on both sides of the axis, and I was wondering if you eliminated this deadzone in your own code?

I would also like to invert each axis but I have no coding experience, just know how to edit values and such, as most games need to have the invert option enabled the way the code you shared is setup currently.

If anyone else reading this can help out too I would really appreciate it.

I will be making an instructable of my project just to help others out also.

Thanks for your time,
Waveform.



linmangmu
Posts: 106
Joined: Thu Jan 25, 2018 3:24 am

michael kors factory outlet

Post by linmangmu » Thu Jan 25, 2018 5:16 am

lebron soldier 10
michael kors outlet
adidas online shop
air jordan shoes
mlb jerseys
fenty puma
golden goose
roshe shoes
kate spade outlet online
nike basketball shoes
tory burch shoes
hogan outlet
michael kors outlet online
yeezy shoes
jordan shoes
yeezy boost 350
longchamp outlet
kobe 9
nike air force 1
asics kayno
links of london
moncler jackets
nike lebron soldier 11
off white hoodie
michael kors outlet online
basketball shoes
adidas tubular
lebron 14 shoes
lacoste outlet
authentic jordans
nike zoom running shoe
yeezy boost
kyrie 3 shoes
cheap jordans
harden shoes
adidas superstar
michael kors outlet
yeezy boost
longchamp
roshe run
prada sunglasses
michael kors handbags
michael kors factory outlet
http://www.kobebasketballshoes.us.com
yeezy boost 350 v2
nike huarache
led shoes
pandora charms
longchamp outlet
curry 3
yeezy boost
true religion
longchamp
kobe 9
timberland outlet
nike polo
yeezy shoes
chrome hearts
adidas stan smith
yeezy boost 350 v2
dior sunglasses
tom ford sunglasses
cartier bracelet
cheap nfl jerseys
paul george shoes
air jordan
goyard bags
adidas stan smith shoes
lebron 13 shoes
yeezys
cheap mlb jerseys
kobe basketball shoes
adidas gazelle
westbrook shoes
kyrie 4
tom ford eyewear
golden goose outlet
adidas outlet
michael jordan shoes
jordan 11 retro
red bottoms
air force 1
cheap jordans
longchamp bags
led shoes for kids
kyrie 3
adidas tubular
ferragamo belts
nike roshe run
100% real jordans for cheap
adidas store
kevin durant shoes
yeezy boost 350
derrick rose shoes
nike roshe uk
lacoste polo
nike air max 90
air jordan
yeezy boost 350
adidas ultra
asics shoes
longchamps
lebron 14
nike dunk shoes
gucci belt
reebok outlet
nike mercurial
adidas nmd r1
yeezy boost 350
brady jersey
pandora charms
goyard bags
paul george shoes
chrome hearts online
nike air huarache
lacoste online shop
nike air force 1
adidas superstar shoes
longchamp handbags
kobe shoes
yeezy boost 350
converse shoes
michael kors outlet online
michael kors uk
yeezy boost 350 v2
adidas nmd
http://www.kobeshoes.uk
pandora jewelry
caterpillar boots
off white
adidas online shop
adidas eqt
retro jordans
goyard handbags
retro jordans
prada glasses
cheap jordans
balenciaga sneakers
nike air huarache
air max 2017
adidas stan smith
adidas nmd
longchamp handbags
michael kors handbags
golden goose sneakers
atlanta falcons jersey
nike roshe one
fitflops
nhl jerseys
gucci belts
adidas shoes
longchamp bags
yeezy boost 350
balenciaga shoes
adidas tubular
yeezy
nike air force
adidas ultra boost
adidas tubular shadow
links of london
adidas neo
moncler outlet
yeezy shoes
yeezy boost
nike air zoom
true religion jeans
falcons jersey
timberland boots
off white clothing
air jordans
christian louboutin shoes
nike zoom
birkin bag
hermes belts
real jordans for sale cheap
kyrie 4
kobe byrant shoes
ferragamo belt
converse outlet store
jordan shoes
vans shoes
hermes belt
christian louboutin
nike dunks
cheap basketball shoes
kd shoes
tory burch shoes
yeezy boost 350 v2
hermes handbags
kyrie shoes
supreme clothing
michael kors outlet store
adidas superstar shoes
jordan retro 6
fitflops
converse outlet
longchamp bags
tory burch outlet
air max 90
jordan retro 12
yeezys
af1
lacoste outlet
john wall shoes
nfl jerseys
off white clothing
adidas superstar
ultra boost
nba jerseys
nike air force
air jordan 13
vibram fivefingers
adidas outlet online
asics gel kayano
kobe sneakers
nike air zoom
james harden shoes
balenciaga sneakers
jordan 13
adidas tubular
nmd
michael kors outlet
bape hoodie
nike lebron soldier 10
adidas nmd
nike air max
yeezy shoes
curry shoes
lebron shoes
golden goose
kyrie irving shoes
chrome hearts
yeezy boost 350 v2
ysl bags
adidas outlet
yeezy boost 350
cheap jordans
air max 90
patriots jersey
kobe 11
nike air max
lebron 15
yeezy shoes
chrome hearts
nike air max 2018
true religion
ysl handbags
balenciaga shoes
pandora jewelry
cheap nba jerseys
nike free
yeezy shoes
red bottom shoes
longchamp longchamps
adidas ultra boost
adidas yeezy
nike huarache
cat boots
chrome hearts online
nike foamposite
damian lillard shoes
new england patriots jersey
kobe basketball shoes
van cleef
stephen curry shoes
nike air huarache
nike air max 2017
birkin bag
nike polo shirts
adidas ultra boost
jordan retro
golden goose sneakers
adidas tubular shadow
curry 3 shoes
jordan 6
hermes belt
vibram five fingers
curry 4
van cleef arpels
hogan outlet online
asics running shoes
nmd
nike hyperdunk 2017
air max 2016
michael kors outlet
retro jordans
reebok shoes
kobe shoes
jordan shoes
kate spade handbags
cheap jordans
jordan 12
links of london sale
jordan shoes
nike huarache
yeezy
lebron soldier 11
michael kors handbags
longchamp handbags
air yeezy
hermes belts for men
vans shoes
kobe 11
golden goose
lebron 15
calvin klein outlet online
links of london outlet store
vans outlet
adidas yeezy
adidas ultra boost uncaged
air jordan shoes
yeezy boost
louboutin shoes
curry 4
hermes belt
goyard handbags
kobe shoes
michael kors outlet
nike free run
adidas yeezy boost
jordan 11
hermes birkin
nike roshe run
nike zoom
nike huarache
fitflops sale clearance
adidas nmd runner
calvin klein outlet
dior glasses
true religion outlet
100% real jordans for cheap
yeezy boost 350
jordan shoes
led shoes
adidas nmd
russell westbrook shoes
longchamp bags
bape hoodie
air max 2018
adidas outlet online
adidas outlet
nike air max 90
Kanye West shoes
russell westbrook shoes
kate spade outlet
adidas nmd
birkin bag
michael kors
longchamp sale
air force 1
light up shoes
nmd
nike football boots
jordan 4
louboutin shoes uk
michael kors handbags
cheap jordans
converse outlet
michael jordan shoes
lebron 13
air max
adidas stan smith sneakers
nike hyperdunk
basketball shoes
supreme hoodie
lebron james shoes
pandora bracelet


Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests