Jump to content

F16 'dobber' switch or DCS switch DIY


eversman0078

Recommended Posts

Maybe this new thread can be helpful for everyone who wants to build the ICP for the Viper and doesn’t have a lot of knowledge, like me, for writing code and it is a really cheap solution.

 

This is my first thread on any forum whatsoever, so if I made some mistakes, please forgive me.

 

Last month I bought an ICP for the Viper from Hispapanels for assembling the first part of my ‘desktop’ cockpit. In other words, I will only have the most important panels on my desk so I can cut back on the use of the mouse and keyboard.

 

For the ICP, I followed the thread from Tekkx and Hansolo for building a matrix and using DCS-Bios, so you can spare some pins on your Arduino board. This was a really helpful thread for getting started.

 

https://forums.eagle.ru/showthread.php?t=195285

 

 

I got all my buttons and switches working, exept the ‘dobber’ or DCS switch gave me a lot of headaches.

 

After looking up and reading a lot of instructables, I endend up with MHeironymus joystick library. So I bought an analoge joystick (1€ in China), an Arduino pro micro(32u4 chip, 6€ for a clone) because I thought it was the easiest way of making a ‘dobber’ switch.

 

After a lot of trial and error, I have found a quite simple solution thanks to Aldrinos for asking and MorganS for providing a working code on the Arduino forum.

 

If you use the Arduino micro with the joystick library it will show up in windows as a game controller and you can assign any key you want for 'up-down-rtn-seq' in the controls menu in DCS. So basically it adds an extra input device, besides the keyboard and Hotas in DCS.

 

https://forum.arduino.cc/index.php?topic=643880.0

https://github.com/MHeironimus/ArduinoJoystickLibrary

 

 

I’ve added the first 4 lines myself. I believe they are necessary for the Arduino to show up in windows 10.

 

The letters ‘h’, ’d’, …. in Keyboard.press('h'); is one of the keys I assigned in DCS control menu.

 

This is my working code:

 

#include <Joystick.h>

#include <Keyboard.h>

// Create Joystick
Joystick_ Joystick;

const int pinXAxis = A0;
const int pinYAxis = A2;

const int middleX = 512;
const int middleY = 512;
const int leftThreshold  = middleX - 256;
const int rightThreshold = middleX + 256;
const int upThreshold    = middleY - 256;
const int downThreshold  = middleY + 256;
const int hysteresis = 32;

void setup() {
}
void loop() {

 int rawX, rawY;
 rawX = analogRead(pinXAxis);
 rawY = analogRead(pinYAxis);

 if(rawX < leftThreshold - hysteresis) Keyboard.press('h');
 if(rawX > leftThreshold + hysteresis) Keyboard.release('h');

 if(rawX > rightThreshold + hysteresis) Keyboard.press('d');
 if(rawX < rightThreshold - hysteresis) Keyboard.release('d');

 if(rawY < upThreshold - hysteresis) Keyboard.press('y');
 if(rawY > upThreshold + hysteresis) Keyboard.release('y');

 if(rawY > downThreshold + hysteresis) Keyboard.press('r');
 if(rawY < downThreshold - hysteresis) Keyboard.release('r'); 
}

joystick.thumb.jpg.5aa1d5c63453d92a5e7538ff701b1936.jpg

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

this week I got 2x minijoys for that same usage, thanks for sharing ;)

i5 8400 | 32 Gb RAM | RTX 2080Ti | Virpil Mongoose T-50 base w/ Warthog & Hornet sticks | Warthog throttle | Cougar throttle USB | DIY Collective | Virpil desk mount | VKB T-Rudder Mk IV | Oculus Rift S | Buddy-Fox A-10 UFC | 3x TM MFDs | 2x bass shakers pedal plate| SIMple SIMpit chair | WinWing TakeOff panel | PointCTRL v2 | Andre JetSeat | Winwing Hornet UFC | Winwing Viper ICP

FC3 - Warthog - F-5E - Harrier - NTTR - Hornet - Tomcat - Huey - Viper - C-101 - PG - Hip - SuperCarrier - Syria - Warthog II - Hind - South Atlantic - Sinai - Strike Eagle

Link to comment
Share on other sites

  • Recently Browsing   0 members

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