Author Topic: DOS VDM - USB and Game port Gamepad support  (Read 147712 times)

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 306
  • Karma: +27/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #255 on: May 21, 2022, 11:00:18 am »
Hallo Jochen,
What would be the correct algorithm? Since we have the code, we could fix that. Most likely the code in SDL2 is also wrong, because it is a straight port of the SDL1 code.
I think that my proposed algorithm is the correct algorithm. See my original post.

First the calculation of the offset, scale1 and scale2:
Code: [Select]
offset = axis_center
scale1 = SDL_JOYSTICK_AXIS_MIN / (axis_lower - axis_center)
scale2 = SDL_JOYSTICK_AXIS_MAX / (axis_upper - axis_center)

Followed by the recalculation for all axes:
Code: [Select]
if (axis < axis_center)
then axis = (axis - offset) * scale1
else axis = (axis - offset) * scale2

This has of course to be substituted in SDL_os2joystick.c at the right places. Too difficult for me to do.

Cheers,
Wim.
Hi Wim.

I don't know when I can get to it, but I will look into it.

Mark Szkolnicki

  • Sr. Member
  • ****
  • Posts: 433
  • Karma: +18/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #256 on: May 21, 2022, 07:49:00 pm »
Heh Lars!

Hope your having a fine weekend - the long Victoria Day weekend here.


It`s a trap 3 which means it is a hard coded int3 breakpoint, put there deliberately by the programmer. The reason it fires is that something is calling/jumping to address 1000:0, that is, a ZERO offset. Since this is not expected and likely is a programmer error in that somebody tries to do an indirect near call/jump with a near NULL pointer, that is caught by this breakpoint.
Note that the trap address is 1000:0001 because for an int3 the trap screen will show the address of the instruction following the int3 and the int3 instruction is 1 byte long.

In order to analyze that, you´d need a trap dump in order to find out what code tried to call/jump to 1000:0 (or rather do an indirect near call/jump with a near NULL pointer).

Thinking about it: selector 1000 points to the DOSCODE segment that contains many low level kernel routines. And the DevHelp Routine is located in that segment (and all the subroutines it calls). The DevHelp Routine in turn is the main entry point for any device driver services and therefore used by about any device driver and a pointer to the DevHelp Routine is passed to each device driver on driver load. If that pointer is not properly saved or subsequently accidentally overwritten then you might see that trap.

So if it`s about a driver, Wim should check that the saved DevHelp pointer was not accidentally overwritten (the offset part of it) by a NULL value.


Thanks for the detailed explanation.

As mentioned I'm not a programmer myself, but I appreciate when someone will explain not just that there is a problem, but what it may be as well as its implications. It also assists greatly in testing at the moment, to analyze  exactly what I did that made it trigger.

In this case I'm simply acting as a tester and reporting anything I may see, that may be of significance or interest, hopefully in a way useful to you, Wim, Jochen or anyone else participating or observing.

However, in my emergency / environmental consulting practice, as well as my senior roles in both government and corporate in my career, I've been a senior project manager leading teams of hundreds - I always appreciated being informed by my staff as to potential roadblocks, pitfalls or problems, and what may need to be done, in a way I can comprehend, as being forewarned allows planning to proceed smoothly. Analysis is key to success, as well as being methodical IMHO.

I've learned a lot in this what I consider a "project" - it is fascinating to look "under the hood" so to speak as to what actually makes up a device driver and how it operates.

Best!

M
Vincit Que Se Vincit - "He Who Conquers Self Succeeds"

Wim Brul

  • Sr. Member
  • ****
  • Posts: 295
  • Karma: +25/-0
    • View Profile
    • Wim's home page
Re: DOS VDM - USB and Game port Gamepad support
« Reply #257 on: May 22, 2022, 01:14:30 pm »
Hi Jochen,

I don't know when I can get to it, but I will look into it.
Thank you. For starters I tried and modified SDL_os2joystick.c myself. I could send the modified source code to you or append it here. Please advice.

