Tired of Mac OS X's mouse acceleration?

Everything todo with programming goes HERE.
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

This is now The Official Bump Thread. :)

Unfortunately I don't know too much about this. I just happened to discover how to enter a negative value and what it does.
  • [-∞, 0): seems mostly linear and without scaling.
  • 0: also seems linear, but at a fraction of the speed.
  • [0, 3]: range of slider in prefs.
  • (3, ∞]: insanity.
ˌɑrməˈɡɛˌtrɑn
almo
Posts: 1
Joined: Fri Jun 12, 2009 3:06 am

Re: Tired of Mac OS X's mouse acceleration?

Post by almo »

Hi!

I've been using Logitech control panel + mousefix. It works since mousefix turns off acceleration, and logitech ups the speed. But that's not an ideal solution since it requires a logitech mouse so you can use their driver, plus mousefix is based on a deprecated OS call, so it may stop working at any time. :(

Anyway, I've bitched at Apple a lot about this. I have a blog, and the mouse acceleration rant page is very popular. So I put up this Petition to Apple:

http://www.petitiononline.com/MacMAcc/petition.html

Sign it if you agree. :)
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Re: Tired of Mac OS X's mouse acceleration?

Post by Jonathan »

Good luck with that petition. All I can say is, sign it and spread the word. If you care about natural pointer response (or even wouldn't mind a checkbox), that is. :)
ˌɑrməˈɡɛˌtrɑn
zany
Posts: 2
Joined: Sun Jul 26, 2009 2:42 pm

Re: Tired of Mac OS X's mouse acceleration?

Post by zany »

almo wrote: I've been using Logitech control panel + mousefix. It works since mousefix turns off acceleration, and logitech ups the speed
Actually there is a preference pane built on top of mousefix. You can set speed to high and acceleration off easily there.
See http://osx.iusethis.com/app/mouseaccele ... erencepane
gupperman
Posts: 2
Joined: Thu Nov 26, 2009 8:07 am

Re: Tired of Mac OS X's mouse acceleration?

Post by gupperman »

Thank you a lot for this wonderful piece of code. I've just switched to Mac after a life on Windows and the acceleration thing almost made me go back to Windows. My hand hurts so bad...I changed some mice but still, when you move the mouse slow for precision, the cursor moves like you drag it through mud on the screen. Geez, I hate that. Your code fixes this perfectly, but I have to run the script after each restart. I would love to be able to make it a startup app like you can do on Windows. Is there any simple way to run it at startup? I have no idea how to do it since I am very new to Mac. Thank you! (MacBook Pro + Snow Leopard - 10.6.2 here)

P.S. I even broke into pieces one of my mice, throwing it to the wall in my room... that damn acceleration drives me crazy. :x
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Re: Tired of Mac OS X's mouse acceleration?

Post by Jonathan »

You can add it under System Preferences -> Accounts -> Login Items.

I also just made another crude executable that doesn't even require you to click the fix mouse button. Turns out it opens in a Terminal window though, but see which you prefer. Edits: heh, you can just put it in a simplistic app bundle. Create a folder, put the program in there, then rename the folder to the same name as the executable with .app added (e.g. decelerate_mouse.app containing decelerate_mouse), and bingo. It doesn't appear to do anything, but it does work.

Code: Select all

#include <stdio.h>
#include <string.h>
#include <IOKit/hidsystem/IOHIDLib.h>
#include <IOKit/hidsystem/IOHIDParameter.h>
#include <IOKit/hidsystem/event_status_driver.h>

int main(int argc, char **argv)
{
	const int32_t accel = -0x10000;
	io_connect_t handle = NXOpenEventStatus();
	
	const char *name = strrchr(argv[0], '/');
	if (name)
		++name; // one past the last slash
	else
		name = argv[0]; // no slashes, just eat it whole
	
	if (!handle) {
		fprintf(stderr, "NXOpenEventStatus is uncooperative\n");
	} else {
		kern_return_t ret;
		if (strcasestr(name, "mouse")) {
			ret = IOHIDSetParameter(handle, CFSTR(kIOHIDMouseAccelerationType), &accel, sizeof accel);
			if (ret != KERN_SUCCESS)
				fprintf(stderr, "Error fixing mouse: %d\n", (int)ret);
		}
		if (strcasestr(name, "trackpad")) {
			ret = IOHIDSetParameter(handle, CFSTR(kIOHIDTrackpadAccelerationType), &accel, sizeof accel);
			if (ret != KERN_SUCCESS)
				fprintf(stderr, "Error fixing trackpad: %d\n", (int)ret);
		}
		NXCloseEventStatus(handle);
	}
	
	return 0;
}
decelerate_mouse_trackpad.gz
(3.45 KiB) Downloaded 2930 times
Leave "mouse" or "trackpad" in its name to have it fix the mouse or trackpad. I.e. if you like your trackpad with accel, remove trackpad from its name. Really crude form of parameter passing because the login item thing won't let you. :) You can double-click it if you feel the need.
ˌɑrməˈɡɛˌtrɑn
gupperman
Posts: 2
Joined: Thu Nov 26, 2009 8:07 am

Re: Tired of Mac OS X's mouse acceleration?

Post by gupperman »

Thank you! I tried to do that but it didn't work for me. At startup, the terminal window opens but doesn't do anything - the mouse is still slow, until I run the script manually. I guess I'm missing a parameter or something. Will try again when I learn more about macs. :)
Googa
Posts: 1
Joined: Wed Dec 09, 2009 1:39 am

Re: Tired of Mac OS X's mouse acceleration?

Post by Googa »

Jonathan, I can't thank you enough for figuring all this out! I'm a photographer who uses a high-resolution precise Razer mouse for photo editing (perhaps strange, but it works great for me!), who loves its performance in Windows... but on OSX, it was painful... until I stumbled upon your fix!

I had to register on this forum just to say thanks.

What can you do for the common cold?
fakefface
Posts: 1
Joined: Mon Jan 18, 2010 7:51 pm

Re: Tired of Mac OS X's mouse acceleration?

Post by fakefface »

OMG! Thank you SO MUCH Jonathan!
Works with Snow Leopard + Logitech :twisted:
bimbo80
Posts: 1
Joined: Thu Feb 11, 2010 10:47 pm

Re: Tired of Mac OS X's mouse acceleration?

Post by bimbo80 »

This did NOT work for me...
Followed the instructions and I ended up with a black screen with the text "No boot device available... Insert bootable disc and press any key" when I restarted my computer. The mouse acceleration did not go away either.
Any idea of what might have happened when I put the bundle as a start item?
zany
Posts: 2
Joined: Sun Jul 26, 2009 2:42 pm

Re: Tired of Mac OS X's mouse acceleration?

Post by zany »

bimbo80 wrote:ended up with a black screen with the text "No boot device available... Insert bootable disc and press any key"
That's a bios message from common PC hardware, right? A Mac wouldn't show that. Also I don't see how a login item would affect the boot process -- It's "Log In" not "Boot Up", isn't it? Better to play it safe and use the preference pane: http://triq.net/software/mouse-accelera ... e-mac-os-x
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Re: Tired of Mac OS X's mouse acceleration?

Post by Jonathan »

Er, none of that should or could have happened. Something else must be seriously messed up.

zany's 10.6 prefpane does work for me, so you might have better luck with that if your system isn't actually falling apart. It's a matter of taste though; it isn't any safer (if a bit friendlier with its GUI).
ˌɑrməˈɡɛˌtrɑn
jasjeet
Posts: 1
Joined: Mon Mar 29, 2010 6:20 pm

Re: Tired of Mac OS X's mouse acceleration?

Post by jasjeet »

Hi, ive tried your little program out, and it successfully removes the acceleration curve. But the mouse is not fast enough for me.
Im using the wired USB Microsoft Optical mouse. Touching the sliders in sys prefs removes the patch re-enabling the mouse acceleration so i cant increase the tracking speed there.

How can i make it a little faster?
Thanks
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Re: Tired of Mac OS X's mouse acceleration?

Post by Jonathan »

Nothing this hack can do for you, sorry. But note that this mapping is already as fast as linear can go without skipping pixels (or using a higher-resolution mouse). Maybe you can try to adjust to the speed though. Should be a bit more pleasant than acceleration anyway.
ˌɑrməˈɡɛˌtrɑn
SortKaffe
Posts: 1
Joined: Mon May 17, 2010 1:01 pm

Re: Tired of Mac OS X's mouse acceleration?

Post by SortKaffe »

Hi Jonathan
You script seams to work well without any hassles on a Magic Mouse. Acceleration is completely gone, super. One to one pixel mapping does however provide too much gain on a 15" screen. Can the script be modified to lower the gain?
Best regards Kaspar S. Meyer
Post Reply