Jump to content

an Arduino USB HID controller, composite USB controller


overpro

Recommended Posts

Overpro,

 

First, thank you for taking your time to create this sketch and get it working for those of us without programming skills.

 

I've had a Mega2560 for three years now, and have not been able to find a long term use for it until now.

 

 

With that said, I uncommented the analog inputs line and programmed the Arduino with the sketch, and then flashed it to appear as a joystick.

 

Buttons are working great, but my analog inputs are not.

 

I hooked up a Parallax 27800 two axis joystick to Analog pins 0 and 1 with 0 being the Up/Down axis and 1 being the Left/Right axis.

 

The movement of the stick is detected, but it is not working correctly.

 

When the stick is at rest, the system shows the joystick response as being maximum.

When I move the stick to the right, the response meter starts at 0 and moves up to the 50% mark.

 

When I put it at rest, it goes back down to 0 and then maximizes at 100%.

When I move the stick to the left, it drops down from 100% to 50%. At rest, it goes back to 100%.

 

Every potentiometer I have hooked up, no matter what brand or resistance level exhibits this same characteristic.

 

Help?

 

Well, please have a try on this

the current analogRead is :

joyReport.axis[ind] = map(analogRead(54+ind), 0, 1023, -32768,32767 );

 

try changed the code to

joyReport.axis[ind] = analogRead(54+ind) << 6;

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

I did not expect to see a response from you for a while, so I was very surprised to see a post here. Thanks for the very prompt reply!

 

The updated sketch seems to have resolved the issue.

I'm testing it now, and will try adding the other two axis joystick to the arduino tonight.

Link to comment
Share on other sites

  • 2 weeks later...

programming software and device name change

 

hello , first THANK YOU very much for this joystick project it really help me with my home cockpit building

 

i want to know how to change the name of the device to show front Panel A10 instead for C.V.P joystick this really will help me assign several joysticks to several game since i am using FSX and DCS and also BMS

 

let me know what software i need to download in order to work of the frimware

 

 

please help me

 

Thank You

Link to comment
Share on other sites

hello , first THANK YOU very much for this joystick project it really help me with my home cockpit building

 

i want to know how to change the name of the device to show front Panel A10 instead for C.V.P joystick this really will help me assign several joysticks to several game since i am using FSX and DCS and also BMS

 

let me know what software i need to download in order to work of the frimware

 

 

please help me

 

Thank You

Please check the top post, there are some instructions on how to compile the firmware, if you want to change the name check Descriptors.c ProductString definition, and I think the PID value in DeviceDescriptor should also be changed.

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

thank yo very much for the reply

 

sorry that i didn't mention that before but i am new to all this electronics

 

here is what i did till now,

 

i am using windows 8.1

 

i download Atmel Studio 6.2 and created a new project i transfer to the new folder project all the file that i download for the big joystick project to the same project folder (here is the folders i downloaded "arduino" "Debug" "firmwares" "LUFA") the lufa folder i download base on the instruction i got on the previous post

 

after i created a new folder in the Atmel Studio i include all the downloaded folders in the project but when i compile (this is what i am doing to get the .hex file right ?) i get an error that it can't find the usb drivers on lufa folder

 

please help and also let me know if i am doing something wrong

i attach some pictures

THANK YOU !!!!!

 

joystick1.jpg

joystick2.jpg

Link to comment
Share on other sites

Oresther, one thing to try would be to change all the <LUFA/Drivers/USB/xxxx.h> to "../LUFA/Drivers/USB/xxx.h" . Currently avr studio is looking in the wrong place for those files. The < > symbols wrapped around the paths for the header files are telling avr studio that those files are located with the avr studio library files, and to look there. The " " will tell avr studio to look in the project source code folder and and the ../ will tell avr studio to jump up one directory from the source directory and look there. Backup existing folder structure just in case i'm talking crap.

Link to comment
Share on other sites

You need to define F_USB, you will need to look through the files and you should be able to see. Can try in usb.h or in the main source file at the top, it may be one of the cofiguration fuses that needs to be set to get the chip up and running.

Link to comment
Share on other sites

F_USB is defined in the makefile that comes with source code, it looks as though you are supposed to build the code using the supplied makefile. When you create a project with avr studio it creates its own makefile, so now a lot of the pre defined constants/symbols are not defined. You will either have to create a new header file with all the missing defines and try and fix any other compilation errors or build the project as was intended by using the included makefile.

Link to comment
Share on other sites

  • 3 weeks later...

input questions

 

Hi there everybody, I got this joystick to work and it's working perfectly thank you overpro, now I have a question that maybe some of you got a solution for it , since we all know that windows will not get more than 32 buttons per joystick so fsx or bms will not get all the buttons to work only the first 32 (xplane work perfectly ), my question is there is any way to divide this board to 8 joystick with 32 buttons to make it work with all the games? Or any type of a software that will do it ?

Please if someone have an idea please let me know

thank you

Link to comment
Share on other sites

my question is there is any way to divide this board to 8 joystick with 32 buttons to make it work with all the games? Or any type of a software that will do it ?

Please if someone have an idea please let me know

thank you

 

It's possible with the right USB descriptor. The current implementation here is a composite device consisting of two 128-button joysticks. It could be changed to show up as four 32-button joysticks instead.

 

That way you can get more than 32 buttons to applications that use the Windows Multimedia API instead of DirectInput. However, any such devices will be limited to a maximum of 16 joysticks.

 

I tried, once you have 16 game controllers connected, new ones just don't show up in the Control Panel. In my USB Rotaries experiment (which used V-USB), I programmed the ATMega168 microcontroller to appear as an arbitrary number of 32-button, 8-axis joysticks.

