necroware / gameport-adapter

GamePort adapter to connect old DB15 joysticks to USB port
GNU General Public License v3.0
297 stars 57 forks source link

CH Production joystick support #52

Open BlazejosP opened 1 year ago

BlazejosP commented 1 year ago

Just d'like to announce that I have working version of files for CH analogue joysticks on game port which working with their extended buttons.

What is a CH joystick standard?

Long time ago in good old DOS days joystick on PC only have 2 axes and 2 buttons. That is why we can play with two joysticks. Then this two Joysticks were merged together and was possible to create joystick with throttle and pedals and four buttons and that was all what was possible to be done on 15 pin joystick port. CH company try to extended this without loss of compatibility of their joysticks with older DOS games and in 1992 starts to sell CH Flightstick Pro. This Joystick start to use simple protocol where some combinations of four button pushed together means a new button. This 4 bit protocol has a 16 possible combination so as you imagine you may have 4 standard buttons + 12 additionally. Not all combination were used in all their joysticks for example this first CH Flightstick Pro only used eight to create 8-way POV HAT. From electronics point of view everyone can create such joystick simple by adding more buttons and using diodes no special circuit was necessary with any chips. I myself extended my ordinary cheap joystick by adding throttle and 6 buttons. I also build circuit in box which has pass through for game port additionally buttons and throttle . With this box I have extended CH Joystick without ordinary with 4 buttons. Without CH driver such joystick behaviour like normal one in DOS games but since 1992 especially simulators has build in drivers for CH what means that you can use fancy POV HATS and buttons for different task. Also since Win95 you can configure such CH joystick in control panel and use all functionality with Win32 games.

What I found during development? First I haven't any CH original Joystick or peripherals. Thy were out of reach in DOS times for me. In 90's i play simulators especially US Navy Fighter etc. I found in early internet an schematics how extend usual joystick for more buttons and throttle so I start soldering simple circuit in my joystick with diodes and for my shock USNF recognise my circuit as a expensive CH joystick. Buttons starts to work throttle even an POV hat. The same I found in Win95 joystick after configuration also works with all buttons etc. Happy from that success I build with father DIY aileron pedals from Wood and that also works. Then I start to think that with other joystick I can build box with joystick cable pas through and I can have CH joystick with this accessory and ordinary joystick when I connect them without box. So in that case I don't modified second original joystick. Then I stored them for last 20 years . That is how I have now CH like joysticks with throttle and pedals for testing. I also have an late from 2000 Saitek Cyborg 3D for game port acquired recently which to my surprise also used CH standard to add more buttons. Based on that devices I was able to start thinking with @necroware code for CH Flightstick Pro.

In CH standard they have such joysticks

CH Flightstick Pro = 3 Axis 4 standard Buttons + 8 positions HAT -> 4 buttons not implemented Combatstick 565F / F-16 Combat Stick = 3 Axis 4 standard Buttons + 4 positions HAT + 8 postions HAT -> no buttons combinations left unused Virtual Pilot Pro = 3 Axis 4 standard Buttons + 4 positions HAT + 8 positions HAT -> -> no buttons combinations left unused Flight Sim Yolk = -> 3 Axis 4 standard Buttons + 8 positions HAT + 4 additional buttons

My DIY Joystick -> 4 axes 4 standard Buttons + 4 positions HAT + 6 additional buttons -> 2 buttons not implemented (works in DOS and win9x)

So we need for implementation such version of Joystick:

*CH like standard Joystick 3 axes 16 buttons

*CH like standard Joystick with pedals 4 axes 16 buttons

CH like standard Joystick 4way hat 3 axes 12 buttons 4 way HAT

CH like standard Joystick 4way hat with pedals 4 axes 12 buttons 4 way HAT

CH like standard Joystick 8way hat 3 axes 8 buttons 8 way HAT

CH like standard Joystick 8way hat with pedals 4 axes 8 buttons 8 way HAT

CH like standard Joystick both hats 3 axes 4 buttons 8 way HAT 4 way HAT

CH like standard Joystick both hats with pedals 4 axes 4 buttons 8 way HAT 4 way HAT

Here is a solution I tested and all buttons working with my Joysticks all 6 I have problem to implement solution with joystick which have both hats 8 way and 4 way because I haven't such joystick. Meaby someone which such joystick can create table of buttons combinations so I can add this third case so now enjoy and check with your own CH joysticks on necrowave game port adapter gameport_adapter.zip