I replaced lines 440 thru 442 with the following:
Code: [Select]
                        joystick->hwdata->transaxes[i].offset = SYS_JoyData[index].axes_med[i];
                        joystick->hwdata->transaxes[i].scale1 = (float)(SDL_JOYSTICK_AXIS_MIN/(SYS_JoyData[index].axes_med[i]-SYS_JoyData[index].axes_min[i]));
                        joystick->hwdata->transaxes[i].scale2 = (float)(SDL_JOYSTICK_AXIS_MAX/(SYS_JoyData[index].axes_max[i]-SYS_JoyData[index].axes_med[i]));

I replaced lines 550 thru 560 with the following:
Code: [Select]
                value = pos[i];
                if (value < transaxes[i].offset)
                {
                        value = (transaxes[i].offset - value) * transaxes[i].scale1;
                        if (value < SDL_JOYSTICK_AXIS_MIN) value = SDL_JOYSTICK_AXIS_MIN;
                }
                else
                {
                        value = (value - transaxes[i].offset) * transaxes[i].scale2;
                        if (value > SDL_JOYSTICK_AXIS_MAX) value = SDL_JOYSTICK_AXIS_MAX;
                }
 
What I am after is that you build an SDL1 test version of DOSBox for us to try out.
I regard this still very experimental, so not yet suitable for an official release.

