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

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #90 on: December 16, 2021, 08:03:59 am »
ok, I now tested hidapitester (with my latest usb100.dll) with a:

[C:\hidapitester]hidapitester --list
054C/0CE6: Sony Interactive Entertainment - Wireless Controller

When I do a:
[C:\hidapitester]hidapitester --vidpid 54c:ce6 -t 1500 --open --read-input-forever
Opening device, vid/pid: 0x054C/0x0CE6
Reading 64-byte input report 0, 1500 msec timeout...read 64 bytes:
 01 7E 7E 7E 81 00 00 CA 08 00 00 00 3A 03 22 95 F9 FF F9 FF FF FF 80 00 26 1F DD 07 D9 0F 76 34
 FD 90 20 D0 00 8A 42 D6 23 5F 09 09 00 00 00 00 00 E7 99 76 34 28 08 00 CB CD FB 46 B6 52 46 0D
Reading 64-byte input report 0, 1500 msec timeout...read 64 bytes:
 01 7F 7E 7E 81 00 00 CB 08 00 00 00 3B 03 22 95 FE FF FB FF FE FF C8 FF A6 1E 69 09 C2 C2 C8 42
 00 90 20 D0 00 8A 42 D6 23 5F 09 09 00 00 00 00 00 19 EC 1A 51 28 08 00 31 3D D5 3B 34 44 48 46
Reading 64-byte input report 0, 1500 msec timeout...read 64 bytes:
 01 7F 7E 7E 81 00 00 CC 08 00 00 00 3C 03 22 95 FD FF FB FF FE FF AB FF AF 1E 5F 09 14 8F 1B 51
 00 90 20 D0 00 8A 42 D6 23 5F 09 09 00 00 00 00 00 36 34 1C 51 28 08 00 42 44 C6 9A 2F F7 4C 37
Reading 64-byte input report 0, 1500 msec timeout...read 64 bytes:
 01 7F 7E 7E 81 00 00 CD 08 00 00 00 3D 03 22 95 FF FF F9 FF FB FF A9 FF B4 1E 57 09 A8 4D 1D 51
 00 90 20 D0 00 8A 42 D6 23 5F 09 09 00 00 00 00 00 B6 66 1E 51 28 08 00 9B DD 74 72 F1 B3 C2 98


and it keeps going on forever. However, how would I now see an individual user action like pressing a button ? The HID report keeps pouring in with a fairly high rate.

« Last Edit: December 16, 2021, 08:10:07 am by Lars »

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #91 on: December 16, 2021, 08:40:22 am »
Change the timeout, -t 50000 seems to work well here to see the various button and joystick changes.
Code: [Select]
Opening device, vid/pid: 0x046D/0xC216
Reading 64-byte input report 0, 50000 msec timeout...read 8 bytes:
 80 7F 7F 80 08 00 04 FC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Reading 64-byte input report 0, 50000 msec timeout...read 8 bytes:
 80 7F 7F 80 28 00 04 FC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Reading 64-byte input report 0, 50000 msec timeout...read 8 bytes:
 80 7F 7F 80 08 00 04 FC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Reading 64-byte input report 0, 50000 msec timeout...read 8 bytes:
 80 7F 7F 80 88 00 04 FC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Reading 64-byte input report 0, 50000 msec timeout...read 8 bytes:
 80 7F 7F 80 08 00 04 FC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Reading 64-byte input report 0, 50000 msec timeout...read 8 bytes:
 80 7F 7F 80 18 00 04 FC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

5th byte seems to be buttons, 6th byte the stick. It is a PC joypad.

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #92 on: December 16, 2021, 12:12:43 pm »
ah, thanks. I had misunderstood what "timeout" was supposed to mean in this context. Now I understand.

Mark Szkolnicki

  • Sr. Member
  • ****
  • Posts: 433
  • Karma: +18/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #93 on: December 16, 2021, 04:52:44 pm »
Hi Dave and Lars!

5th byte seems to be buttons, 6th byte the stick. It is a PC joypad.

When Wim and I were fooling around with his USB control driver, using his output program generated the following:

This way oinput.cmd would work for all 4 switch settings and the actual hid input report obtained would vary accordingly.

Code: [Select]

EC18000081030700 | 04000F4956FF6E | EE
EC18000081030700 | 04000F4A94FF6E | EE
EC18000081030700 | 04000F9250FF6E | EE

On each line, between the | characters, you see the actual hid input report data in hexadecimal.

Code: [Select]

04 | 00 | 0F | 49 | 56 | FF | 6E
B  | 00 | H  | X  | Y  | Z  | S

B=button, H=Hat, X=X-axis, Y=Y-axis, Z=Z-axis, S=Slider


Don't know if the hex code output definitions he mentioned above (for B, H, X, Y, Z and S) would be in the same order but thought I would bring it to your attention, in case it might help.

Also Dave, in that technical white paper you linked to on USB Usage Data, Section 4 and specifically Section 4.1 defines standard usages for Joysticks and Gamepads, while section 8 and most specifically Table 8.1 gives standardized usage data related to PC Game controllers.  According to Section 3.5.3 of the paper:

Typical system software will search for application collections tagged with either a Joystick or a Game Pad Usage. When found, the Usages generated by these collections will be treated as standard system joystick (gaming device) input. Devices that use these declarations will have their output routed to separate destinations, allowing multiple-player applications.

The rest of section 3 may be interesting to you and Lars as well.

