Steam Controller

Steam Controller

Not enough ratings
DOSbox and the Steam Controller (FIX)
By cammelspit
Do you want to use your Steam Controller with DOSbox games on steam or off steam? The overlay being unstable for you or just not responding at all in a DOSbox game? Well, I have a fix for you.
   
Award
Favorite
Favorited
Unfavorite
What exactly is the problem with DOSbox and the Steam Overlay
The way DOSbox updates the frame is not typical for most apps or games. What it does is only updates the parts of the screen that have made a change. In this way, it is SUPER efficient and uses very little resources to actually do anything. The problem arises in how the steam overlay interacts with only partial updates. Sometimes, as far as steam is concerned it is only getting one or less than one frame per second.

The Steam overlay, which is required for proper Steam Controller usage, injects itself into the render pipeline of the game, in this case, DOSbox. If the game is not updating the WHOLE frame then the overlay won't either as it relies upon the DOSBoxs pipeline to the GPU to display itself.

This can cause the overlay to seem to stop responding or sometimes just crash. This was verified by using the desktop UI overlay and steam FPS counter. While playing Elder Scrolls Arena as my test game it would routinely say 1 FPS. At times it would climb to up to 40 FPS and then the overlay would work and then stop working once more as soon as it dropped back down. Previously, a solution could not be found because the precise cause had not been determined. Once the cause was known, the solution became much easier to find without having to resort to simply trial and error.

So, what EXACTLY is the fix doing
DOSBox itself would need to me modified greatly to have it update whole frames as you go. The problem here is that this method would likely not be accepted into the main branch of DOSbox seeing as Steam overlay functionality is not a priority but rather emulation speed and accuracy.

The solution I have found is to use a post-processing pixel shader to force the frame to update fully on each vertical refresh even if the frame that DOSbox is rendering has not changed so that DOSBox will work like it normally would but the frames are just being infinitely redrawn. In this case, the DOSbox video backend is left to behave normally as it always will and only the way it is output to the host GPU is changed.
Okay then, let's apply this fix so I can play some games!
You must have the correct version of DOSBox
At the time of this writing, the current public stable version of DOSBox is 0.74. This version has been around for some time and hasn't changed in quite a few years. Development on DOSBox has not halted, though. The problem here is that most of the games that use DOSBox on steam, GOG or anywhere else use this version. The problem here is this version does not support any of the features we need to use to make this fix happen. You can build your own version of DOSBox with the appropriate patches already applied or you can download a version of DOSBox that already has had these features added. For most of us, the latter option is likely the best one since it requires no understanding of how to actually build things yourself. If you would like to do it yourself, you need to be able to output to Direct3D, Vsync and add a pixelshader.

The version used explicitly for this guide is the one found HERE[ykhwong.x-y.net]

Editing a pixel shader manually
You will need to choose a shader to edit manually. I chose point.fx because it does little to the graphics, you can also use the none.fx, make your own blank file to edit or choose any other shader you would like to use. The shaders are stored in the DOSBox\SHADERS folder. You can simply open the file in any text editor.

From here, all you have to do is go all the way to the bottom of the file and add one line of code.
bool forceupdate : FORCEUPDATE = true;
and then make sure to save this new modified file. if you choose to do so, you can also go and edit the other files in the same way so that every pixel shader will have the same effect.

Changing settings in DOSBox itself
Now it is time to open DOSBox. There are a few steps that are required for the fix to actually work. Thankfully, not all of it is done manually in the dosbox.conf. This version of DOSBox has most of the commonly changed settings available to you in the GUI so for now, you can just open DOSBox and follow the instructions below.

  1. Opening the video menu and select Direct3D under the output submenu. This should change the backend that DOSBox is using to D3D so our D3D shader can be applied.







  2. Next, you should set the Vsync option to either On or Forced. The frequency of the Vsync will be the frequency that the frames will be sent to your monitor or TV. 75Hz is default but you may wish to change this using the SetRate option in the same submenu.

    NOTE: With me, it crashed when setting it to 60Hz in the app itself but 75Hz seems to not cause any issues as far as I can tell. What I did was open dosbox.conf after the fact and manually changed the Vsync frequency to 60Hz since I am using a 60Hz display.
  3. The last thing that needs to be done is selecting the pixel shader itself, the one that we had previously modified. All you have to do is select 'Direct3D pixelshader' from the video menu and select the file itself, in this example that would be point.fx.



















SAVE EVERYTHING
Of course, you don't want to have to do this every time you launch any game. Thankfully there is an easy way to write your current settings directly to the dosbox.conf file quickly and easily. All you have to do is go to the file menu and select 'save the current settings' under the configuration submenu. it will pop up a box asking you what to save the conf file as. If you save it as the default dosbox.conf then this will from now on, be the new default settings for the next time you launch DOSBox.
Can I add this fix to a DOS game I bought on steam?
WIP IN THE PROCESS OF BUILDING! MAY WANT TO CHECK BACK LATER AFTER IT IS FINISHED! AS OF NOW THIS IS NOT DONE YET!

