# Questions about the USB HID device drivers



## A. D. Sharpe Sr. (Feb 15, 2019)

Specifically, I'm interested in how the USB keyboard & mouse drivers publish their nodes. I've been combing through the sources of both drivers in an attempt to understand a) how they make available the data from their devices, b) how they publish their device nodes, and c) where all of the code that implements both sets of sequences is stored at in the source tree. I currently see the ukb & ums driver sources. Beyond that, I'm not sure where to look in order to follow the path between those drivers & /dev. Can anyone help me understand this?


----------



## SirDice (Feb 15, 2019)

This might be useful: Architecture Handbook: Chapter 13. USB Devices


----------



## A. D. Sharpe Sr. (Feb 15, 2019)

SirDice said:


> This might be useful: Architecture Handbook: Chapter 13. USB Devices



Thank you. I think I have a fairly decent understanding of USB devices under FreeBSD. However, two things are tripping me up: a) the fact that the ums & ukbd drivers don't have "make_dev()" calls in them; and b) I can't seem to find an overall keyboard system or overall mouse system.


----------



## olli@ (Feb 15, 2019)

A. D. Sharpe Sr. said:


> I can't seem to find an overall keyboard system or overall mouse system.


I'm not sure if this is what you mean, but keyboards are usually attached to (and managed by) the keyboard multiplexer kbdmux(4), while mice are managed by sysmouse(4).


----------



## SirDice (Feb 15, 2019)

Keyboards go through kbdmux(4). But that's about as deep as my FreeBSD internals knowledge goes.


----------



## A. D. Sharpe Sr. (Feb 15, 2019)

olli@ said:


> I'm not sure if this is what you mean, but keyboards are usually attached to (and managed by) the keyboard multiplexer kbdmux(4), while mice are managed by sysmouse(4).



This is exactly what I'm looking for. However, I'm having difficulty with pinpointing exactly how keyboards talk to kbdmux & how mice talk to sysmouse, especially because ums & ukbd don't publish their own device nodes.


----------



## A. D. Sharpe Sr. (Feb 15, 2019)

I think I might've made a break through. It seems that moused has to be configured to listen to specific device nodes for mouse data. I now see that one of the nodes that it's specifically setup to listen to is /dev/ums. I also see that kbdcontrol has to be configured to attach specific keyboards to the console, so it's setup to attach /dev/ukbd. Now that I understand this, my next question is more about usb device nodes. Is there a specific reason that ukbd and ums publish their nodes directly into /dev, instead of publishing into something like /dev/input? Is that a hard constraint of the usb system, or is it a default spot?


----------



## A. D. Sharpe Sr. (Feb 18, 2019)

olli@ said:


> I'm not sure if this is what you mean, but keyboards are usually attached to (and managed by) the keyboard multiplexer kbdmux(4), while mice are managed by sysmouse(4).


I completely understand that it goes against basic Unix philosophy, however desktop usage would probably be better served by a single input solution that receives input from ALL input devices. Having 2 separate setups for the mouse & keyboard feels wrong to me. Though, that would probably be very difficult to accomplish considering the fact that there's absolutely no standard for publishing device nodes in /dev (besides each node having a unique name & a unique unit number). I wonder how well-received a proposal/patch for automatically publishing device nodes by a pre-established set of categories would be. For instance:

/dev/audio
/dev/bus
/dev/graphics
/dev/input

...and so on.


----------

