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

Lars

  • Hero Member
  • *****
  • Posts: 941
  • Karma: +41/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #75 on: December 11, 2021, 01:14:08 pm »
Anyways, dropping in the new usb100.dll gave
Code: [Select]
12-10-2021  09:59:35  SYS2070  PID 2128  TID 0001  Slot 00a6
H:\TMP\HIDAPI\LIB\HIDTEST.EXE
HIDAPI0->USB100._clock_gettime
127

So I rebuilt hidapi, some wrestling to link to usbcalls (see libcx is also linked in by the pkgconfig script). Things have improved as the PATH error is gone but still unable to open the device.
Code: [Select]
H:\tmp\hidapi\lib>hidtest.exe
hidapi test/example tool. Compiled with hidapi version 0.11.0, runtime version 0.11.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 046d c534
  path: 1-3:1.0
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    0
  Usage (page): 0x0 (0x0)

Device Found
  type: 046d c534
  path: 1-3:1.1
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x0 (0x0)

Device Found
  type: 046d c216
  path: 0-4:1.0
  serial_number: (null)
  Manufacturer: Logitech
  Product:      Logitech Dual Action
  Release:      300
  Interface:    0
  Usage (page): 0x0 (0x0)

unable to open device

Edit: notice the serial number is still null, perhaps the problem, perhaps caused by working around iconv.

"serial number": the "serial number" as well as "Manufacturer" and "Product" are string descriptors, the id of which are given in the device descriptor. But if the string descriptor id is 0, then no string (descriptor) is saved in the device. About all manufacturers bother to set the "Manufacturer" and the "Product" string, but not the "serial number" string (even though it's possible that even Windows is using that to distinguish 2 instances of the very same device).
In short: nothing to worry about.
« Last Edit: December 11, 2021, 01:18:11 pm by Lars »

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3562
  • Karma: +75/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #76 on: December 11, 2021, 05:11:44 pm »
OK, thanks. The -no-attributes option is handy for stopping the visibility attribute warnings, have to remember that. I see configure also adds -lcx to the LIBS.
I was using the USBDEV package that can be installed with the Arca Noae USB package. It does raise the question of if and how compatible they are. It does have this in usbcalls.txt, "Applications built using this USBCALLS toolkit will only work if a compatible
USBCALLS.DLL and USBRESMG.SYS are installed and running." Something to test I guess.

Lars

  • Hero Member
  • *****
  • Posts: 941
  • Karma: +41/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #77 on: December 11, 2021, 05:45:36 pm »
The interface of the AN USBCALLS and my USBCALLS is exactly the same and therefore the import library is also the very same.
And therefore, if I build usb100.dll, you can run that on any AN system.

Jochen Schäfer

  • Full Member
  • ***
  • Posts: 218
  • Karma: +19/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #78 on: December 11, 2021, 07:04:58 pm »
I tried further analyze the write errors from hidtest:
1.) It tries to write a feature report with number 0x02. The call to libusb_control_transfer gives me a return value of -1 (Input/Output value).
2.) Later, it writes to the device. The call to libusb_control_transfer also gives me a return value of -1.

When I press button or turn the stick, the read data gives me different data values. So that works at least.

@Lars: If you want to compile hidapi yourself, I have forked hidapi and applied Dave's diff and committed them. You find my repo here: https://github.com/josch1710/hidapi.


Dave Yeo

  • Hero Member
  • *****
  • Posts: 3562
  • Karma: +75/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #79 on: December 12, 2021, 05:11:45 am »
2) as to usbcalls import library: if you install RPM package "usbcalls-devel" from the NETLABS release repo, the import library is in there (in .A as well as in .LIB format)

YUM insists on installing libusbcalls-devel 12.10-1.oc00 from arcanoae-rel even when trying to override it. Not going to try too hard with --force or such.
Edit: I reverted back to the USBDEV package due to sys2070's as mentioned above.
« Last Edit: December 12, 2021, 08:30:00 am by Dave Yeo »

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3562
  • Karma: +75/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #80 on: December 12, 2021, 08:36:40 am »
So I found https://github.com/todbot/hidapitester
Compiled it and using this command line,
Code: [Select]
hidapitester.exe --vidpid 046D/C216 -l 64 --open --read-input-forevermy joy-pad seems to work. Lots of other stuff can be done apparently, even adjusting the LED's on those expensive keyboards.
I'll simply attach the whole source including usb100.dll. The makefile needs adjusting if you are rebuilding. Simplest was to use an intree build of hidapi.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3562
  • Karma: +75/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #81 on: December 12, 2021, 09:04:14 am »
Playing around with my sons cheap expensive keyboard and this command line,
Code: [Select]
hidapitester.exe --vidpid 04D9/A0CD -l 64 --open --read-input-foreverkeyscans seem to work until I played with the fnc key, then it stopped working and eventually returned -1 byte and closed the device. Keyboard needs unplugging and plugging back in to come back to life.
For those following along, HID stands for human interface device and includes keyboards, mice and joysticks, which all seem to have similar behaviour when it comes to drivers.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3560
  • Karma: +34/-0
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: DOS VDM - USB and Game port Gamepad support
« Reply #82 on: December 12, 2021, 04:48:39 pm »
Hi

