Go Down

Topic: Arduino vJoy Feeder (Read 258 times) previous topic - next topic

afy

I am not sure about that is the right place to ask it but. I am working on a homemade cockpit and need roughly 6 axis, 48 buttons to replicate a viper pit, and I want to do it with an arduino mega. So far so good. I found a driver interface that makes anything joystick when they are not, named as vJoy. The problem is vJoy needs a feeder application that reads the serial and sends it to the virtual joystick, the way that I barely know to do with c/c++. I found some other ways to use ino as hid/joystick like reprogramming 32u4 bootloader, with mega, I don't have that option. If anybody has some knowledge on my project, I am very exited to listen it.

First of all, the purpose on why I choose that way to do is
  • I want to find a way to convert an arduino to joystick in a proper way. So it could help people to solve their similar problems
  • If I accomplish mine, I am also thinking about making my feeder public, useful and improvable, usable with any arduino in market


I don't have much C/C++ experience but can say i am pretty good at programing with java, if there is another way to do with it, it will be awesome too.

I tried to use vJoy SDK, cannot even manage to successfully compile it, what a disaster, I want to know is there any other good reference than the default SDKs readme.pdf file.

Like i said, I want it to be public, because I am having hard time to find a way to use serial devices as hid, yes the serial that makes an arduino so powerful, I am very surprised about can't find any generic way to do it. If you guys know any other way to do it, also want to know that as well.

afy

nobody around to say something?

hc625ma

you can use UnoJoy or MegaJoy. Grab modified to 6 axes software from here:

https://www.thingiverse.com/thing:2775102

or unmodified from the author's page:

https://github.com/AlanChatham/UnoJoy/tree/master/MegaJoy

It is a slightly modified UnoJoy software, 6 axes, up to 13 buttons. You can also try stock MegaJoy example firmware. UnoJoy has the 8bit resolution (255 points), Mega joy can have up to 16bit (of which probably 10 can be used with stock mega ADC). I am working on the 10bit version of the UnoJoy now. The problem currently is that random spikes pop up when moving several axes simultaneously (i use it to fly helicopters). I am planning to solve this with either finding what causes this in software or using an external ADC for levers. You can look at my page on thingiverse, probably you will find something you like).

If you have smth like ch340 as USB2com chip, it may be a good idea to order a different board, like pro micro or Leonardo, or just a mega with 16u2 onboard.

MorganS

I would start with a Teensy. The support for HID devices is very good. Just download the TeensyDuino add-on to Arduino and start programming exactly like an Arduino.

The Teensy 2 series uses the same chip as the Arduino Micro. The Teensy 3 series use different chips with more capabilities.

All of the Teensies use the full USB interface, so you can have Serial and HID working simultaneously. You don't have to have any additional software on the PC.
"The problem is in the code you didn't post."

afy

that sounds awesome, thanks for the headsup @MorganS i already made a good progres with c++ feeder. it is more stable and reliable with easy to change code because you did not have to flash bootloader. definitely gonna check the teensy stuff right away.

clerick

#5
Feb 19, 2018, 09:08 am Last Edit: Feb 19, 2018, 09:29 am by clerick
Hi, recently I published a tool that I've made for my own purposes:
https://github.com/Cleric-K/vJoySerialFeeder

You need an arduino board. As far as the sketch requirements - any will do (Uno, nano ...). So your real hardware requirements are up to the number of digital/analog inputs you'll need.

Check out the Arduino example:
https://github.com/Cleric-K/vJoySerialFeeder/blob/master/docs/Arduino.md
This should give you a general idea.

Basically your arduino reads the inputs (analog and digital) and sends them over the serial port (using IBUS protocol) where vJoySerialFeeder reads them, maps them to joystick axes and buttons and feeds them to vJoy.

The positive side is that you won't need to reprogram the USB chip of your arduino - everything works over the standard USB serial port. You will, however, need vJoySerialFeeder to be running at all times (in contrast to a HID solution).

To make the arduino sketch work you'll have to make some very basic editing in the beginning - it is explained in the comments.

If you have any questions or problems I'll try to help.

Best~

afy

you are awesome dude. thats excectly what a was trying to do but i cannot build a generic solution. so far my code can can read from mega and send that data to vjoy but your solution is ready to go yet simple. of  course i have to chang that a bit to work with my hardware but thank you for your hard work, that saves a lot of precious time for me. you should consider publishing it with more loud that makes the people to find some cool stuff more easily.

clerick

I'll be glad if you can use it for your needs.

As I saw that your project requires a great number of buttons, I think that things can be optimized a little. Currently, buttons are implemented as regular channels (16-bit values) which are interpreted according to a threshold to decide the state of the button. This is the usual way things work in RC controllers for example. But in your case, as you have 48 buttons, 48 16-bit channels would be such a waste!

So I'll try to implement another type of Mapping, which will interpret the channel value as bit-map. Thus a single channel would be able to encode 16 buttons - one for each bit. You will need 3 channels for all 48 buttons.

I'll try to write the code these days.

clerick

I've implemented Bit-mapped Buttons. Now you can command 16 buttons with one channel. Check it out:
https://github.com/Cleric-K/vJoySerialFeeder

Go Up