GamePort to USB Adapter for analog and digital joysticks

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello and welcome many people from the retro community still have their beloved joysticks and gamepads from the early days these devices often leave their lives somewhere in the dark corners of our basements and we don't dare to throw them away because of nostalgic reasons they remind us so much in our childhood where we played our wing commanders x-wings distance and many other games those old joysticks were all made to be connected to the game port usually on a song card but in the end of 90s and beginning of 2000s game ports vanished from our computers and were replaced by usb and our old joysticks disappeared in the past today not everybody has a full retro pc and many people are using their modern computers with a dosbox emulators and virtual machines to play the old games if needed with a modern usb joysticks but wouldn't it be great to play the old games with the same joysticks which we used back then if you saw my last video about gravy's analog pro joystick you will probably remember that in the end i briefly mentioned this gameport adapter which i made it can be used to connect old gameport joystick to an usb port of a modern pc and in this video it is all about this adapter back in the days i was a big fan of the wing commander series and about half a year ago i got a feeling that i want to play it again so i took my digital copy of the game and started it in a dos box on my morden pc which i'm using daily i remembered quite fast that there is no good way to play it without a joystick so i grab my usb gamepad because it has 2 analog sticks but to be honest it was just not the same i actually don't use this gamepad very often and maybe it is due to the lack of experience but for me it turned out to be not playable with that at the time i realized that i need a real joystick again so i went online and look what i can get incidentally i stumbled upon the graves analog pro joystick and thought that it would be cool to get this one again however it is a game for joystick and not usb so i wouldn't be able to use it on my modern pc well not a problem at all i mean this is a retro hardware channel i built so many retro gaming pcs there are plenty of options right right i took my tandy 1000 rsx installed wing commander 2 there and the world was shiny and great again until i wanted to play wing commander prophecy eventually i was convinced that i want to be able to play this game on my modern pc but then i needed an usb joystick so what to do well maybe you remember my ps2 to serial mouse adapter which i showed in my december 2020 special there i use an arduino to convert between different mouse protocols so i thought why not go in the same way and convert my analog joystick to a usb and after some reading and experimenting i got my first prototype working it could convert simple analog joystick signals to usb i will explain technical details a little bit later but at that moment i was glad that i could use the old gravis on an usb port to play wing commander prophecy on my pc so i told about this converter with another user named creopart from the german dos reloaded e community and he was very excited about it and encouraged me to make this adapter for another joysticks as well and since i had no other joysticks at hand creopard gratefully donated multiple joysticks to me a crevice gamepad which was even still sealed and completely new a microsoft sidewinder gamepad also as good as new and completely with original manual and software and last but not least the famous microsoft sidewinder 3d pro also in best condition with original manual drivers and even with full version of microsoft fury 3 game included at that point i just couldn't stop anymore and so i continued my work on the adapter and added support for all these joysticks by the way there are similar adapters out there which you can buy but they are limited to simple dos compatible analog joysticks and i wanted to make something more universal and open for other tinkerers first of all let's clarify what a gameport was in those times a gameport is a 15 pin connector which carries plus 5 volts on pin 1 8 and 9 4 digital pins 2 7 10 and 14 4 buttons 4 analog pins 3 6 11 and 13 for axes 2 pins 12 and 15 for midi in and output and last but not least ground on pin 4 and 5. the digital button pins are low active and are 0 when a button is pressed and 1 when a button is released 0 and 1 are represented by discrete voltage 0 and 5 volts accordingly the analog pins for xs indicate the deflection by continuous values between 0 and 5 volts both midi pins were used for external synthesizers like roland sound canvas and others later in windows times the meanings of the pins of a gameport could be well let's say redefined and i will come back to it later but for now let's stay in those times and see what we had back then in those the meanings of the pins were hard defined the joysticks didn't need any special drivers but also all games were limited to the maximum of four buttons and four x's these x's and buttons could be either divided over two joysticks with two buttons and two x's x and y each or could be all integrated into one device which was usually the case because having only two buttons was quite an annoying limitation in flight simulators and such games with that knowledge in the head let's take a look at the adapter now the hardware behind this is super simple it is basically an arduino which is connected to the pins of the game port it has four additional 100 kilo ohm pull down resistors for the axis a dip switch to control some settings and a socket where an arduino actually goes into that's it no more no less all the heavy lifting happens in the software and before we come to that let's talk about the arduino first it is very important which model to use the most common and cheapest devices which are built around atmega328p like arduino nano and others will not work here since we want to convert a game port to usb we need a device with integrated usb hid feature which atmega328p doesn't have but the atmega32u4 does and so my choice fell on the arduino pro micro which is built around that i see however should you build one adapter yourself please pay attention that there are two variants of the pro micro as you can see the surface mounted micro usb connector is not the world hardest thing to break so in my first choice i wanted to get one pro micro with a mini usb port like this one unfortunately as it arrived i realized that it is much wider than the version with micro usb and at that time i already ordered the adapter pcbs and it is not easy to find sockets for the wider version of the apro micro so in the end i decided to go with the version with micro usb for now this could be a subject to change in the future but p note wise both adapters are the same so it's not a big deal the software is written completely in c plus and is a normal arduino project which can be opened and programmed directly from the arduino ide as i already said all the magic happens actually in the software and i really tried hard to make it as extensible flexible and though simple as i could i consider it well documented and easy to read code if you are in c plus plus it might be a bit more tricky if you are a c programmer or have your roots in other languages but still i think that it shouldn't be a problem i didn't use any assembler c macros or any other wild hacks i had to implement on class for reading digital input signals though because the standard are the inner functions were too slow but i will come back to it a bit later the whole software is distributed over a handful of driver files and some additional helper code you can find the source code together with the kicad files on github i'll put the link down into the description each type of joysticks has its own driver with own specialities so the best is if i explain each driver and their technical details separately simple dos compatible joysticks with two to four buttons and two to four axes were not a big deal as i told the very first prototype was written for the crevice analog pro which is a such simple dos compatible joystick with up to four buttons and three axes as i tested the implementation with different very used old and also unused old stock joysticks i realized that all of the joysticks have slightly different internal potentiometers some were not bad from the beginning some went bad over the years but the standard says that the potentiometers has to go from 0 to 100 kilo ohm i measured all kind of values between 80 and 140 kilo ohm that results in annoying coordinates offset this can be solved by recalibration but i noticed that some modern games ignore the operation systems calibration and also don't provide own in-game calibration as well that made many joysticks simply unusable in such games because the middle point was always somewhere else but not in the middle so i got an idea how this could be solved it is sufficient to save the position of the joystick during the initialization and use it as the center for all the subsequent position calculations the outer limits of the axis will be updated on the fly during the joystick movements as soon as the software recognizes a deflection of the axis from the middle it updates the maximum and minimum limits and recalculates the position relative to the center this auto calibration feature makes it possible that all joysticks will always remain in the center right on start and without the need for additional calibration at the operation system level this works independent from the condition of the internal potentiometers the only requirement for this solution is that all of the analog access must be centered when the joystick is connected what is usually the case anyway for the most axes when we don't touch them the only exceptions are wheels throttle control and such things so pay attention to center them when connecting the joystick this auto calibration feature is shared by all drivers for joysticks with analog axis so far thrustmaster was a very famous and high quality joystick back in the days basically it is the same simple dos compatible joystick with four buttons and four x's where two x's were used for x and y movements or pitch and yaw if you want so and one axis was used for throttle control and one axis had a special function the value of this axis was interpreted as a head switch movement a value below 25 voltage means up below 50 percent right below 75 down and below 96 percent left and 100 percent of voltage means center the question was how to test it i don't have a real thrustmaster joystick here came the donated microsoft sidewinder 3d pro quite handy this joystick is really awesome it can work in multiple modes and can also emulate thrustmaster and ch flight stick joysticks the sidewinder 3d pro has a switch on the front where you can select the type of emulated joysticks this way i could test the thrustmaster implementation and it works flawlessly sure it is not the real thrust master but as far as i can see the emulation is quite precise and everything works as expected and since the sidewinder 3d pro also can emulate ch flight stick joystick i took care of this one as well this joystick is also dos compatible with 4 buttons and 4 x's instead of 3 like with thrust master it has the pitch and your throttle control and rotation and in addition to that the joystick also has a head switch but wait all available gameport pins are already in use if you remember a standard gameport joystick can have maximum of four buttons and four axes how does that head switch works well ch flight stick has another interesting solution it encodes the head switch movements using the buttons you see this joystick doesn't allow to press multiple buttons simultaneously every time a user is trying to press multiple buttons the buttons with a higher id are shadowed by the ones with the lower id for example if you press the button 0 you can press the buttons 1 2 and 3 as much as you want but they will not react on the other hand if you press the button 2 and then press press the button 0 still keeping your fingers on button 2 you will see how button 0 will light up and shadow button 2 in the same way like you would release it until you release the button 0 again so for the head switch the joystick encodes the position as multiple button usage so the software which supports such a joystick knows if multiple buttons were pressed then it must be the head switch when all buttons are reported as pressed means head switch is in up position when all buttons are pressed except the second then it is right when all buttons are pressed except the third then it's down and when only the buttons zero and one are pressed but two f3 are released then it's left all the other combinations would mean center position of the head switch the specialty of the ch flight stick as well as the one of the thrustmaster are both implemented in the software of the gameport adapter and properly mapped to the usb codes many people call buttons only joysticks or gamepads as digital this is kind of right because a button is either pressed or not you can't have an endodontic values in between however in this video by digital i mean something different as i already told a game port contains 15 pins 8 of which are used for joystick communication four pins are for buttons and carry digital values in sense of on off and four pins are for analog access which deliver voltage somewhere between zero volts and five volts joystick which were made in the early days were using this pin out they could have maximum of 4 buttons and 4 axes and were dos compatible and due to analog access signals such joysticks were called analog all the joysticks i was talking about in this video so far are analog joysticks even this gamepad despite that it has no analog stick like the others it still uses the same signaling here when you press the axis buttons it just reports that the axis is completely deflected to the limit and if you release the button then the x's are centered later in times of windows 95 and 98 many joysticks were made to be plugged into a gameport as well but they were not limited to four buttons and four axes they had a lot more exciting features like hat switches and throttle controls but how did this work well in the time before usb the manufacturers implemented their drivers to communicate with the joystick via gameport using a proprietary communication protocol for example by using one pin of the game port as a clock and another one as data the possibilities were almost limitless such joysticks are called digital as well because they are using digital protocols to communicate with the pc and suddenly many features were possible but the price for this feature was the loss compatibility to doors you couldn't just plug such a joystick into the game port and expect it to work on the old dos games the plug was the same but the signaling was completely different so from there on you needed special drivers which would handle the communication between the joystick and the pc this part is probably a bit too technical for this video but maybe it is still interesting for some of you as i told sidewinder 3d pro can emulate thrustmaster and ch flight stick joystick using this switch on the front to select between the types however this joystick has more buttons than only the 4 which are supported by those types of joysticks this additional four buttons on the base of the sidewinder 3d pro are not used in emulation mode they simply are not working there so what can we do to use those buttons too well sidewinder 3d pro is a very late game for joystick it was produced in the year in 1996 where windows 95 already took over the gaming market usb was already incoming and replaced the gameport very soon entirely the reason why sidewinder 3d pro supported the emulation modes was the attempt to keep up the compatibility with those games which still were quite strong at the time but since in windows 95 there were no such four buttons for access limitations microsoft introduced the digital sidewinder protocol which could provide a lot more features than was possible ever before let's take a brief look on how it works microsoft decided to reuse at least three pins for some sidewinder joysticks more but for now let's take the simplest case into account for that purpose sidewinder protocol reuses pin 2 for clock pin 3 for so called trigger signal and last but not least pin 7 is used for data the idea is very simple the pc sends a trigger signal to the joystick on pin 2 and the joystick sends the data as bunch of ones and zeros back on pin 7 clocked by the signal on the pin 3. in the data all the joystick state information like axis positions and buttons states are encoded and are usually parsed by the joystick driver on the epc side and represented by a common software interface to the games these triggering data reception and more is now completely implemented in the software for this project however even if the idea itself sounds simple the implementation was a bit tricky to be honest one of the bigger problems were very strict timings since such sidewinder joysticks send the data with a clock pulse duration of only 5 microseconds or a frequency of 200 kilohertz with the other words which is far too fast for the stork digital read function of an arduino i made some measurements on the 16 megahertz pro macro and found that it needs about 2.3 microseconds to make one digital read so in 5 microseconds you can pull the signal only twice and you still need some time to make the actual work in between no way so i implemented my own function for that which is about five times faster and it's only 440 nanoseconds per read which allows to pull the signal at about 2.2 megahertz instead of 430 kilohertz of the stock function before i go too deep into it if you are interested just take a look at the digital pnh file in the code which contains the full c plus plus implementation for reading and writing digital signals i am quite happy with it and now i have a powerful tool to handle such a high clock frequencies at which a sidewinder throws data at me now where i briefly explain how the sidewinder protocol basically works let's talk about the actual sidewinder 3d pro joystick as i told it can emulate analog joysticks but can also be switched into digital mode where all eight buttons four axis and an eight way headswitch can be used the tricky part is to switch the sidewinder 3d pro into a digital mode there is no physical switch to do that i needed quite some time to figure out how it works therefore i started deciding the source code of the linux kernel and the microsoft patent us5628686a there you can find the solution on page 19 and 20 and it's not really complicated once you know how it works you just have to use the trigger on pin 3 of the gameport to send a magic sequence of 3 pulses of particular duration when joystick recognizes such a magic sequence it will switch into the digital mode and start to communicate using the previously described sidewinder protocol i don't want to get deeper into technical details here but you can find the corresponding code in the file sidewinder age the sidewinder gamepad is another example of device which uses the sidewinder protocol this gamepad works in similar way like the sidewinder 3d pro except it works only in digital mode and doesn't need to be switched into the digital mode first the data from the gamepad is then transferred to the computer in the same way using trigger clock and data pins as for 3d pro for details please look into the code well that was quite a lot of theory and background information but i hope it was at least informative so far and i promise you from now on it is only about usage of this adapter which is by the way very simple first of all you have to select the type of joystick using these dip switches on the side the adapter currently supports all kinds of joysticks which i was talking about so far on the project side you can find a table with all supported joysticks and in this column you can see how the switches has to be set zero means off and one means on so if you want to use an analog joystick with two axes and two buttons just turn all switches off and for example for thrustmaster compatible joystick turn the first and the third switch on for all side window joysticks you have to turn first second and third switch on please notice how the switch is the same for both side winder devices since in digital mode the adapter just needs to know that the joystick is a sidewinder which type exactly it is the adapter will detect automatically such auto detect is of course not possible for non-digital joysticks since there you have only way communication and there is no way to distinguish the type somehow okay let's give it a try and connect the gravis analog pro i'll set up it to analog joystick with two buttons and here you go the joystick was detected as two buttons to access joystick and as you see due to the automatic calibration feature the joystick is exactly in the middle no need to recalibrate it the adapter does the job automatically let's switch the setting to two axis four buttons now by the way you always have to unplug the adapter from the usb port if you want to change the settings and here you see the joystick was correctly detected and we have now four buttons let's now take the sidewinder 3d pro joystick and set it to ch flight stick emulation mode the adapter has to be switched to ch fly stick as well don't forget to set all axes into the center also the throttle slider let's connect and as you see the joystick was detected as six axis four buttons one and again all the axes are auto adjusted perfectly centered and all the axes are working also the throttle slider and the head switch however notice how the head switch has only four ways up down left right this is a limitation of the ch light sticks which doesn't allow to go to other directions like bottom left or top right furthermore we see only four buttons despite that the joystick has actually 8 of them so let's switch to sidewinder as you see the joystick is now detected as 6 axis 8 buttons device and in the test we can use all eight buttons indeed furthermore the heart switch is now usable in all eight directions isn't it nice now let's connect the glass joystick sidewinder gamepad we don't need to change any dip switches since it is already set to sidewinder and the actual type should be auto detected and here we go the game path was detected as two axes and ten buttons joystick and as you see all the buttons do work indeed well now all these joysticks will get their second life and can be used again on modern pcs i developed this adapter on linux but i also tested it on windows 98 windows xp and windows 10. at least i didn't notice any problems but it needs to be tested by more people on different systems and joysticks to consider it stable i guess at least on older windows versions you maybe will need to install arduino drivers which are officially available on linux and windows 10 everything is already included just plug it into the usb port and you're good to go like everything in the world also this device has a lot of space for improvements first of all i hope that others will contribute even more drivers to this project obviously i don't have all kinds of joysticks which were ever produced for the gameport and even if i would i'd need a lot of time to get them all tested and running i mean i will certainly try to add more joysticks to the list of supported devices but i really hope for your contributions as i already told you can find all the schematics and code open source on github and the link is in the description of this video please take a look at it ask your questions and if you think that you can help please do so our good old joysticks deserve a second chance on regards of the current implementation i think it makes a good base so far and i'm quite happy how it turned out though not everything is perfect for example that the axes have to be centered when plugging in the joystick so the automatic calibration can be made is a bit annoying the joystick itself is usually centered by the engine anyway but the sliders can be offset you can realize it too late and have to readjust the or reconnect the device this is only related to analog joysticks and not to digital ones like sidewinder but anyway maybe this can be somehow improved in the future many people are also concerned about latency and here is the good news this adapter adds just a very little delay on analog joystick it's less than one millisecond on sidewinder it's below four milliseconds in the worst case so this adapter is absolutely usable in the fastest action games and in regards of hardware there is one thing so far i don't like the micro usb on the arduino which i already mentioned this could be too fragile in my opinion but i already have some ideas how to improve it so maybe i will introduce an optional design in the future maybe it will also have to be changed one day to support another joysticks as well well we will see and this video already became a little bit long and maybe also too technical i'm sorry if it was too much but it is a little bit hard to find a good way of how to explain the background without going too much into the technical details so please write into the comments if you like such a technical depth or should i try to make it less detailed to everyone who wants to contribute to the project you are welcome and to everyone who just wants to use an all joystick i hope i could help you with this device and before you ask i currently don't sell these adapters but i am playing with a silly idea to make an online shop where i would be able to offer all the devices i'm making i'm currently unsure about this idea and would like to know what do you think about it and this is it for today i had a lot of fun doing this project and i hope you enjoyed this video as well i'm looking forward for your feedback and so far thank you and goodbye
Info
Channel: Necroware
Views: 8,405
Rating: undefined out of 5
Keywords: retro, hardware, soldering, repair, review, nerd
Id: tSJLgCD8jeM
Channel Id: undefined
Length: 30min 3sec (1803 seconds)
Published: Sun May 30 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.