Mac Mouse/Trackpad Speed Programmatically

我的未来我决定 提交于 2019-12-10 10:09:26

问题


I'm trying to change the mouse tracking speed (Notice: Not acceleration) for an application I'm working on. I've searched everywhere for a way to do this, but couldn't find anything. I suspect that has to do with the value I give in this function on the IOKit/hidsystem Framework:

IOHIDSetAccelerationWithKey(handle, CFSTR(kIOHIDMouseAccelerationType), mouseAcceleration);

Being mouseAcceleration the value, I suspect there is a hex value that defines both acceleration and speed.

Does anyone came across this problem and could help me?

Thanks in advance


回答1:


Working example in swift:

func getAcceleration() -> Double {
    var speed:Double = 0
    IOHIDGetAccelerationWithKey(NXOpenEventStatus(), kIOHIDTrackpadAccelerationType, &speed)
    return speed
}

func setAcceleration(_ speed: Double) {
    IOHIDSetAccelerationWithKey(NXOpenEventStatus(), kIOHIDTrackpadAccelerationType, speed)
}

Source: http://lists.apple.com/archives/usb/2004/Aug/msg00056.html




回答2:


You can try to make NSTrackingArea and change mouse position after you get new mouse position.



来源:https://stackoverflow.com/questions/10448843/mac-mouse-trackpad-speed-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!