necroware commented 1 year ago

CH Flightstick (Pro) and CH F16 Combat Flightstick are already implemented. CH joysticks didn't allow to press multiple buttons simultaneously, instead they used those combinations to encode more buttons. If you want to extend this behavior just take a look at the decode function of the named implementations. They are very simple.

The problem will be to set all those combinations you mentioned with the dip switches on the adapter. So if you need one of those settings, you would probably have to make a custom firmware for CH flightsticks familiy only.

t0x1cpain commented 1 year ago

@BlazejosP i have a working implementation for CH Virtual Pilot Pro, but there are some jitter problems on some of the 6 buttons and the hat switch on the right side of the Yoke, maybe i am doing something wrong. Or maybe my Yoke is faulty ( i've done hardware testing and the down button on the hat switch on the right side its not working, its not the switch it self but its the IC PLA controller) i really don't know but i will look in to your code and compare it to my code and test it. I also have one question about the CH Virtual Pilot Pro Yoke, what binary number you get when there is no button pressed ?

BlazejosP commented 1 year ago

When 0000 is chosen so means none button is pressed of 4 button code Button 12 is pressed which working reverse to ordinary buttons. But I commented this button so nothing is working when nothing is pressed. Check yourself with my code. I have now table where I have all codes for CH joystick with 4-way POV hat and some partially with 8-way HAT but I have no idea how 4-way&8-way together are encoded because I have no such Joystick myself and CH done this in some standard way. If you are interested in that investigation and have necessary hardware I can upload here special code for CH joystick which shows button combinations. Then is only necessary push all buttons and write which of them are encoded in which combination inside table. When all types of combination will be know I think is easy create correct driver even for your fancy CH Virtual Pilot Pro because from this what I found code works without any jitter on my Saitek Cyborg 2000 and my diy CH joystick. I'm also suprised that you have some PLA IC in your Virtual pilot because CH joystick buttons where build just with simple diodes to have more buttons :)

BlazejosP commented 1 year ago

My actually knowledge about CH Joystick will be great if you check with your CH Virtual Pilot Pro how all buttons of 8-way hat are encoded and how is encoded 4-way hat together with 8-way hat? With this knowledge is possible to build in support for all CH Products Joysticks even this DIY like myself I have.

Number of Combination CH 4-way HAT joystick Generic CH 8-way HAT joystick Generic CH 4-way and 8-way HAT joystick Generic Saitek Cyborg 3D CH Products FlighstickPro CH Combatstick 565F / F-16 Combat Stick CH Virtual Pilot Pro Yoke
1 0 0 0 0 🚫 (uncomment unused ⓬ to have special reverse button ⑫) 🚫 (uncomment unused button ? to have special reverse button ?) 🚫 (uncomment unused button ? to have special reverse button ?) 🚫 (uncomment unused ⓬ to have special reverse button ⑫) 🚫 (uncomment unused ➎ to have special reverse button ⑤) 🚫 (uncomment unused ➐ to have special reverse button ⑦) 🚫
2 0 0 0 1
3 0 0 1 1 F2 🚫 🚫
4 0 1 1 1 F1 ⬅️ 🚫
5 1 1 1 1 ⬆️ ⬆️ ⬆️ ⬆️ ⬆️
6 1 0 0 0
7 1 1 0 0 ⬅️ << ↖️
8 1 1 1 0 ⬇️ ⬇️ ⬇️ ⬇️ ⬇️
9 1 0 1 0 ⬅️ ↙️ ⬅️ ↙️ ⬅️
10 1 0 1 1 ➡️ ↗️ ➡️ ↗️ ➡️
11 0 1 0 0
12 0 0 1 0
13 1 0 0 1 ↘️ >> ↘️
14 0 1 1 0 F3 🚫 🚫
15 0 1 0 1 F4 🚫 🚫
16 1 1 0 1 🚫 ➡️ 🚫
t0x1cpain commented 1 year ago

@BlazejosP Thank you for the detailed information i will check it for sure, i can do more testings after about 2 weeks. By the way you can see the Yoke from this announcement that i've posted some time ago if you didn't already do : https://github.com/necroware/gameport-adapter/issues/43

I did the hardware testing with a multimeter to check the switch if its working or not. Also i got an old pc with a gameport and when i connected the Yoke and opened the CH product manager i got the same results as via the Necroware adapter. On this Yoke there are two 4 way HATS, inside the hats there are 4 switches they are not 8 way. What do you mean necessary hardware ? i am about to buy a digital analyzer. Also for the button decoding i used the already built in debug code from Necroware and also wrote some simple separate code on arduino for testing just to be sure.

And as i remember the PLA IC inside the yoke was GAL20V8B-25LP

t0x1cpain commented 1 year ago

@BlazejosP Finally got time to test your code. So I did modifications using the code you provide and the results were same. Definitely my yoke has hardware failure and maybe there is insufficient power for the USB hub + hums and etc... so that's the reason for the jitter. Plus I think the encoding is done in different way on this yoke. So ill provide my code that works for my yoke and hopefully someone who has fully working same yoke can test the code with it and finalize it.

Thanks.

BlazejosP commented 1 year ago

Thanks for checking this on your original hardware @t0x1cpain . I have some idea can you by using my CHproducts3axes12buttons1hat.h buttons check what are the combinations of buttons for your CH Virtual Pilot Pro Yoke with that you can fill the table of buttons and HAT encoding if they are working of course just edit my table. Even if your yoke are burnt in some way this IC PLA I spouse is easy to repair them with a little bit of soldering skills. Buttons and HAT's on easy diodes circuit and yoke on potentiometer and you can left PLA IC as is. I can show you how I build DIY imitation CH joystick that way 20 years ago. from other side this PLA is easy to buy on aliexpress you need a programmer and original content from working joystick (meaby your PLC IC still have orginal content inside and you can read this with programer?) or is possible to write this code yourself like that are just simple imitation of simple diodes circuits. What is really necessary is to know original combination of buttons

My actual knowledge about your CH Virtual Pilot Pro Yoke Number of Combination CH Virtual Pilot Pro Yoke
1 0 0 0 0 🚫
2 0 0 0 1
3 0 0 1 1
4 0 1 1 1
5 1 1 1 1
6 1 0 0 0
7 1 1 0 0
8 1 1 1 0
9 1 0 1 0
10 1 0 1 1
11 0 1 0 0
12 0 0 1 0
13 1 0 0 1
14 0 1 1 0
15 0 1 0 1
16 1 1 0 1

from your photo there are 2 4-way HAT's + 6 buttons whats means they are here two additionally combinations for buttons and 8 occupied by HAT's = 5 combinations are unused but which where is that possible to deduct that from your death CH Virtual Pilot Pro Yoke ?

t0x1cpain commented 1 year ago

image

@BlazejosP Let’s assume the button numberings are like shown on the above picture. I am using the in-build DEBUG code from Necroware inside the Utilities.h file Here is the following encoding: No button pressed – CODE 3 -> 0011

Button 1 pressed – CODE 2 -> 0010 Button 2 pressed – CODE 7 -> 0111 Button 3 pressed – CODE 6 -> 0110 – Have Jitter messes up the Axis Button 4 pressed – CODE 10 -> 1010 - Have Jitter messes up the Axis Button 5 pressed – CODE 11 -> 1011 Button 6 pressed – CODE 1 -> 0001

Left HAT UP – CODE 13 -> 1101 Left HAT DOWN – CODE 5 -> 0101 Left HAT LEFT – CODE 15 -> 1111 Left HAT RIGHT – CODE 9 -> 1001

Right HAT UP – CODE 12 -> 1101 Right HAT DOWN – CODE 3 - Like no button is pressed. Not working (The physical button is working, but there is a problem with the PLA) Right HAT LEFT – CODE 0 -> 0000 - Have Jitter messes up the Axis Right HAT RIGHT – CODE 8 -> 1000 - Have Jitter messes up the Axis

And yes, I was thinking of replacing the PLA maybe with some microcontroller. Also I don't have any programmer for that chip and I don't think so I can find one in my country. I believe inside the PLA is the original content and if i have a chance to get to that code ill sure try my best to modify/fix or re program another PLA if i can find.

Also regarding this paragraph: "I can show you how I build DIY imitation CH joystick that way 20 years ago. from other side this PLA is easy to buy on aliexpress you need a programmer and original content from working joystick (meaby your PLC IC still have orginal content inside and you can read this with programer?) or is possible to write this code yourself like that are just simple imitation of simple diodes circuits. What is really necessary is to know original combination of buttons"

I will check if there is some "cold" soldering maybe that would fix the problem, if not you can show me the DIY imitation.

Thanks!