Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ udev_trigger:
@echo -e "\n::\033[34m Triggering new udev rules\033[0m"
@echo "====================================================="
udevadm control --reload-rules
udevadm trigger --subsystem-match=usb --subsystem-match=input --subsystem-match=hid --attr-match=bInterfaceClass=03 --attr-match=bInterfaceSubClass=01 --attr-match=bInterfaceProtocol=02
udevadm trigger --subsystem-match=usb --subsystem-match=input --subsystem-match=hid --attr-match=bInterfaceClass=05 --attr-match=bInterfaceSubClass=02 --attr-match=bInterfaceProtocol=01

udev_uninstall:
@echo -e "\n::\033[34m Uninstalling leetmouse udev rules\033[0m"
Expand Down
750 changes: 750 additions & 0 deletions debug.log

Large diffs are not rendered by default.

43 changes: 26 additions & 17 deletions driver/accel.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ PARAM_F(SensitivityCap, SENS_CAP, "Cap maximum sensitivity.");
PARAM_F(Offset, OFFSET, "Mouse base sensitivity.");
PARAM_F(Exponent, EXPONENT, "Exponent for algorithms that use it");
PARAM_F(Midpoint, MIDPOINT, "Midpoint for sigmoid function");
PARAM_F(DomainX, DOMAIN_X, "Domain of X");
PARAM_F(DomainY, DOMAIN_Y, "Domain of Y");
PARAM_F(RangeX, RANGE_X, "Range of X");
PARAM_F(RangeY, RANGE_Y, "Range of Y");

PARAM_F(Domain_X, DOMAIN_X, "X Domain multiplyer");
PARAM_F(Domain_Y, DOMAIN_Y, "Y Domain multiplyer");
PARAM_F(Range_X, RANGE_X, "X Range multiplyer");
PARAM_F(Range_Y, RANGE_Y, "Y Range multiplyer");

//PARAM_F(AngleAdjustment,XXX, ""); //Not yet implemented. Douptful, if I will ever add it - Not very useful and needs me to implement trigonometric functions from scratch in C.
//PARAM_F(AngleSnapping, XXX, ""); //Not yet implemented. Douptful, if I will ever add it - Not very useful and needs me to implement trigonometric functions from scratch in C.
PARAM_F(ScrollsPerTick, SCROLLS_PER_TICK, "Amount of lines to scroll per scroll-wheel tick.");
Expand All @@ -82,19 +84,20 @@ INLINE void updata_params(ktime_t now)
PARAM_UPDATE(ScrollsPerTick);
PARAM_UPDATE(Exponent);
PARAM_UPDATE(Midpoint);
PARAM_UPDATE(DomainX);
PARAM_UPDATE(DomainY);
PARAM_UPDATE(RangeX);
PARAM_UPDATE(RangeY);

PARAM_UPDATE(Domain_X);
PARAM_UPDATE(Domain_Y);
PARAM_UPDATE(Range_X);
PARAM_UPDATE(Range_Y);
}

// ########## Acceleration code

// Acceleration happens here
int accelerate(int *x, int *y, int *wheel)
{
float delta_x, delta_y, delta_whl, ms, speed, accel_sens,
lg, lm, lim;
float delta_x, delta_y, delta_whl, ms, speed, accel_sens, lg, lm, lim;
// float e = 2.71828f;
static long buffer_x = 0;
static long buffer_y = 0;
static long buffer_whl = 0;
Expand Down Expand Up @@ -142,6 +145,10 @@ kernel_fpu_begin();
goto exit;
}

//Multiply by Domain
delta_x *= g_Domain_X;
delta_y *= g_Domain_Y;

//Add buffer values, if present, and reset buffer
delta_x += (float) buffer_x; buffer_x = 0;
delta_y += (float) buffer_y; buffer_y = 0;
Expand All @@ -159,8 +166,8 @@ kernel_fpu_begin();
updata_params(now);

//Divide delta by domain before acceleration is applied
delta_x /= g_DomainX;
delta_y /= g_DomainY;
delta_x /= g_Domain_X;
delta_y /= g_Domain_Y;

//Get distance traveled
speed = delta_x * delta_x + delta_y * delta_y;
Expand Down Expand Up @@ -239,11 +246,13 @@ kernel_fpu_begin();
delta_x *= g_Sensitivity;
delta_y *= g_Sensitivity;

//Multiply by both domain and range
delta_x *= g_DomainX;
delta_y *= g_DomainY;
delta_x *= g_RangeX;
delta_y *= g_RangeY;
//Divide by Domain
delta_x /= g_Domain_X;
delta_y /= g_Domain_Y;

//Multiply by Range
delta_x *= g_Range_X;
delta_y *= g_Range_Y;

delta_x += carry_x;
delta_y += carry_y;
Expand Down
10 changes: 6 additions & 4 deletions driver/usbmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
int num_descriptors;
char *rdesc;
unsigned int n = 0;
size_t offset = offsetof(struct hid_descriptor, desc);
size_t offset = offsetof(struct hid_descriptor, rpt_desc);

//Leetmouse Mod END
interface = intf->cur_altsetting;
Expand Down Expand Up @@ -209,9 +209,11 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
num_descriptors = min_t(int, hdesc->bNumDescriptors,
(hdesc->bLength - offset) / sizeof(struct hid_class_descriptor));

