the mouse cursor starts off way too slow, takes too long to accelerate and the max speed could also be higher.
So I'd like to propose that this plug-in is changed from "core" to a normal plug-in with an options page for the mouse speed/acceleration.
This changed "Mouse" class should be sufficient to get it configurable,
but even after changing the plug-in "kind" to "other" I can't add it because eventghost says it is already loaded.
Code: Select all
class Mouse(eg.PluginBase):
def __init__(self):
self.AddEvents()
self.AddAction(GoDirection)
self.AddAction(LeftButton)
self.AddAction(MiddleButton)
self.AddAction(RightButton)
self.AddAction(LeftDoubleClick)
self.AddAction(RightDoubleClick)
self.AddAction(ToggleLeftButton)
self.AddAction(MoveAbsolute)
self.AddAction(MoveRelative)
self.AddAction(MouseWheel)
def __start__(self, initSpeed = 60, maxSpeed = 7000, accelerationFactor = 3, accelerationStopFactor = 100):
self.thread = MouseThread()
self.thread.iniSpeed = initSpeed * 0.001
self.thread.maxSpeed = maxSpeed * 0.001
self.thread.accelerationFactor = accelerationFactor * 0.001
self.thread.accelerationStopFactor = accelerationStopFactor * 0.001
self.leftMouseButtonDown = False
self.lastMouseEvent = None
self.mouseButtonWasBlocked = [False, False, False, False, False]
SetMouseCallback(self.MouseCallBack)
@eg.LogIt
def __stop__(self):
SetMouseCallback(None)
self.thread.receiveQueue.put(-1)
@eg.LogIt
def __close__(self):
pass
def MouseCallBack(self, buttonName, buttonNum, param):
if param:
if self.lastMouseEvent:
self.lastMouseEvent.SetShouldEnd()
shouldBlock = HasActiveHandler("Mouse." + buttonName)
self.mouseButtonWasBlocked[buttonNum] = shouldBlock
self.lastMouseEvent = self.TriggerEnduringEvent(buttonName)
return shouldBlock
else:
if self.lastMouseEvent:
self.lastMouseEvent.SetShouldEnd()
return self.mouseButtonWasBlocked[buttonNum]
return False
def Configure(self, initSpeed = 60, maxSpeed = 7000, accelerationFactor = 3, accelerationStopFactor = 100):
panel = eg.ConfigPanel(self, resizable=True)
optionsSizer = wx.GridBagSizer(0, 5)
initSpeedLabel = wx.StaticText(panel, -1, 'Initial mouse speed')
optionsSizer.Add(initSpeedLabel, (0, 0))
initSpeedSpin = eg.SpinIntCtrl(panel, -1, initSpeed, 10, 2000)
optionsSizer.Add(initSpeedSpin, (1, 0))
maxSpeedLabel = wx.StaticText(panel, -1, 'Maximum mouse speed')
optionsSizer.Add(maxSpeedLabel, (3, 0))
maxSpeedSpin = eg.SpinIntCtrl(panel, -1, maxSpeed, 4000, 32000)
optionsSizer.Add(maxSpeedSpin, (4, 0))
accelerationFactorLabel = wx.StaticText(panel, -1, 'Acceleration factor')
optionsSizer.Add(accelerationFactorLabel, (6, 0))
accelerationFactorSpin = eg.SpinIntCtrl(panel, -1, accelerationFactor, 1, 200)
optionsSizer.Add(accelerationFactorSpin, (7, 0))
accelerationStopFactorLabel = wx.StaticText(panel, -1, 'Acceleration stop factor')
optionsSizer.Add(accelerationStopFactorLabel, (9, 0))
accelerationStopFactorSpin = eg.SpinIntCtrl(panel, -1, accelerationStopFactor, 50, 2000)
optionsSizer.Add(accelerationStopFactorSpin, (10, 0))
panel.sizer.Add(optionsSizer, 0, wx.TOP, 10)
while panel.Affirmed():
panel.SetResult(
initSpeedSpin.GetValue(),
maxSpeedSpin.GetValue(),
accelerationFactorSpin.GetValue(),
accelerationStopFactorSpin.GetValue()
)