Jump to content

Connect a PS/2 keyboard to your CDU with an Arduino and DCS-BIOS


FSFIan

Recommended Posts

thanks Peter, those i had to order, hopefully someday laser to cut 2mm aluminum in household garage will be a reality. I'm not sure i'm tracking your thought with a joystick. i went with keyboard since it is instant 100 buttons matrixed at cost of 10$ or below. but RPi has more USB connections so it can easily have a joystick as well. as the mater of fact i'm also working on AAP panel that will connect to RPi CDU board to share that that networked connection, and in case GPIO interupt code going to degrade CDU screen refresh times i will revert to using Joystick via onboard USB.

 

as far as EDA software hint thank you. kicad indeed is making me feel stupid. after several tries i did manage to build it properly, but the mentality of workflow I just can't get used to. while i could create a PCB example i still don't understand how to import DXF with physical button sizes and locations.

will be trying Diptrace

 

On the joystick, you may want to check out Overpros project it gives you a good sized matrix for the cost of an ArduinoMega.

http://forums.eagle.ru/showthread.php?t=117011

It'll give you a 16*8 matrix. I used it on my Jet Ranger project, and as I'm adding new panels on the A10C, they are being wired up to this.

 

Cheers

Peter

Link to comment
Share on other sites

 

[sIGPIC][/sIGPIC]
Win11x64, NVIDIA GeForce RTX 2080Ti, i5-8600K OC4.5 GHz, 120GB SSD INTEL 530, SAMSUNG SSD 850 EVO 250G, 1TB HDD WD RED, MSI Z370-A PRO, Cougar AQUA 360 CPU cooler, Kingston 2x32GB DDR4 3800MHz, 4K LG 50" Monitor, Meta Quest Pro VR, Orion2 HOTAS MAX,Orion Metal Flight Rudder Pedals (With Damper Edition), GAMETRIX KW-908 JETSEAT.

Link to comment
Share on other sites

Hiway, I will be using 6mm tacts for the double buttons (page, BRT, etc.). For the rest I will be using 8.5mm ones as they have travel and tactile click at the end. Aside of cost I tried to minimize backlight Led count - one LED per pair of buttons . but buttons aside its the button caps that I'm working on. Quite a thing...

Anton.

 

My pit build thread .

Simple and cheap UFC project

Link to comment
Share on other sites

  • 2 months later...

I haven't read all of those posts ahead (no time at all) but - on my own experiences - your lighting concept will work very well!!!

 

Your Screen-Solution is quite better than mine (VGA export by lua)

 

Hats off.

Manual for my version of RS485-Hardware, contact: tekkx@dresi.de

Please do not PM me with DCS-BIOS-related questions. If the answer might also be useful to someone else, it belongs in a public thread where it can be discovered by everyone using the search function. Thank You.

Link to comment
Share on other sites

  • 4 months later...

I wonder if any of these displays would be good options to use with the RPi for the CDU?

 

http://makersify.com/collections/raspberry-pi/products/adafruit-dpi-tft-kippah-for-raspberry-pi-ada2454 TFT Interface £11.70

or

http://makersify.com/products/adafruit-tfp401-hdmi-dvi-decoder-to-40-pin-ttl-breakout-without-touch HDMI to TTL board £19.80

 

with

http://makersify.com/products/adafruit-5-0-40-pin-800x480-tft-display-without-touchscreen

5" 800x480 TFT £24.30

or

http://makersify.com/collections/lcds-displays/products/adafruit-7-0-40-pin-tft-display-800x480-without-touchscreen 7" 800x480 TFT £29.70

 

The cheapest combo there comes to £36.

 

Alternatively this touchscreen connects without any additional boards.

http://makersify.com/collections/lcds-displays/products/adafruit-pi-foundation-pitft-7-touchscreen-display-for-raspberry-pi 7" touchscreen £49.50

 

I know 7" is too big but perhaps we could block off part of it with the panels so that only the right amount is visible (how big is the real CDU?). If we used the touchscreen, we could perhaps utilise that so that the buttons either side of the display push soft pads onto onscreen buttons, rather than being wired up to anything. Or maybe the 5" non-touchscreen would be easier to frame to match the proper size?

Main rig: i5-4670k @4.4Ghz, Asus Z97-A, Scythe Kotetsu HSF, 32GB Kingston Savage 2400Mhz DDR3, 1070ti, Win 10 x64, Samsung Evo 256GB SSD (OS & Data), OCZ 480GB SSD (Games), WD 2TB and WD 3TB HDDs, 1920x1200 Dell U2412M, 1920x1080 Dell P2314T touchscreen

Link to comment
Share on other sites

You could probably fit those screens if you OK giving up some of the prototypicallity - something got to give. Repositioning mount points and reducing LS keys might allow to fit a 5 incher screwn and keep the standard 5.75" total width but it will no longer fit inner 5.25 opening (which is not nessesery a problem )

Anton.

 

My pit build thread .

Simple and cheap UFC project

Link to comment
Share on other sites

  • 2 months later...

If you want to make a PS/2 Keyboard to USB Game Controller adapter, I'd start with a project that turns your microcontroller into a USB Game Controller and add the PS/2 Keyboard library to that.

 

