I am trying to build a custom joystick/gamepad device for an embedded Linux system. I am looking for a library or system API that will allow me to create a node in /dev/input from userspace code.
I would like this because:
The custom hardware can communicate with the system using the existing SPI or I2C drivers (it's my hardware design so I can do whatever makes the most technical sense)
Kernel modules can't utilize other drivers, only exported symbols from other modules
I understand the only way to make a kernel module is with kernel code and compiling that as a kernel module. I am not trying to achieve a kernel module with userspace code.
I am looking for an API that allows me to create a file, and when that file is read from or written to, functions get called. That's the general concept of a character driver. I don't need the privileges or restrictions that the kernel provides or imposes.
There must be some way to emulate file I/O that doesn't involve writing a brand new kernel module.
Thanks!
Controlling Hardware From User Space First and foremost, a driver is software that directly controls a particular device attached to a computer. Second, operating systems segregate the system's virtual memory into two categories of addresses based on privilege level - kernel space and user space.
The Linux kernel supports two main types of USB drivers: drivers on a host system and drivers on a device. The USB drivers for a host system control the USB devices that are plugged into it, from the host's point of view (a common USB host is a desktop computer.)
Old question, but I thought I'd add a tidbit so people looking at this won't get the wrong ideas. For about the last 3-4 years now, there's been this little framework, that was added to extend the FUSE filesystem edge that provides a sandboxed solution to do precisely what the questioner is asking for.
It's called CUSE, which allows character drivers to be instantiated by people that are part of the FUSE group on a system that has had FUSE and CUSE turned on in the kernel. All it takes is an appropriate application (your OSS adaptation daemon on your distribution is just one such application, FWIW...)
Answers of "you can't" and the like back then weren't at-all helpful, didn't actually consider the problem, and were...heh...quite wrong overall...even then.
CUSE hasn't had as much uptake as FUSE so there's less help to do things there in the form of nifty easy-to-use bindings, but it's still there. What brought me to this thread was me looking for a "better" answer if there was one to be had on that subject. Answer there's turning out to be "yes, if you can do Python..." (pycuse)- and if you can't do Python there, you're on your own. Well...I've never been one to accept that sort of thing...so I'm going to learn from pycuse and make a C++/Go/etc. binding as I get to them and need a new one for the language I'm working with at the time I need it.
As for the rest...heh...next time have your ducks more in a row. You certainly didn't on this one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With