Don't know if any of that helps understanding the programming, as its all "hex" to me, but if there's one thing I can do is read technical - been doing that for over 40 years and Best, Gentlemen!

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

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #94 on: December 16, 2021, 05:58:52 pm »
What byte means what actually depends on the HID report descriptor. ("burned" into the USB device). That is basically a structure that describes the hid report data structure in a defined way (a little bit like a DTD would do for XML).
In short: there is no hard and fast meaning for a specfic bit/byte.
« Last Edit: December 16, 2021, 06:00:23 pm by Lars »

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #95 on: January 12, 2022, 09:03:49 pm »
By now, I finally finished libusb (and also libuvc). Additionally, BWW has now built hidapi.
All 3 packages can now be installed from netlabs-exp.

Dave, can you build hidapitester.exe and link to hidapi dynamically ? That would allow me to test the hidapi->libusb chain.
I did test with your static build of "hidapitester.exe" but I don't know how many "hacks" you needed to get hidapitester running properly.

Cheers,
Lars

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #96 on: January 12, 2022, 11:09:30 pm »
By now, I finally finished libusb (and also libuvc). Additionally, BWW has now built hidapi.
All 3 packages can now be installed from netlabs-exp.

Dave, can you build hidapitester.exe and link to hidapi dynamically ? That would allow me to test the hidapi->libusb chain.
I did test with your static build of "hidapitester.exe" but I don't know how many "hacks" you needed to get hidapitester running properly.

Cheers,
Lars

Hi Lars, no I can't easily build hidapitester to dynamically link as it is coded to just use the object fiie, "$(HIDAPI_DIR)/libusb/hid.o"
I'll install the 3 packages and think on it. Actually might be easy, need to test.
Here's the hidapitester patch, basically just added an OS/2 section to the makefile,
Code: [Select]
diff --git a/Makefile b/Makefile
index dad535e..cd952ec 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,9 @@ endif
 ifeq "$(UNAME)" "Linux"
        OS=linux
 endif
+ifeq "$(UNAME)" "OS/2"
+       OS=os2
+endif

 # deal with stupid Windows not having 'cc'
 ifeq (default,$(origin CC))
@@ -54,6 +57,18 @@ EXE=

 endif

+############ OS/2 (libusb)
+ifeq "$(OS)" "os2"
+
+CFLAGS+=-Zomf -Zmap -I../hidapi/hidapi
+# Edit the libs line to reflect your environment
+# If fully installed, "-lusb-1.00 -lpthread"
+LIBS = h:/tmp/libusb1/lib/usb-1.00_dll.a -lpthread
+OBJS = $(HIDAPI_DIR)/libusb/hid.o
+EXE=.exe
+
+endif
+

 ############# common

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #97 on: January 12, 2022, 11:35:09 pm »
OK, that was easier then expected. Attached, note that for testing purposes the Zhigh-mem cflag is commented out. I prefer to add it after making sure things work, along with including <os2safe.h>.
Very lightly tested.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #98 on: January 13, 2022, 03:32:02 am »
Hmm, more testing, hidapitester seems broken, even reverting to the original static makefile using my copy of hidapi (untouched) has the same result, namely --list doesn't output anything.
Hmm, recompiling my local copy of hidapi and running hidtest has the same problem, no devices listed.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #99 on: January 13, 2022, 04:43:12 am »
Seems the YUM/RPM version of USB100.dll is broken. Doing a git pull on your (Lars) repository and then building it and putting the DLL in the program directory works much better, though not perfect.
Code: [Select]
K:\work\hidapitester>hidapitester.exe --list
046D/C534: (null) - (null)
046D/C534: (null) - (null)
046D/C216: (null) - (null)
Code: [Select]
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: 1-4:1.0
  serial_number: (null)
  Manufacturer: Logitech
  Product:      Logitech Dual Action
  Release:      300
  Interface:    0
  Usage (page): 0x0 (0x0)

Manufacturer String: Logitech
Product String: Logitech Dual Action
Serial Number String: (1033)
Indexed String 1: Logitech
Unable to get a feature report.
hid_error is not implemented yetwaiting...
waiting...
...

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #100 on: January 13, 2022, 07:29:40 am »
That's odd because BWW has been building from exactly "my" version (the BWW repo) and I have used your hidapitester and that worked just fine.
Can you make sure that you have usb100.dll and USBCALLS.dll on your system only once and that they are the expected version?
Please note that I am using my USB drivers. That might make a difference as a few things had to be fixed in USBCALLS.dll as well as in the HC drivers.
As a test, can you test with my stack (after checking that the rest is ok) ?
If that works I will try and convince AN to pick up the changes that I did for USBCALLS and the HC drivers.

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #101 on: January 13, 2022, 07:32:29 am »
As to my USB stack: I need to release a new stack first...

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #102 on: January 13, 2022, 07:53:35 am »
Wait a sec, this is about hidapi: can you send your patched hid.c file? I can then merge that into the BWW repo.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #103 on: January 13, 2022, 08:25:34 am »
Hi Lars, pulling and building your USB100.dll and putting it in the program directories, things work. As for what I have installed (W: is boot volume and Unixroot). This is a netlabs-rel install besides the libs and dev packages you mentioned, which2 -la shows all the libs on LIBPATH.
I can test with your stack tomorrow, bedtime here.
No patches applied to hid.c
Code: [Select]
K:\work\hidapi\libusb>which2 -la usb100.dll
w:/usr/lib/usb100.dll

K:\work\hidapi\libusb>which2 -la usbcalls.dll
w:/os2/dll/USBCALLS.DLL

Edit, removed stuff I previously posted, SM crashed when posting :)
« Last Edit: January 13, 2022, 08:32:32 am by Dave Yeo »

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: DOS VDM - USB and Game port Gamepad support
« Reply #104 on: January 13, 2022, 08:30:38 am »
Whoops, committed patches are attached. Jochen commited my first patch.