EDIT1: 20220523 - Updated lines 440 thru 442 with the new code!
EDIT2: 20220523 - Updated line 551 too (with proper code I hope!
« Last Edit: May 23, 2022, 11:29:38 am by Wim Brul »

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 306
  • Karma: +27/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #258 on: May 22, 2022, 09:28:27 pm »
Thanks Wim.

I will try that code snippets and build a test version.


Bye Jochen

Wim Brul

  • Sr. Member
  • ****
  • Posts: 295
  • Karma: +25/-0
    • View Profile
    • Wim's home page
Re: DOS VDM - USB and Game port Gamepad support
« Reply #259 on: May 23, 2022, 09:17:42 am »
Hi Jochen,
Thanks Wim.

I will try that code snippets and build a test version.


Bye Jochen
Thank you. NOTE1: I have updated lines 440 thru 442 with the new code rather than the old code. NOTE2: Modified line 551 later on too (with proper code I hope)!

Sorry, but this is nowadays really difficult for me to do.

Regards, Wim.
« Last Edit: May 23, 2022, 11:36:18 am by Wim Brul »

Mark Szkolnicki

  • Sr. Member
  • ****
  • Posts: 433
  • Karma: +18/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #260 on: May 27, 2022, 04:37:49 pm »
Good Morning Guys!

Finally had time for other matters yesterday, so I took another crack at trying to see if I could get joysticks to work on Trials of Battle (TOB).

For the members of the crowd who haven't been around this operating system only forever, after Galactic Civilizations it was one of the few actual games produced solely and specifically for OS/2 by a retail company, for commercial sale. (Galactic Civilizations was ported to Windows later - originally it was designed solely for OS/2)

I had bought a retail copy from Stardock back when it came out in 1995, and still had it in the original box up to a few years ago, when I was trying to clean up my office of all the software and boxes that accumulated over 30 or so years. I stored away the CD but don't recall if it ever came with a manual (if so, it is now missing, so I had no reference points to go by other than sketchy information on the internet, the Read.Me, a review and fuzzy recollections from originally playing the game.

Anyway, I was finally able to determine that all the functions of the game were accessed from the hanger screen, an annotated version of which I've attached to this post. If you move the mouse cursor about, the cursor changes from red to green when there is a hidden menu flyout present.

These are four in number:
(see the picture for the location of the numbers below):

1 - Storage Equipment Inventory
2 - Options Menu
3 - Arena Entrance
4 - System Damage Report and Repair screen

Clicking on the location I've marked (2) brings up the options screen. The second button down on the right side of the menu, when pressed, brings up a flyout where you can choose whether you want to use a joystick or mouse as part of the controls of the game. This is where you can also calibrate the joystick.

While I still have a hard lock-up after a certain length of time, I can report that, running Wim's driver set and the appropriate xevents.cmd for the joystick in question, I now have joystick control in TOB.

The controls allowed are very simple in nature, consisting of Buttons 1 and 2 and movement using the joystick. The menu choices are hard coded, so you can't customize anything. But at least we've found another native OS/2 game that confirms that Wim's efforts are paying off. Big kudos again to you. Sir!

As mentioned I am still getting the hard lock-ups after various periods of time. I will explain what I've tried so far to alleviate that, in another post.

Also, I don't know if any of you have ever gone to Internet Archive (www.archive.org).

I've found a lot of interesting legacy items which have been placed there for posterity. They do have an ISO of the original game disk there, in their CD collection. The disk is required to both install the game and it needs to be present in the system while the game is running.

I don't know, Martin, if you ever have checked with Stardock as to whether the game is considered abandonware now, or not. I have downloaded the ISO from there, burned it and it runs fine - I have returned my original retail copy of TOB to sleep in its storage case.

Have a great weekend, Ladies and Gentlemen and Best!

M
Vincit Que Se Vincit - "He Who Conquers Self Succeeds"

Mark Szkolnicki

  • Sr. Member
  • ****
  • Posts: 433
  • Karma: +18/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #261 on: May 28, 2022, 03:49:44 am »
Heh Again Guys!

As mentioned in my previous post on getting Trials of Battle (TOB) to recognize the Joysticks using Wim's drivers, I also thought I'd address what I've tried and found so far related to using the program itself.

As mentioned previously, under ArcaOS 5.0.7 using the latest Panorama driver, I was getting hard screen lock-ups after a few seconds entering a new battle within the arena. The lock-up is so hard that no input (keyboard, joystick or mouse, no Ctrl-Alt-Del) is accepted, although the mouse still moves on the frozen screen. You essentially have to hit the hardware reset button to reboot and recover.

During my additional exploration of how to run Trials of Battle, I found that hitting either F3 or F4 set TOB to run a windowed session, at least in the hanger screen - in the first case (F3) the window is smaller than when you hit F4 (only part of the hanger screen is seen in the first case, while a miniature version of the hanger screen is observed in the second case - both windows can be dragged and enlarged).

Again after running the game using Panorama in a windowed session, a hard lock of the screen is observed after a few seconds of movement and battle in the arena - this happens with or without enabling Wim's drivers.

As a second test, I removed the Panorama driver in one of my test partitions, and substituted the Scitech SNAP based ArcaOS driver instead and again ran TOB. Video refresh, desktop wise, seemed slower overall, but running TOB full screen or windowed seemed better - in one case, I was able to maneuver for somewhere between 30-60 seconds (did not time it). That was what I used to test Wim's drivers and get the joystick(s) recognized (there is no way in TOB to run both joysticks used by separate players at the same time - the tests were strictly one joystick or the other).

Using the options screen (see the previous post) the game gives you multiple options as to video - low resolution as to high resolution, the ability to remove multiple texture maps, etc. - using SNAP and going to the lowest resolution, unchecking all the texture maps, I was able to run the game, with Wims drivers for about 45 seconds - after that the lock-up occurred again.

Again observations like that need additional people to observe the same thing, but I suspect the following:

1) Problems related to programming purely in DIVE, and the program never being updated from v1.0

2) Potential problems, single processor vs multi-processor systems, as the development of the OS/2 based OS's have progressed in other directions.

If anyone has any bright ideas related to that or other possibilities I'm open to testing them - the problem is that there are so few complex native OS/2 based games that were created. As such, there is little to use for comparison purposes.

I would be interested in any feedback others may have related to how TOB runs on their systems - nothing I've seen indicates that Wims drivers for Joystick / Gamepad are causing the lock-ups - but perhaps there may be some other video or other workarounds that can be tried to get TOB to run smoothly ......... or perhaps its something on my test system solely ....... or perhaps the past is better left in the past, after at least using TOB as proof of concept.