Short answer, YES!

Long answer, also yes but as you may be aware, I wouldn't put a whole section here about doing it if it were easy, straight forward and quick.

How hard is it?
The problem we will run into here is a lack of consistency. Each game on steam that uses DOSBox seems to like doing things in a different way and no one can be expected to be able to cover every possible scenario. This is why some kind of manual investigation will be needed to figure out how best to proceed with applying the fix. Here, we will try and get a clearer idea of some of the most common issues you will run into with DOS games on steam.

Some common issues include but are not limited to
  1. Some games will launch a BAT file that starts DOSBox and tells DOSBox what conf file to use when starting.
  2. Other games will just launch the DOSBox executable directly and will have the DOSBox.conf set up is such a way to automatically run the commands needed to start the game.
  3. Some games will use the default 0.74 version of DOSBox and others may use older outdated versions like 0.73.
  4. Some games will use completely non-standard builds of DOSBox, some of these will even use the Daum build, the one we used ourselves to make this fix happen.
  5. The last thing to keep in mind is that steam itself does not have DOSBox built in. Instead, each game individually has it's own copy of DOSBox inside of its own directory, meaning we have to do this for each and every game as needed.

Example one, games that already use the Daum build
This is an example of an easier game to apply this fix to, hocus pocus published by 3D Realms. The good news with this one is that it already uses the Daum build that we use ourselves earlier on in this guide. But there are a couple of things here that can throw a monkey into the wrench of our plans of just applying the fix.

Finding a games install folder and locating the *.conf
Let's start off by opening the games folder. The easiest way to do this is to browse to the game in your library in the desktop UI, right-click the game and select properties. Now that you are in the properties of the game, select the local files tab and then select the button that says 'browse local files'. This will open a normal explorer window right to the games directory so that we can work our magic.

As you can see, this game has a directory with all of the games files in it and it also has a BAT file. If you were to edit this bat file you can see that all it does is point to the DOSBox installed in the games directory and then tells it what configuration file to use, hocus.conf. It is important to take note of this conf file the game is using for its main config. This is because, when we go to save our new settings, we will have to either replace or edit this file. Please note that this file can be right here in the games main directory, in a subdirectory or some games with use the default dosbox.conf as well. This is something you will just have to figure out. Once you do get used to how DOSBox works and how steam games use it, this process should become much simpler over time.

Going into the games folder, we see a folder called DOSBox, open this up and we will try and figure out how hard it will be to apply this fix. We can edit the shader, or better yet, copy the shaders folder right from our already set up DOSBox install. From here we have two options for changing the settings we need to change.

The Easy Way
Go on ahead and launch the game with your Steam Controller off. This will open the normal Desktop UI overlay. You want to make sure you turn on the FPS display so you can just make sure that the fix it working as expected.

  • Bump out of fullscreen by pressing alt-enter.
  • Set the pixelshader as described before.
  • Change the Vsync settings based on the earlier part of this guide including the rate value if desired.

    Now when we save the config, we have to save the config that the game actually loads. Since we saw earlier that the game uses hocus.conf instead of a default DOSBox.conf we need to save over that specific conf file to make sure that the settings will load properly the next time we open the game. Just keep in mind that you will have to type in the whole path to the conf file, it may be annoying but it is still probably easier than going into the conf file itself and changing the settings manually.

    Now, you should confirm that the FPS counter is reading the proper FPS, 75 or 60 depending on how you set things, and then close the game. I would recommend opening the game without the Steam Controller on one last time to make sure the config was saved and can be loaded properly. If it has loaded and works correctly then that is all you needed to do, if not, then you have missed a step or done something incorrectly and should go back through the guide more slowly to try and find out what you did wrong.

    The Hard Way
    ILL FINISH THIS PART LATER... :)

    Games that use the official DOSBox build
    Let's change gears here for a moment and take look at a games that uses an official build of DOSBox. Starting with Final DOOM. Immediately upon opening the Final DOOM directory we can see two things. The first this is that the game uses a separated DOSBox.conf files for each of its launch options and it keeps the game files and the DOSBox files in the same folder. We can tell because each of the launch options has a BAT file and a corresponding conf file associated with it in the games base directory. We also notice by either the icon of the DOSBox executable itself or by simply opening up this build of DOSBox that this game uses the 0.72 official build of DOSBox.

    Most of the time, when a game uses am official build like DOOM does, you should be able to simply copy the whole directory of the Daum build right in there, overwriting the DOSBox.exe file. From here you can apply the fix as you would with any other DOS game as shown above. Now all we have to do is decide how best to go about making the appropriate changes to all of these conf files. Since Final DOOM keeps more than one conf file, one for each launch option, I would HIGHLY recommend using Notepad++ so you can open all of these conf files at the same time and edit them at once without having to open each and every one to edit them one at a time. Otherwise, you should be able to follow the above instructions on manually editing conf files in the 'the hard way' section.




    THIS SECTION IS A WIP AND IS UNDER CONSTRUCTION
