Fixed mouse driver and moved to seperate folder
This commit is contained in:
134
README.md
134
README.md
@@ -1,116 +1,54 @@
|
||||
|
||||
Device Driver
|
||||
============
|
||||
======================
|
||||
|
||||
This folder contains a minimal **out-of-tree** Linux kernel module that acts as a USB **boot-protocol mouse** driver.
|
||||
A collection of USB device drivers for Linux kernel, demonstrating how to interact with various USB HID devices.
|
||||
|
||||
It supports:
|
||||
- Left and right buttons
|
||||
- Scroll wheel
|
||||
- Relative cursor motion (X/Y)
|
||||
## Current Drivers
|
||||
|
||||
Important notes
|
||||
---------------
|
||||
### Mouse Driver (`mouse/`)
|
||||
A USB HID mouse driver that supports 16-bit coordinate tracking for high-DPI gaming mice. Tested with Cooler Master MM710.
|
||||
|
||||
- This is an **educational** example. Real USB mice are normally handled by the kernel HID stack (e.g. `usbhid` / `hid-generic`).
|
||||
- This driver binds to HID **Boot Mouse** interfaces (class=HID, subclass=BOOT, protocol=MOUSE). Many mice work, but not all.
|
||||
- To use it on a running system you typically must **unbind** the existing driver from that USB interface first.
|
||||
|
||||
Files
|
||||
-----
|
||||
|
||||
- `usb_bootmouse.c` – kernel module (USB driver + input device)
|
||||
- `Makefile` – builds against your running kernel headers
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
Install kernel headers/build deps (examples):
|
||||
|
||||
- Debian/Ubuntu: `sudo apt-get install build-essential linux-headers-$(uname -r)`
|
||||
- Fedora: `sudo dnf install @development-tools kernel-devel-$(uname -r)`
|
||||
|
||||
Then build:
|
||||
**Features:**
|
||||
- Left, right, middle, side, and extra button support
|
||||
- 16-bit X/Y movement (high-speed tracking)
|
||||
- Scroll wheel support
|
||||
- Binds to HID Boot Protocol Mouse interfaces
|
||||
|
||||
**Building:**
|
||||
```bash
|
||||
cd Device-Driver
|
||||
cd mouse/
|
||||
make
|
||||
```
|
||||
|
||||
Load
|
||||
----
|
||||
## USB Driver Manager
|
||||
|
||||
The `usb_driver_manager.py` tool simplifies the process of binding USB devices to custom drivers.
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
sudo insmod usb_bootmouse.ko
|
||||
dmesg | tail -n 50
|
||||
# Search for .ko files in current directory
|
||||
sudo python3 usb_driver_manager.py
|
||||
|
||||
# Search in specific directories
|
||||
sudo python3 usb_driver_manager.py ./mouse ./keyboard
|
||||
|
||||
# The tool will:
|
||||
# 1. List available USB HID devices
|
||||
# 2. Show available kernel modules (.ko files)
|
||||
# 3. Unbind the device from its current driver
|
||||
# 4. Unload existing module (if already loaded)
|
||||
# 5. Load the new module
|
||||
# 6. Bind the device to the new driver
|
||||
```
|
||||
|
||||
If you want to restrict binding to a specific device:
|
||||
## Future Drivers
|
||||
|
||||
```bash
|
||||
sudo insmod usb_bootmouse.ko match_vendor=0x046d match_product=0xc077
|
||||
```
|
||||
- **Keyboard**: USB HID keyboard driver
|
||||
- **Racing Wheel**: USB racing wheel driver with force feedback
|
||||
|
||||
(Replace IDs with your mouse vendor/product from `lsusb`.)
|
||||
## Requirements
|
||||
|
||||
Bind it to your mouse (unbind/bind)
|
||||
---------------------------------
|
||||
|
||||
1) Find the USB interface path.
|
||||
|
||||
You can use `dmesg` when plugging the mouse in, or inspect:
|
||||
|
||||
```bash
|
||||
ls -l /sys/bus/usb/devices/
|
||||
```
|
||||
|
||||
Typical interface names look like `1-2:1.0` (bus-port:config.interface).
|
||||
|
||||
2) Unbind the existing HID driver (commonly `usbhid`) from that interface:
|
||||
|
||||
```bash
|
||||
DEVIF="1-2:1.0" # <- change this
|
||||
echo -n "$DEVIF" | sudo tee /sys/bus/usb/drivers/usbhid/unbind
|
||||
```
|
||||
|
||||
3) Bind this module to the interface:
|
||||
|
||||
```bash
|
||||
echo -n "$DEVIF" | sudo tee /sys/bus/usb/drivers/usb_bootmouse/bind
|
||||
```
|
||||
|
||||
At this point, the driver should create an input device (via `evdev`).
|
||||
|
||||
Test
|
||||
----
|
||||
|
||||
List input devices and find the new one:
|
||||
|
||||
```bash
|
||||
cat /proc/bus/input/devices
|
||||
```
|
||||
|
||||
Or use `evtest`:
|
||||
|
||||
```bash
|
||||
sudo apt-get install evtest # or your distro equivalent
|
||||
sudo evtest
|
||||
```
|
||||
|
||||
You should see events:
|
||||
- `BTN_LEFT`, `BTN_RIGHT`
|
||||
- `REL_X`, `REL_Y`
|
||||
- `REL_WHEEL`
|
||||
|
||||
Unload
|
||||
------
|
||||
|
||||
```bash
|
||||
sudo rmmod usb_bootmouse
|
||||
```
|
||||
|
||||
If you want the original HID driver back, bind it again:
|
||||
|
||||
```bash
|
||||
echo -n "$DEVIF" | sudo tee /sys/bus/usb/drivers/usbhid/bind
|
||||
```
|
||||
- Linux kernel headers
|
||||
- Python 3.6+
|
||||
- Root/sudo access for driver loading and binding
|
||||
|
||||
Reference in New Issue
Block a user