Best of the day and weekend!

M
Vincit Que Se Vincit - "He Who Conquers Self Succeeds"

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #262 on: May 28, 2022, 04:46:32 am »
You could try adding DEVICE=X:\OS2\SDDHELP.SYS to your Panorama install with X: being your SNAP install and testing. Not likely to help but who knows.
Your lockup, does CTRL-ALT-F10 twice force a dirty reboot after failing to find a dump partition? Slightly cleaner then hitting the power button.

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #263 on: May 28, 2022, 03:55:17 pm »
Use Panorama, but as a test, disable the screen buffer (it's in the screen settings). If that helps then unfortunately, you will have lousy overall video performance.

Mark Szkolnicki

  • Sr. Member
  • ****
  • Posts: 433
  • Karma: +18/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #264 on: June 01, 2022, 09:36:22 pm »
Heh Lars!

Use Panorama, but as a test, disable the screen buffer (it's in the screen settings). If that helps then unfortunately, you will have lousy overall video performance.

I actually tried that previously at Dave's suggestion with Panorama, and got the hard lock-up, but decided to try it again today, as:

1) Finding the Options menu, I was able to switch from default High Resolution to Low Resolution, and

2) I was able to disable all the Texture Maps through the options menu, as a test, to see if that would make a difference.

The answer, disabling the Shadow Buffer is ............. NO, no diffference.

So unless someone else has a copy and can provide some input, I guess our answer is - YES, Wim's drivers are recognized by at least one other native OS/2 program, but no extended additional testing is possible at this time.

But thanks for the suggestion - as always useful and Best!

M

Vincit Que Se Vincit - "He Who Conquers Self Succeeds"

Mark Szkolnicki

  • Sr. Member
  • ****
  • Posts: 433
  • Karma: +18/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #265 on: June 02, 2022, 04:55:53 pm »
Hi Guys!

As there was no Stanley Cup hockey playoff action last night (our Edmonton Oilers are in Round 3 against Colorado tonight) I had some free time after my ride, and decided to tackle trying to get DOOM to recognize the joysticks under DOSBOX.

I have a copy of both Doom and Ultimate Doom installed under DOSBOX and both run perfectly - however it is not obvious as to HOW to enable controller support, although it is mentioned under F1 in the UDOOM game as one of the control options.

So I went out to Memory-Alpha (my Star Trek reference for the Internet), to find out that I had to run Setup.exe for the program under DOSBOX, where the setting to enable controller functions is located.

I don't know how many others are actually using Jochen's version of DOSBOX for our OS, but I've found it very useful to run the DOSBOX GUI program Dosbox Front on top of it (I'm using v 4.9.5 which runs well on ArcaOS). It brings up a window, with Tabs, which allow you to choose settings for DOSBOX and create a .CMD file to run the DOS game or program.