Changelog
V1.0 11/13/2016
First initial release. This is mostly just a less hastily slapped together version of a post I made in the Steam community forum for the Steam Controller. There are bound to be misspelled words or errors in grammar but at least the fix is here, recorded and with pictures too. :D. I may add a section for adding this to your DOSBox games that you bought via steam but each game will be entirely different so I may just not care. I also really want to add a video of it actually working just for kicks but I can't be bothered to do that right now so maybe in a few days if I decide I care.

UPDATE: I was bored so I decided to record that video. I only had a few games added to my BigBox library but since it looks so clean I figured, what the hell, Why not!? :D

UPDATE2: Also just tossed in all my other guides just for kicks. Who knows, you might find them helpful.

V1.1 11/15/2016
Added a section to give an outline on how to place the modified DOSBox and/or the pixel shaders into DOS games you have already purchased via steam. This will essentially be a WIP for a bit till I get some good examples of odd ways the maintainers of the games have set them up.

V1.2 11/16/2016
Will tidy up the guide a little bit later in the day. Added an acknowledgments section with details of the copyright. I should really go back and do this for all of my guides. Just so that people can't just rip it off and claim it as their own. I have already seemed slight rewordings of one of my guides posted and claimed as their own content. I know this because the info was out of date so it would have been different if they had actually done anything themselves. I guess plagiarism is a form of flattery when it comes to being an author. :P
Acknowledgements
This guide is penned by Kevin "Cammelspit" Connolly and is copyrighted. You may link to this guide without restriction but if you would like to distribute from other sources you must contact the author first.

All images or other source material was gathered specifically for this guide by the author unless otherwise indicated.
My other guides!
If you are interested, I have made quite a good few of guides, most very deep regarding the Steam Controller. If you like, feel free to browse through them. Some of these can be very helpful so the novice and experienced user alike!

http://steamcommunity.com/sharedfiles/filedetails/?id=753876809
http://steamcommunity.com/sharedfiles/filedetails/?id=670401242
http://steamcommunity.com/sharedfiles/filedetails/?id=595597298
http://steamcommunity.com/sharedfiles/filedetails/?id=572740074
http://steamcommunity.com/sharedfiles/filedetails/?id=571637466
4 Comments
ThreeSon Aug 19, 2020 @ 12:37am 
For the DOSBox games that this fix won't work for, do you know what a possible reason would be?

It seems strange to me that it doesn't work universally with all games in DOSBox, since the fix is being applied to the emulator and not to the game itself. But for some reason, I'm attempting this fix with the original 1993 Alone in the Dark game and it just doesn't want to work. Tried multiple different shader files and different v-sync rates and no luck whatsoever; the Steam overlay just won't come up.
Vampire Woona Dec 21, 2018 @ 11:48am 
Okay, so I can't claim to understand any of what's going on here, as every instance of dosbox i have is what came pre-setup and bundled with a specific game, such as TES1 Arena and TES2 Daggerfall that came with the Anthology box set, and i havent ever attempted to fiddle with their settings in the slightest....

But what I do know is that i just installed the Steam version of Hocus Pocus by 3d Realms, and that game's version of dosbox is setup to work with not only the steam overlay, but discord overlay and my nvidia geforce overlay as well... all right out of the box...

so maybe you pros can use that info to see what's going on under the hood of Hocus Pocus's dosbox and maybe find a way to apply it to the other dosboxes?

anywho. i'll just be keeping my ear to the kennel to see what bones you dig up in the future.
cammelspit  [author] Dec 5, 2018 @ 9:45pm 
Thanks for the kind words. Even though I have essentially abandoned this guide, the fix itself still works a treat for MOST games. AT least there is enough there someone can muddle through if they can wrap their head around it all. Recently, eXoDOS 3.11 came out and the version of DOSbox I was using breaks some of those games so i am currently ecploring using another build or even building my own to deal with the new DOSbox enhancements. If I can figure it out i will finally have a reason to update this guide, and even with a better version of the fix. Though, no promises since im not a software engineer or anything. :P
JackWalters222 Dec 5, 2018 @ 9:11pm 
You, my good sir, are a life-saver. I finally got the classic Rise of the Triad running in a way that isn't God-awful but that also works with my Steam Controller, and with this fix, I'm probably gonna try some other games and see just what I can do with this. Thank you so much for this!