0

I'm trying to make a joystick. The idea is that I will get an analog input from a pot by arduino I'll send the value to visual studio via serial port and finally I have to put this value as joystick analog input to the system so I'll be able to use it in the games but I couldn't find the command to do this.

I found a command like SendKey and I tried it but the result isn't what I needed. For example if I use the SendKey.Send("a") the car in the game acts fully turned to left. I want to use the potentiometer like an analog stick. If I turn the pot half way, the steering wheel will turn half way.

Ron Beyer
  • 11,003
  • 1
  • 19
  • 37
srkn
  • 35
  • 3
  • You might be better off having the arduino emulate a serial joystick itself. Also you are not sending it to Visual Studio, you are sending it to a program you just happened to write in Visual Studio. You could have used notepad to write it, Visual Studio has nothing to do with this. – Scott Chamberlain Aug 13 '15 at 20:57
  • Which arduino is it? If its one of the USB ones you can make it act like a HID device. Kind of like this: https://code.google.com/p/unojoy/ – Ron Beyer Aug 13 '15 at 20:58

1 Answers1

1

I think it would be definitely a better idea to implement a HID joystick profile instead handling serial data and create a virtual joystick in windows via C#. But if it is very important for you to have a virtual joystick check the vJoy project.

As I mentioned above, I would implement a HID Joystick profile. You can do that in many ways and it is not complicated at all.

For example use a Arduino board that have a native supports of joystick HID profile (such as the Teensy Boards), use a Arduino which you can modify to use a Joystick library (e.g. USBAPI) (like the Arduino Leonardo boards, instructions see here), or use a compatible bluetooth module with HID firmware, such as the RN42 HID from Sparkfun. There are several example codes for that application in the web.

user3704293
  • 1,026
  • 2
  • 16
  • 28