diff options
Diffstat (limited to 'fastmouse.patch')
| -rw-r--r-- | fastmouse.patch | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/fastmouse.patch b/fastmouse.patch new file mode 100644 index 0000000..55dd0b5 --- /dev/null +++ b/fastmouse.patch @@ -0,0 +1,84 @@ +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c +index 9d80635a91eb..7cd438cbb76c 100644 +--- a/drivers/hid/hid-input.c ++++ b/drivers/hid/hid-input.c +@@ -14,6 +14,7 @@ + */ + + #include <linux/module.h> ++#include <linux/moduleparam.h> + #include <linux/slab.h> + #include <linux/kernel.h> + +@@ -1505,6 +1506,63 @@ static void hid_report_set_tool(struct hid_report *report, struct input_dev *inp + report->tool = new_tool; + } + ++ ++struct fastmouse_state { ++ int division; ++ int x, y; ++}; ++static struct fastmouse_state fastmouse = { ++ .division = 1, ++ .x = 0, ++ .y = 0, ++}; ++ ++static int set_division(const char *val, const struct kernel_param *kp) { ++ const int ret = kstrtoint(val, 0, &fastmouse.division); ++ if (ret != 0 || fastmouse.division <= 0) { ++ return -EINVAL; ++ } ++ // Modifying divison should reset accumlated events. ++ fastmouse.x = fastmouse.y = 0; ++ ++ return ret; ++} ++ ++static const struct kernel_param_ops division_ops = { ++ .set = set_division, ++ .get = param_get_int, ++}; ++module_param_cb(division, &division_ops, &fastmouse.division, 0664); ++MODULE_PARM_DESC(division, "Mouse movement division amount (default: 1)"); ++ ++static int apply_fastmouse(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) { ++ if (hid->type != HID_TYPE_USBMOUSE) { ++ return value; ++ } ++ ++ if (usage->type != EV_REL) { ++ return value; ++ } ++ ++ int* target; ++ switch (usage->code) { ++ case REL_X: ++ target = &fastmouse.x; ++ break; ++ case REL_Y: ++ target = &fastmouse.y; ++ break; ++ default: ++ return value; ++ }; ++ ++ *target += value; ++ const int result = *target / fastmouse.division; ++ *target %= fastmouse.division; ++ ++ return result; ++} ++ + void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) + { + struct input_dev *input; +@@ -1713,6 +1771,7 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct + (!test_bit(usage->code, input->key)) == value) + input_event(input, EV_MSC, MSC_SCAN, usage->hid); + ++ value = apply_fastmouse(hid, field, usage, value); + input_event(input, usage->type, usage->code, value); + + if ((field->flags & HID_MAIN_ITEM_RELATIVE) && |