Depending on your existing experience / willingness to learn, there are several options available, each with slightly different trade-offs between cost and effort.

 

The cheapest option is probably an ATMega328 running V-USB. V-USB is pretty easy to get up and running in a traditional Linux development environment (any text editor, make, avr-gcc, flash with avrdude). I don't know how much work it would be to use it with AVR Studio or the Arduino IDE, as I have never tried that.

 

Another option is to use a microcontroller with native USB support. There are Arduino boards with the ATMega32u4 (Leonardo, Pro Micro), or you could use a Teensy board.

 

Use your favorite search engine to find a USB Game Controller code example that you can understand and work from there.

Link to comment
Share on other sites

I'm going to order a teensy 3.1 (https://forum.pjrc.com/threads/23681-Many-axis-joystick?p=41942&viewfull=1#post41942) and I sort of understand how the code you wrote (and from other examples) reads the keyboard input, but how do you then get it to send a button press to the computer?

Could I just use for example:

if (c == 'q') Joystick.button(1, 1);

if (c == 'w') Joystick.button(2, 1);

if (c == 'e') Joystick.button(3, 1);

etc...

Would I need off commands for those joystick buttons or do the buttons swich off when c no longer equals the corresponding key press?

If c is a specific key press at any given time, how does this handle multiple keys being pressed or does this not matter?

Link to comment
Share on other sites

I've been reading that thread, the problem is it looks like it just remaps keys to other keys, so all it's doing is moving the keys around and adding macros without actually adding more buttons. The macro function is a cool idea but it means that unless the macros have the same function across all aircraft you'd have to remap the keys every time you change aircraft. What I want is a game controller with 104 buttons.

Link to comment
Share on other sites

I want to get my idea to work precisely because I (and I suspect many many others) don't want to physically create a button box. I want to be able to solder 5 wires, flash the teensy, stuff it into a tictac box and plug in an old keyboard, and I want to enable others to do the same instead of spending $100 and a week of spare time on parts and matrices.

 

I'll be clear:

I want to create an easy to build in line device that turns any old PS/2 keybord into a button board. Other solutions are of no interest. The problem is that I don't know how to code short of trying to repurpose someone else's.

Link to comment
Share on other sites

I'm going to order a teensy 3.1 (https://forum.pjrc.com/threads/23681-Many-axis-joystick?p=41942&viewfull=1#post41942) and I sort of understand how the code you wrote (and from other examples) reads the keyboard input, but how do you then get it to send a button press to the computer?

Could I just use for example:

if (c == 'q') Joystick.button(1, 1);

if (c == 'w') Joystick.button(2, 1);

if (c == 'e') Joystick.button(3, 1);

etc...

Would I need off commands for those joystick buttons or do the buttons swich off when c no longer equals the corresponding key press?

If c is a specific key press at any given time, how does this handle multiple keys being pressed or does this not matter?

 

You need to explicitly set the joystick button to "off" (I don't know the Teensy libraries, but I assume that would be "Joystick.button(3, 0);"). Ideally, you want to do this when the button on the actual keyboard is released. The sketch in the original post does not address this, as it was hacked together in half a day (it simply immediately releases the button in DCS after pressing it).

 

You need to figure out how to get separate "key down" and "key up" events out of the PS/2 keyboard library (which might require modifications to the library). It may also be easier to work directly with the scan codes that the keyboard sends instead of translating to characters first, this way you don't need special handling for shift and caps lock.

 

I want to be able to solder 5 wires, flash the teensy, stuff it into a tictac box and plug in an old keyboard

In that case, the Teensy is definitely the right choice (with the possible alternative of the Arduino Pro Micro). V-USB requires extra soldering and more external components (three resistors, two diodes, USB jack) and IIRC overpro's sketch requires re-flashing the ATMega16U2 on the Uno board -- not that difficult, but more complicated than simply uploading a sketch.

 

 

The problem is that I don't know how to code short of trying to repurpose someone else's.

Your chances of success are not limited by what you know. They are only limited by how much you are willing to learn and the amount of time you can invest into this project.

Link to comment
Share on other sites

Thanks.

Would this work?

if (c == 'q') Joystick.button(1, 1)

else

Joustick.button(1, 0)

I'll look into scan codes, but it's the logic that's most important now. Since I'm trying to emulate a game controller, the behaviour I'm looking for is that the joystick button is held down as long as the key is pressed, and released when the key is lifted (I'm guessing scan codes might be better for this as well).
Link to comment
Share on other sites

"Would this work?" is a question you can ask your compiler / hardware. Just write it into a sketch and find out!

 

A better question for a web forum is "Why doesn't this work? I thought it would do X, but instead Y is happening."

 

In this case, the button would get pushed down when you press 'q' and released when you press any other key.

 

Modifying code without understanding how it works rarely ever works out (trust me, I speak from personal experience). Even when it does what you expect it to on the first test, there can still be lots of edge cases that don't. You need to understand what you are doing. If you don't, read documentation and tutorials until you do. When you get stuck reading documentation, ask a specific question and state where you got stuck, what you tried, and how it behaved differently from what you expected.

 

I'd suggest to take further discussion of this project to a separate thread.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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