Skip to content

Commit

Permalink
Merge pull request #23 from Gnarus-G/feat/hid-driver
Browse files Browse the repository at this point in the history
Feat/hid driver
  • Loading branch information
Gnarus-G authored Aug 10, 2024
2 parents 77a78f6 + dedaa97 commit c79957b
Show file tree
Hide file tree
Showing 35 changed files with 53,063 additions and 49,099 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/Release_CLI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,27 @@ jobs:
- name: Compile
id: compile
run: |
set -x
cargo build --release --manifest-path=cli/Cargo.toml
OUTPUT_DIR="built/output"
mkdir -p "$OUTPUT_DIR"
echo "BUILT_ARCHIVES=$OUTPUT_DIR" >> $GITHUB_OUTPUT
ARTIFACTS_FOLDER="${GITHUB_REPOSITORY#*/}_${GITHUB_REF_NAME}"
mkdir $ARTIFACTS_FOLDER
set -x
make build_cli
BIN=maccel
ARCHIVE=$BIN-cli.tar.gz
BIN_PATH=cli/target/release/$BIN
BIN2_PATH=cli/usbmouse/target/release/$BIN
strip $BIN_PATH;
strip $BIN2_PATH;
cp -r $BIN_PATH $BIN2_PATH LICENSE $ARTIFACTS_FOLDER
ARTIFACTS_FOLDER="${GITHUB_REPOSITORY#*/}_${GITHUB_REF_NAME}"
mkdir $ARTIFACTS_FOLDER
cp -r $BIN_PATH LICENSE $ARTIFACTS_FOLDER
tar -caf $ARCHIVE $ARTIFACTS_FOLDER/*
mv $ARCHIVE $OUTPUT_DIR
Expand Down
29 changes: 20 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,46 @@ build:
debug_install: debug install

install: default
@sudo insmod $(DRIVERDIR)/maccel.ko;

@mkdir -p $(MODULEDIR)
@sudo cp -v $(DRIVERDIR)/*.ko $(MODULEDIR);
@sudo chown -v root:root $(MODULEDIR)/*.ko;
@sudo insmod $(MODULEDIR)/*.ko;
sudo groupadd -f maccel;
sudo depmod;
sudo chown -v :maccel /sys/module/maccel/parameters/*;
ls -l /sys/module/maccel/parameters/*

uninstall:
@sudo rmmod maccel
uninstall: clean
@sudo rm -fv $(MODULEDIR)/maccel.ko
@sudo rmmod maccel

refresh: default uninstall
@sudo make install

refresh-debug: default uninstall
@sudo make debug_install

build_cli:
cargo build --release --manifest-path=cli/Cargo.toml
cargo build --release --manifest-path=cli/usbmouse/Cargo.toml

install_cli: build_cli
sudo install -m 755 `pwd`/cli/target/release/maccel /usr/local/bin/maccel
sudo install -m 755 `pwd`/cli/usbmouse/target/release/maccel-driver-binder /usr/local/bin/maccel-driver-binder

uninstall_cli:
@sudo rm -f /usr/local/bin/maccel
@sudo rm -f /usr/local/bin/maccel-driver-binder

udev_install: build_cli
udev_install: install_cli
sudo install -m 644 -v -D `pwd`/udev_rules/99-maccel.rules /usr/lib/udev/rules.d/99-maccel.rules
sudo install -m 755 `pwd`/cli/target/release/maccel /usr/local/bin/maccel
sudo install -m 755 -v -D `pwd`/udev_rules/maccel_bind /usr/lib/udev/maccel_bind
sudo install -m 755 -v -D `pwd`/udev_rules/maccel_param_ownership_and_resets /usr/lib/udev/maccel_param_ownership_and_resets

udev_uninstall:
@sudo rm -f /usr/lib/udev/rules.d/99-maccel.rules /usr/lib/udev/maccel_bind
@sudo rm -f /usr/lib/udev/rules.d/99-maccel*.rules /usr/lib/udev/maccel_*
sudo udevadm control --reload-rules
sudo /usr/local/bin/maccel unbindall
@sudo rm -f /usr/local/bin/maccel
sudo /usr/local/bin/maccel-driver-binder unbindall

udev_trigger:
udevadm control --reload-rules
Expand Down
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,6 @@ curl -fsSL https://www.maccel.org/install.sh | sudo MACCEL_DEBUG_INSTALL=1 sh

This debugging experience might be lacking still. Feel free to report any issues.

## Limitations

This might not work for some mice.
For all intents and purposes this is a bug.
See [this issue](https://github.com/Gnarus-G/maccel/issues/9).
If you're having an issue like this; there is a [different branch](https://github.com/Gnarus-G/maccel/issues/9#issuecomment-2068290121) with HID parser ported from `leetmouse` to support more devices. It might help.
Install with the `leetmouse` HID parser:

```sh
curl -fsSL https://www.maccel.org/install.sh | sudo MACCEL_LEETMOUSE_HID_PARSER=1 sh
```

Notably, I am using this (it is working) on:
Razer Viper,
Razer Deathadder V2

## References

- https://lwn.net/Kernel/LDD3/
Expand All @@ -140,3 +124,8 @@ Razer Deathadder V2
- https://github.com/a1xd/rawaccel/blob/master/doc/Guide.md
- https://github.com/Skyl3r/leetmouse/blob/master/driver/accel.c
- https://sourceforge.net/p/fixedptc/code/ci/default/tree/
- https://github.com/torvalds/linux/blob/master/drivers/input/evdev.c
- https://github.com/freedesktop-unofficial-mirror/evtest/blob/master/evtest.c
- https://docs.kernel.org/input/input-programming.html
- https://www.kernel.org/doc/Documentation/input/input.txt
- https://docs.kernel.org/driver-api/input.html
32 changes: 32 additions & 0 deletions TWO_IMPLEMENTATIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Two Drivers

maccel has two drivers. One, the legacy, driver is a usb mouse driver that follows a very simple
process for getting mouse inputs and reporting the modifying inputs. The limitation of this driver
is that it might not work for some mice, because it binds your devices away from linux input system which
already supports your mouse. See [this issue](https://github.com/Gnarus-G/maccel/issues/9).

The recommended (default) driver is an input handler kernel module, such that it applies acceleration
on the mouse inputs that have already been properly parsed by the linux kernel.

## Difference

The old driver will either not support your device at all, or not support some extra functions (keys)
that your mouse has.

The new driver has general compatibility with the mice that linux already supports.
In exchange it has 'more' lag than the old driver. Inconsequentially more. See the plot.

![Screenshot_2024-08-10_02-47-37](https://github.com/user-attachments/assets/def3a9d0-2bf3-401e-960c-b299592d1658)

We're talking microseconds here, so you have no reason to use the old driver.
If, for some reason, you want to use the old driver and it supports your mouse. You can bind to it like so:
```sh
sudo maccel driver bindall -- --install # --install makes it so it persists across boots
```
and unbind like so:
```sh
sudo maccel driver unbindall -- --uninstall # --uninstall makes it so it no longer rebinds across boots
```

### WARNING
I will most likely delete the old driver someday to simplify things. There is probably no point to keeping it.
3 changes: 3 additions & 0 deletions bench/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.o
bin
venv
19 changes: 19 additions & 0 deletions bench/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
bench_driver: build
bin/evdriverlag

bench_handler: build
bin/evinputlag

build: evdriverlag.o evinputlag.o
mkdir -p bin
cc evdriverlag.o -o bin/evdriverlag
cc evinputlag.o -o bin/evinputlag

evdriverlag.o: evdriverlag.c
cc -c evdriverlag.c

evinputlag.o: evinputlag.c
cc -c evinputlag.c

clean:
rm *.o
Loading

0 comments on commit c79957b

Please sign in to comment.