for (n = 0; n < num_descriptors; n++)
if (hdesc->desc[n].bDescriptorType == HID_DT_REPORT)
rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength);
for (n = 0; n < num_descriptors; n++){
const struct hid_class_descriptor *desc = n == 0 ? &hdesc->rpt_desc : &hdesc->opt_descs[n - 1];
if (desc->bDescriptorType == HID_DT_REPORT)
rsize = le16_to_cpu(desc->wDescriptorLength);
}

if (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) {
dbg_hid("weird size of report descriptor (%u)\n", rsize);
Expand Down
27 changes: 18 additions & 9 deletions install_files/udev/leetmouse_manage
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -e

DRIVER=leetmouse
DRIVER_PATH=/sys/bus/usb/drivers/$DRIVER
DEVICES=( "5-2:1.0" )

# No argument has been passed over. Exit
if [ $# -eq 0 ]; then
Expand All @@ -24,16 +25,24 @@ if [ $1 == "unbind_all" ]; then
# Temporarily disable binding via udev to leetmouse
echo -ne "1" > /sys/module/leetmouse/parameters/no_bind

for d in $DRIVER_PATH/*/ ; do
# Strip basepath and trailing/leading slashes
d=${d#$DRIVER_PATH}
d=${d:1:-1}
# for d in $DRIVER_PATH/*/ ; do
# # Strip basepath and trailing/leading slashes
# d=${d#$DRIVER_PATH}
# d=${d:1:-1}
#
# if [ $d != "module" ]; then
# echo -e "$d" > /sys/bus/usb/drivers/leetmouse/unbind
# echo -e "$d" > /sys/bus/usb/drivers/usbhid/bind
# fi
# done

for DEVICE in "${DEVICES[@]}"; do
echo "Rebinding $DEVICE"
echo -n "$DEVICE" > /sys/bus/usb/drivers/usbhid/unbind
echo -n "$DEVICE" > /sys/bus/usb/drivers/leetmouse/bind
done


if [ $d != "module" ]; then
echo -e "$d" > /sys/bus/usb/drivers/leetmouse/unbind
echo -e "$d" > /sys/bus/usb/drivers/usbhid/bind
fi
done

# Reenable binding to leetmouse via udev after all pointer devices successfully have attached to usbhid again
sleep 2
Expand Down
25 changes: 25 additions & 0 deletions q.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024/Arch Linux) (preloaded format=pdflatex 2025.2.9) 12 FEB 2025 14:14
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**resume_2025.tex
(/usr/share/texmf-dist/tex/latex/tools/q.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-02-20>
File ignored
)
! Emergency stop.
<*> resume_2025.tex

*** (job aborted, no legal \end found)


Here is how much of TeX's memory you used:
18 strings out of 476076
493 string characters out of 5793776
1925187 words of memory out of 5000000
22223 multiletter control sequences out of 15000+600000
558069 words of font info for 36 fonts, out of 8000000 for 9000
14 hyphenation exceptions out of 8191
12i,0n,13p,95b,8s stack positions out of 10000i,1000n,20000p,200000b,200000s
! ==> Fatal error occurred, no output PDF file produced!
2 changes: 1 addition & 1 deletion scripts/bind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# TODO This proof-of-concept bind script will be replaced by a more mainstreamed udev rule in the near future.

# Home PC
DEVICES=( "5-1.1:1.1" )
DEVICES=( "1-3:1.0" )
# Office PC
#DEVICES=( "2-1.3.4:1.1" )
# Lab PC
Expand Down
37 changes: 37 additions & 0 deletions scripts/unbind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh

# TODO This proof-of-concept bind script will be replaced by a more mainstreamed udev rule in the near future.

# Home PC
DEVICES=( "5-2:1.0" )
# Office PC
#DEVICES=( "2-1.3.4:1.1" )
# Lab PC
#DEVICES=( "3-2.5.4:1.1" "3-1.1.3:1.1" )

# How to get the device id
# Identify your mouse via 'lsusb'
# Bus 003 Device 004: ID 1038:1729 SteelSeries ApS
# So your mouse is on Bus 3 and has the id 4

# Now dive in deeper with 'lsusb -t' and check out "Bus 3" in detail
#/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
# |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
# |__ Port 1: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
# |__ Port 1: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
# |__ Port 2: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 12M
# |__ Port 2: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 12M

# The node with 'Dev 4' tells you, your mouse is on Bus 3, Port 1, Port 2

# Now do a sanity check with 'ls /sys/bus/usb/devices'
#1-0:1.0 1-1.3 1-1.5 1-1.5:1.1 2-0:1.0 3-1 3-1.1:1.0 3-1.2 3-1.2:1.1 4-0:1.0 6-0:1.0 usb2 usb4 usb6
#1-1 1-1.3:1.0 1-1.5:1.0 1-1:1.0 3-0:1.0 3-1.1 3-1.1:1.1 3-1.2:1.0 3-1:1.0 5-0:1.0 usb1 usb3 usb5

# -> Select the matching sub-device. This really much depends on your mouse. It can be the "1.0". For my SteelSeries mice, it was always "1.1". So here it is 3-1.2:1.1 (Bus3-Port1.Port2:SubDevice)

for DEVICE in "${DEVICES[@]}"; do
echo "Rebinding $DEVICE"
echo -n "$DEVICE" > /sys/bus/usb/drivers/leetmouse/unbind
echo -n "$DEVICE" > /sys/bus/usb/drivers/usbhid/bind
done
Loading