Quickly setting up the Setup .CMD file, I was able to access it and enable Joystick support and calibrate the joystick (the setup program allows you to enable Joystick OR Mouse support, which is default. You can't seem to do both).

Running UDOOM, I was able to use my older Joystick, for both movement and with all four buttons available. It all worked very well, playing the game for over an hour, no problems noted. I have not tested the other Joystick yet.

I imagine setting up the regular Doom 2 controller support will not be much different, now that I know what to look for.

So currently, I have the following programs working completely with Joysticks, using Wim's experimental drivers under DOSBOX:

- Wolfenstein 3D
- Comanche 2
- Star Wars: Dark Forces
- Mechwarrior 2
- Ultimate Doom

There are some variations in the performance of the two joysticks in some programs, probably due to the Joystick algorithm problems mentioned by Wim, but overall, this has been a very uneventful Beta Test - and a much more fun gaming experience!

Best!

Mark
Vincit Que Se Vincit - "He Who Conquers Self Succeeds"

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #266 on: June 03, 2022, 04:22:20 am »
About to test the latest USB stack which has some HID changes and it occurred to me that joystick support should be tested.
So how should I test? eg what to install and run. I should test then update the drivers and retest.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4713
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: DOS VDM - USB and Game port Gamepad support
« Reply #267 on: June 03, 2022, 05:21:45 pm »
About to test the latest USB stack which has some HID changes and it occurred to me that joystick support should be tested.
So how should I test? eg what to install and run. I should test then update the drivers and retest.
Hi Dave

It is along forum thread and I don't want to go back  :)
Sorry if I'm asking things that you already post.

Picking up from here I'm using
- gamepad-20220317.zip
and updated the driver to:
- gamepad-20220517.zip
I hope I'm not confusing the versions here.

Change config.sys
According to your device HardwareID set your config.sys. Mine is like:
 DEVICE=X:\OS2\BOOT\USBECD.SYS /D:081#:##01:0106 /N:$PCSIGP$ /V
and
 DEVICE=X:\OS2\MDOS\GAMEDD.SYS
 DEVICE=X:\OS2\MDOS\GAMEPAD.SYS
 DEVICE=X:\OS2\MDOS\GAMEVDD.SYS

Test oinput.cmd and xevents.cmd
This is the tricky part since these file scripts are provided for some USB gamepad models that we tested with Wim. Here the scripts are the ones that connects the buttons actions with the gamepad (that is how I understand it). The name of the device ($PCSIGP$) is also an important things on the scripts.
While runing the scripts, If you get different codes when you press the buttons, it is good news.

Test an OS/2 game
With xevents.cmd running on the background I had tested Makman (trying joy 1 and joy2)


Test DOS VDM:
With xevents.cmd running on the back you may test:
- https://hobbes.nmsu.edu/download/pub/dos/util/misc/JoystickTestUtils_1998-04-01.zip
Also some DOS games that uses the Gameport joystick like Wolfstein in my case.

Test DOS Game with DOSBox
In my case it was very straight forward to also test Wolfstein 3D with DOSBox and gamepad worked.

Which USB Gamepad do you have? Can you generate the USB report of it?

Regards

Update: Oops, I forgot the gamepad drivers, corrected. But the best way is to read Mark's PDF.
« Last Edit: June 04, 2022, 03:25:04 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #268 on: June 03, 2022, 05:57:56 pm »
The gamepad is,
Code: [Select]
Device 046D:C216 (HID) LS Logitech, Inc. F310 Gamepad [DirectInput which I guess needs a different usbecd.sys setting then any listed.

Mark Szkolnicki

  • Sr. Member
  • ****
  • Posts: 433
  • Karma: +18/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #269 on: June 03, 2022, 06:56:12 pm »
Heh Dave!

About to test the latest USB stack which has some HID changes and it occurred to me that joystick support should be tested.
So how should I test? eg what to install and run. I should test then update the drivers and retest.

Hope your having a fine end of the week!

A while back I created a Testing Guide for Game Controllers, in PDF, which I attached below.

It gives all the set-up info for getting Wim's drivers to work.

However, about xevents.cmd - Wim, for these experiments created the drivers to address his extended control driver on a custom basis so in the RM203 directory of the gamepad package is the xevents.cmd file specifically created for my joystick, using my product ID's, etc. Martins is the same for the gamepads he submitted to Wim - as such, the xevents.cmd file would have to be edited with the info specific to your device, to function correctly.

The most current xevents file for my new joystick is attached below, which you may wish to use for editing purposes.

I am currently in the process of creating v1.2 of the testing guide to add more information related to how to do that, as well as how to use DOSBOX for testing purposes, and other items - hope to post that soon and Best!

Mark

P.S. If you or others have any suggestions related to the guide, I plan to create updates regularly during this testing process, so feel free to provide feedback on that through the thread here or at my Mark@paladinenvironmental.com e-mail.





« Last Edit: June 03, 2022, 06:58:28 pm by Mark Szkolnicki »
Vincit Que Se Vincit - "He Who Conquers Self Succeeds"