[SOLVED] How can I implement HID protocol ?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Rukog
Member
Member
Posts: 51
Joined: Sun Aug 01, 2021 5:24 pm

[SOLVED] How can I implement HID protocol ?

Post by Rukog »

I do not want to deal with in or out because I do not on Windows, I setup data structure and call a bunch of functions to initialize HID protocol and thus being able to talk to my keyboard or any USB devices.

https://www.codeproject.com/Articles/12 ... -using-HID
Last edited by Rukog on Sun Aug 08, 2021 4:54 am, edited 1 time in total.
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: How can I implement HID protocol ?

Post by Klakap »

Rukog
Member
Member
Posts: 51
Joined: Sun Aug 01, 2021 5:24 pm

Re: How can I implement HID protocol ?

Post by Rukog »

Klakap wrote:HID specification is here https://www.usb.org/sites/default/files/hid1_11.pdf
I know everything about this already, it doesn't say how can I do that in a non Windows environment.

Update:
My current research is at
https://en.wikipedia.org/wiki/Ioctl
https://docs.microsoft.com/en-us/window ... eiocontrol
https://elixir.bootlin.com/linux/latest ... octl.c#L24

Maybe it's all about that, the IOCTL thing
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: How can I implement HID protocol ?

Post by Klakap »

I apologize, but I do not understand how is this connected with OS development. Shouldn’t this be in General Programming? If you want to parse HID, you need to have written USB driver as first. HID parsing comes when you receive HID protocol from USB device.
Rukog
Member
Member
Posts: 51
Joined: Sun Aug 01, 2021 5:24 pm

Re: How can I implement HID protocol ?

Post by Rukog »

Klakap wrote:I apologize, but I do not understand how is this connected with OS development. Shouldn’t this be in General Programming? If you want to parse HID, you need to have written USB driver as first. HID parsing comes when you receive HID protocol from USB device.
It is, same as viewtopic.php?f=1&t=49913
Both of those requests are aiming to handle device communication for further implementation inside an OS.

The USB driver handle HID protocol, it's its nature, a driver is written to offer a gate of communication between PC and device, thus HID protocol for USBD.

What I've wrote is a driver, a user land driver but still a driver, but for windows: https://www.codeproject.com/Articles/12 ... -using-HID

Now I want to write an equivalent driver as the one above for my own OS.
Last edited by Rukog on Sat Aug 07, 2021 12:15 pm, edited 2 times in total.
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: How can I implement HID protocol ?

Post by Klakap »

HID protocol is not about communicating with USB devices. Communication with USB devices is doing through USB controllers OHCI/UHCI/EHCI/xHCI. When you can communicate with USB device, you can found that it is Human Interface Device, and parse HID protocol to found how you can use data which is device sending to you.
Rukog
Member
Member
Posts: 51
Joined: Sun Aug 01, 2021 5:24 pm

Re: How can I implement HID protocol ?

Post by Rukog »

Klakap wrote:... through USB controllers OHCI/UHCI/EHCI/xHCI ...
All of these are related to the PCI thing ?
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: How can I implement HID protocol ?

Post by Klakap »

Yes, from PCI you read base address of ports of these controllers. But do not be worry about PCI, writing driver for it is not hard thing.
Rukog
Member
Member
Posts: 51
Joined: Sun Aug 01, 2021 5:24 pm

Re: How can I implement HID protocol ?

Post by Rukog »

Klakap wrote:Yes, from PCI you read base address of ports of these controllers. But do not be worry about PCI, writing driver for it is not hard thing.
Ok thanks, I will take a look on that thing lol
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: How can I implement HID protocol ?

Post by Klakap »

In fact, if you want to have from your operation system something more than simply showing something to screen, you have to write PCI driver. In PCI is connected everything, hard disk, CDROM, sound card, USB controllers, network cards...
Rukog
Member
Member
Posts: 51
Joined: Sun Aug 01, 2021 5:24 pm

Re: How can I implement HID protocol ?

Post by Rukog »

Why is it so hard to get the PCI Firmware Specification PDF :shock:

https://pcisig.com/firmware-wg-pci-firm ... change-bar

Have to be an org or smth to be able to dl that stuff, it's not the same song for USB spec https://usb.org/hid

I have to search for that like I would do for a torrent lol

(I found it btw, not sure I can share the link here)
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: [SOLVED] How can I implement HID protocol ?

Post by nexos »

No, don't share it :D . There is book on the internet called PCI systems architecture that the publishers made as a free PDF. You could try using that
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Post Reply