Link to comment
Share on other sites

Hi there everybody, I got this joystick to work and it's working perfectly thank you overpro, now I have a question that maybe some of you got a solution for it , since we all know that windows will not get more than 32 buttons per joystick so fsx or bms will not get all the buttons to work only the first 32 (xplane work perfectly ), my question is there is any way to divide this board to 8 joystick with 32 buttons to make it work with all the games? Or any type of a software that will do it ?

Please if someone have an idea please let me know

thank you

 

For FSX check out Linda- http://fs-linda.com/, that enables you to use 128 buttons in FSX. I'm using it in the helicopter, works a treat.

 

cheers

 

Peter

Link to comment
Share on other sites

  • 2 weeks later...
Hi Peter, many thanks for your effort on testing this, I think I have understand the point and uploaded the code to github,

The arduino code was changed, no firmware change for ATMega16u2.

please have a try when you are free.

 

https://github.com/calltherain/ArduinoUSBJoystick/commit/0f7146c27b83f465fafaaf6b1d35ad45ab0cb2b1

 

Hi OverPro

 

Its been the longest time, but I'm back working on panels with Rotary Encoders, the great news is the code works really well, thanks for getting that right.

 

Cheers

 

Peter

Link to comment
Share on other sites

  • 1 month later...

Hi Guys

 

Little fyi - Very close to having the wiring complete in the pit, one thing I did run into was the need to add some pull-up resistors as the cables lengthened, even though the sketch enables pull-up resistors, found I needed to add 10K pull-ups to the columns.

 

cheers

 

Peter

Link to comment
Share on other sites

  • 3 weeks later...

Overpro you are awesome!!!! I just got this up and running. I know slightly less than jack and sh*t about electronics but your tutorial was easy enough that even a dummy like me could figure it out. You just saved me a lot of money. Thanks again for putting this out to the community!

 

Sage

VFA-25 Fist of the Fleet

[sIGPIC][/sIGPIC]

Virtual Carrier Strike Group One | Discord

Link to comment
Share on other sites

  • 4 weeks later...

Sync Error !

 

Hello... I´m trying to use this amazing project.

 

But i´m with some problem, i hope someone can help me. In first moment i have very Drift problem. I increase the original CWCCWDriftTimeLimit = 20 , to 50 , and now is better.

 

But i have other problem, that i can´t solve. Turning left or right the encoder, at some point, the button stay ON directly, it is necessary to give few turns get back to normal. Like attached image.

 

Someone here had this problem ?

 

I´m using encoder with this specification:

Position: 20

Pulse: 20

Max. Rating: 10 mA 5 VDC

img1.jpg.6e40dfe9402c0d43ea2e785d66bf212a.jpg

rotary-encoder-21950-MLB20221802858_012015-O.jpg.7b1e31f56f9ccc989bc1ca59ee17c918.jpg

Link to comment
Share on other sites

The other thing it might be, are you sure the encoder is in the range of ports enable for encoder, I've seen the 'stuck' button thing when an encoder is connected to any ordinary port, also is that the only device you have connected, if not are you using diodes?

 

cheers

 

Peter

Link to comment
Share on other sites

Hello... I´m trying to use this amazing project.

 

But i´m with some problem, i hope someone can help me. In first moment i have very Drift problem. I increase the original CWCCWDriftTimeLimit = 20 , to 50 , and now is better.

 

But i have other problem, that i can´t solve. Turning left or right the encoder, at some point, the button stay ON directly, it is necessary to give few turns get back to normal. Like attached image.

 

Someone here had this problem ?

 

I´m using encoder with this specification:

Position: 20

Pulse: 20

Max. Rating: 10 mA 5 VDC

 

 

Well, there might be some issues in the code, let me get some 20 pulses encoders first and have it tested. I will provide some updates later.

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

But i have other problem, that i can´t solve. Turning left or right the encoder, at some point, the button stay ON directly, it is necessary to give few turns get back to normal. Like attached image.

 

 

also is that the only device you have connected, if not are you using diodes?

 

cheers

 

Peter

 

Hi riclamer, Just as Peter mentioned, please can you confirm if you have multiple encoders attached without the diodes?

There are 3 pins on the encoders A,B and Common

Consider this situation: Let's attach 2 encoders common pin to row 1 and 2 respectively, and both pin A connected to Column 1 and both pin B connected to Column 2, if no diodes used on pin A,B it might lead to this issue.

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

  • 1 month later...

LEd ?

 

For start , Thanks for your work overpro ;-)

 

I wanted to know if there are a simple possibility to include led control ?

The idea is to light on a led when you push a momentary switch and and light off when you push it a second time ( for know the state of the command you push).

 

for information, i start to make a front panel of my homemade play seat for Star citizen.

 

Thanks for your answer.

Link to comment
Share on other sites

  • 1 month later...

This is exactly what im looking for.

 

I was looking for an inputmodul, which gives me really much buttons as Joystick for the PC.

 

So without the timelimited pins i have calculated about 192 usable buttons.

I am building a Pad, which has 100 Buttons, needed for Star Citizen.

 

So my question:

Is there any way to use pin 2 - 21 and pin 54 - 69 for LEDs if Joystick button 32 upwards are toggled, to light those LEDs?

 

Just for visual information, to know Gear is down or Hatch is open or something like this.

Because the first buttons wont work as buttons, they are just for toggle-switches, which i dont need.

 

 

And Pins 54 - 69 are those Analog-Inputs, which can be used to digital outputs, too. I dont need any analogue axes.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...