Thread Tools
This thread is privately moderated by Jack Crossfire, who may elect to delete unwanted replies.
Jan 17, 2016, 06:45 PM
Registered User
Jack Crossfire's Avatar
Thread OP
Discussion

USB mouse hacking


After 15 years of using 2 cordless keyboards & 1 cordless mouse, finally switched back to an old fashioned corded setup. The constant battery deaths would occur in the least timely moments. The radio integrity was random. The range wasn't long enough to truly be cordless. The mouse speed would change randomly, after changing batteries. The return to corded input is like returning to 1999, an easier time. It always worked, but there was 1 problem.

The pointer speed for PS2 mice always worked in Linux. For USB mice, it never worked. xset never worked as documented. Always stuck with a 15 year old mouse with a PS2 adapter, even after its scroll wheel stopped working & it randomly jumped around on a new mouse pad.

Linux has gone now through a dozen attempts to control pointer speed for USB mice, none of which have worked. They've tried changing xset, xinput, gnome-mouse-properties, gpointing-device-settings, xorg.conf, 50-mouse-acceleration.conf. The only foolproof way to configure the mouse has been recompiling the kernel. This too migrated from a change in drivers/input/mousedev.c to drivers/input/input.c several years ago. After years of editing mousedev.c or just using a USB -> PS2 adapter to force it to use the old PS2 driver, here is the change to input.c to slow down the mouse:

inside

static void input_handle_event(struct input_dev *dev,
unsigned int type, unsigned int code, int value)
{

add

#define DOWNSAMPLE_N 100
#define DOWNSAMPLE_D 400
static int x_accum = 0, y_accum = 0;


Then after the switch statement:

case EV_REL:

add

if(code == 0)
{
x_accum += value * DOWNSAMPLE_N;
value = x_accum / DOWNSAMPLE_D;
x_accum -= value * DOWNSAMPLE_D;
}
else
if(code == 1)
{
y_accum += value * DOWNSAMPLE_N;
value = y_accum / DOWNSAMPLE_D;
y_accum -= value * DOWNSAMPLE_D;
}
Last edited by Jack Crossfire; Jan 17, 2016 at 11:27 PM.
Sign up now
to remove ads between posts


Quick Reply
Message:
Thread Tools