Arduino vJoy Feeder

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.

nobody around to say something?

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

or unmodified from the author's page:

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.

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.

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.

Hi, recently I published a tool that I've made for my own purposes:

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~

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.

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.

I've implemented Bit-mapped Buttons. Now you can command 16 buttons with one channel. Check it out:

1 Like

You are awesome man.This is the most comprehensive open source package i could find for arduino Joystick interfacing .All other sources provide hex only .Is there any way that your application be developed to transmit force feedback back from steering back to arduino with vjoy(the vjoy sdk has the required libs to get the data from game) if you could do that your app will be unbeatable.
There's a similar implementation in a french forum (DIY arduino forcefeedback steering wheel | PART 1 - YouTube ,http://www.racingfr.com/forum/index.php?showtopic=49848 ) but they provide only the hex file for arduino and it limits further development .

well, I may start a new topic, but I'm really hoping to hear from Clerick himself.

I have a game controller build, with 4 total joysticks, wired to an arduino nano v3 (old bootloader).

I want to use vjoy to play space simulator games like Starmade and Astrokill,,

I have a sketch (please excuse my terribleness with programming, I am not a programmer I just clicked around until figuring some things out) that reads my controls and prints them to the serial monitor.

I TRIED to follow your ibus instructions, but I don't know, (no.... JOY ..... ) I tried pasting the ibus.h and ibus.cpp to files in my libraries folder but first problem, no such ibus.h found,, second problem, I actually just don't know what I'm doing, or how to make ibus protocol, or if that's the best option anyway, to get vjoy. I think that once vjoy sees my inputs, basically everything else works automatically,,, vjoy already shows up in my game options menus.

#include "ibus.h"
#define UPDATE_INTERVAL 10
#define BAUD_RATE 115200

Ibus ibus(20);

void setup() {
// put your setup code here, to run once:

pinMode(5,INPUT);
pinMode(6,INPUT);
pinMode(7,INPUT);
pinMode(8,INPUT);
pinMode(9,INPUT);
pinMode(10,INPUT);
pinMode(11,INPUT);
pinMode(12,INPUT);
pinMode(13,INPUT);
pinMode(14,INPUT);
pinMode(15,INPUT);
pinMode(16,INPUT);
Serial.begin(BAUD_RATE);
}

void loop() {
// put your main code here, to run repeatedly:
int buttonB = digitalRead(5);
int buttonA = digitalRead(3);
int buttonX = digitalRead(2);
int buttonY = digitalRead(4);
int buttonR1 = digitalRead(6);
int buttonR2 = digitalRead(7);
int buttonL1 = digitalRead(9);
int buttonL2 = digitalRead(8);
int buttonH1 = digitalRead(11);
int buttonH2 = digitalRead(12);
int buttonH3 = digitalRead(10);
int buttonH4 = digitalRead(13);
int stickOneX = analogRead(A1);
int stickOneY = analogRead(A0);
int stickTwoX = analogRead(A2);
int stickTwoY = analogRead(A3);
int stickThreeX = analogRead(A5);
int stickThreeY = analogRead(A4);
int stickFourX = analogRead(A7);
int stickFourY = analogRead(A6);

unsigned long time = millis();

ibus.begin();
ibus.write(buttonA);
ibus.write(buttonB);
ibus.write(buttonX);
ibus.write(buttonY);
ibus.write(buttonH1);
ibus.write(buttonH2);
ibus.write(buttonH3);
ibus.write(buttonH4);
ibus.write(buttonR1);
ibus.write(buttonR2);
ibus.write(buttonL1);
ibus.write(buttonL2);
ibus.write(stickOneX);
ibus.write(stickOneY);
ibus.write(stickTwoX);
ibus.write(stickTwoY);
ibus.write(stickThreeX);
ibus.write(stickThreeY);
ibus.write(stickFourX);
ibus.write(stickFourY);

ibus.end();

Serial.print("buttonA: ");
Serial.println(buttonA);
Serial.print("buttonB: ");
Serial.println(buttonB);
Serial.print("buttonX: ");
Serial.println(buttonX);
Serial.print("buttonY: ");
Serial.println(buttonY);
Serial.print("buttonH1: ");
Serial.println(buttonH1);
Serial.print("buttonH2: ");
Serial.println(buttonH2);
Serial.print("buttonH3: ");
Serial.println(buttonH3);
Serial.print("buttonH4: ");
Serial.println(buttonH4);
Serial.print("buttonR1: ");
Serial.println(buttonR1);
Serial.print("buttonR2: ");
Serial.println(buttonR2);
Serial.print("buttonL1: ");
Serial.println(buttonL1);
Serial.print("buttonL2: ");
Serial.println(buttonL2);
Serial.print("stickOneX: ");
Serial.println(stickOneX);
Serial.print("stickOneY: ");
Serial.println(stickOneY);
Serial.print("stickTwoX: ");
Serial.println(stickTwoX);
Serial.print("stickTwoY: ");
Serial.println(stickTwoY);
Serial.print("stickThreeX: ");
Serial.println(stickThreeX);
Serial.print("stickThreeY: ");
Serial.println(stickThreeY);
Serial.print("stickFourX: ");
Serial.println(stickFourX);
Serial.print("stickFourY: ");
Serial.println(stickFourY);

time = millis() - time;
if(time < UPDATE_INTERVAL)
delay(UPDATE_INTERVAL - time);
}

ok, I went with editing the sample sketch, and it appears to be working for me. I need to now try on my gaming computer, but it looks like it's going to work!! thanks.

Hey Guys, I've been trying to make the vJoy project posted by clerick but I can't understand at all how to merge the feeder files posted with the vJoy driver. Any idea?