FYI. In case some code can be reused:
- GAMEDD2_2002-07-24.zip and GamePort. Has the source code for JOY_PORT.EXE, a joystick test command line.
- JoySupport. Spiceware code to  make using the joysticks as easy as possible.
- JoyDemo. SpiceWare sample source code for reading the joystick ports under OS/2.

Regards
« Last Edit: December 12, 2021, 04:51:09 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Mark Szkolnicki

  • Sr. Member
  • ****
  • Posts: 252
  • Karma: +11/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #83 on: December 12, 2021, 11:11:11 pm »
Heh Dave!

So I found https://github.com/todbot/hidapitester
Compiled it and using this command line,
Code: [Select]
hidapitester.exe --vidpid 046D/C216 -l 64 --open --read-input-forevermy joy-pad seems to work. Lots of other stuff can be done apparently, even adjusting the LED's on those expensive keyboards.
I'll simply attach the whole source including usb100.dll. The makefile needs adjusting if you are rebuilding. Simplest was to use an intree build of hidapi.

The added adjustments may be even more valuable to us than the game functionality.. I have Both a Corsair K70 and K95 keyboard that has the ability to adjust the backlighting so at night the keyboard is quite spectacular and you can easily type in pitch black - the colours are also slow enough that the special effects aren't annoying, like a couple of keyboards I've had with that functionality.

However, if we can script or key code that would be very useful - my K95 has 6 extra gaming keys (G1-G6), and I understand from Ivan that a previous incarnation of the K95 actually had 18 Function keys on the left side. He's been trying to find a way to use those keys for other purposes outside the gaming realm, but has not been able to succeed. I noted in one of your other posts that the keyscans locked the board, butr perhaps with the advances being made that can be overcome.

I will download the test program and try it but not today - Grey Cup afternoon today, and I used to be from Winnipeg, so Go Bombers Go!

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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3562
  • Karma: +75/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #84 on: December 13, 2021, 02:23:02 am »
Yes, the possibilities are many if the interface ever works correctly. https://www.usb.org/sites/default/files/hut1_21_0.pdf, a 319 page PDF gives some idea of the devices that can be controlled. I see there's even a Python interface to hidapi. Keyboard, touchpads and such are the obvious and what Arca Noae might be interested in.
Right now the hidapitester doesn't seem to be returning the usage field, or rather returning 0x0.

Lars

  • Hero Member
  • *****
  • Posts: 941
  • Karma: +41/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #85 on: December 13, 2021, 08:36:14 am »
I tried further analyze the write errors from hidtest:
1.) It tries to write a feature report with number 0x02. The call to libusb_control_transfer gives me a return value of -1 (Input/Output value).
2.) Later, it writes to the device. The call to libusb_control_transfer also gives me a return value of -1.

When I press button or turn the stick, the read data gives me different data values. So that works at least.

@Lars: If you want to compile hidapi yourself, I have forked hidapi and applied Dave's diff and committed them. You find my repo here: https://github.com/josch1710/hidapi.

Hi Jochen,

I'd be happy if you'd send me the built version and a test app that calls hidapi. Or if you could enable LIBUSB_DEBUG=4 and dump stderr to a file. I simply do not have the time to build yet another library and libusb is still work in progress.
hidapi and a test app would help me in verifying that libusb will do ok also for that secondary library (I am currently interacting with libuvc exclusively).

Jochen Schäfer

  • Full Member
  • ***
  • Posts: 218
  • Karma: +19/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #86 on: December 13, 2021, 08:40:07 am »
So I had some success with the HIDAPI interface to SDL2. It seems like HIDAPI only supports some common game controller like Xbox or PS4 controllers, at least when used via libusb. I plugged in my PS4 controller via USB and it shows up on testjoystick.
I think, I will push the changes upstream, so that we have at least that support.

@Lars, I can do that. I have attached a build of hidapitester with the needed HIDAPI dll. hidapitester -h gives you the parameters. Cf Dave's post with the link to the Github page of hidapitester for more informations.

EDIT: The PS4 game controller works as joystick on PrBoom.
« Last Edit: December 14, 2021, 10:22:38 am by Jochen Schäfer »

Mark Szkolnicki

  • Sr. Member
  • ****
  • Posts: 252
  • Karma: +11/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #87 on: December 13, 2021, 03:45:48 pm »
Hi Dave!

Yes, the possibilities are many if the interface ever works correctly. https://www.usb.org/sites/default/files/hut1_21_0.pdf, a 319 page PDF gives some idea of the devices that can be controlled. I see there's even a Python interface to hidapi. Keyboard, touchpads and such are the obvious and what Arca Noae might be interested in.
Right now the hidapitester doesn't seem to be returning the usage field, or rather returning 0x0.

Downloaded that technical paper you linked and had a quick skim and it is indeed a treasure trove - looks like a great detailed standardized reference guide to addressing a myriad of HID USB devices and usage functions, programming wise, as well as addressing how "Unknown devices" are treated.

I'm going to have a more detailed look at it this afternoon, to see if anything interesting jumps out and report back. I see that Jochen also posted an updated HIDAPI tester, so will see if I can use it with a number of my devices.

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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3562
  • Karma: +75/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #88 on: December 13, 2021, 04:45:23 pm »
@Lars, the hidapitester build I uploaded here also works as a test program, it is statically linked to hidapi.

Lars

  • Hero Member
  • *****
  • Posts: 941
  • Karma: +41/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #89 on: December 14, 2021, 07:39:17 am »
Ok thanks, I'll download all that and have a try.