diff options
| -rw-r--r-- | mouse.lua | 124 | 
1 files changed, 80 insertions, 44 deletions
| @@ -1,28 +1,36 @@  mouse = {} -function mouse.bottom_left() -	local position = hs.mouse.getRelativePosition() -	position.x = position.x - 100 -	position.y = position.y + 100 -	hs.mouse.setRelativePosition(position) +function mouse.bottom_left(amount) +	return function() +		local position = hs.mouse.getRelativePosition() +		position.x = position.x - amount +		position.y = position.y + amount +		hs.mouse.setRelativePosition(position) +	end  end -function mouse.bottom() -	local position = hs.mouse.getRelativePosition() -	position.y = position.y + 100 -	hs.mouse.setRelativePosition(position) +function mouse.bottom(amount) +	return function() +		local position = hs.mouse.getRelativePosition() +		position.y = position.y + amount +		hs.mouse.setRelativePosition(position) +	end  end -function mouse.bottom_right() -	local position = hs.mouse.getRelativePosition() -	position.x = position.x + 100 -	position.y = position.y + 100 -	hs.mouse.setRelativePosition(position) +function mouse.bottom_right(amount) +	return function() +		local position = hs.mouse.getRelativePosition() +		position.x = position.x + amount +		position.y = position.y + amount +		hs.mouse.setRelativePosition(position) +	end  end -function mouse.left() -	local position = hs.mouse.getRelativePosition() -	position.x = position.x - 100 -	hs.mouse.setRelativePosition(position) +function mouse.left(amount) +	return function() +		local position = hs.mouse.getRelativePosition() +		position.x = position.x - amount +		hs.mouse.setRelativePosition(position) +	end  end  function mouse.click() @@ -32,30 +40,38 @@ function mouse.click()  	-- TODO: key down is mouse down, key up is mouse up  end -function mouse.right() -	local position = hs.mouse.getRelativePosition() -	position.x = position.x + 100 -	hs.mouse.setRelativePosition(position) +function mouse.right(amount) +	return function() +		local position = hs.mouse.getRelativePosition() +		position.x = position.x + amount +		hs.mouse.setRelativePosition(position) +	end  end -function mouse.top_left() -	local position = hs.mouse.getRelativePosition() -	position.x = position.x - 100 -	position.y = position.y - 100 -	hs.mouse.setRelativePosition(position) +function mouse.top_left(amount) +	return function() +		local position = hs.mouse.getRelativePosition() +		position.x = position.x - amount +		position.y = position.y - amount +		hs.mouse.setRelativePosition(position) +	end  end -function mouse.top() -	local position = hs.mouse.getRelativePosition() -	position.y = position.y - 100 -	hs.mouse.setRelativePosition(position) +function mouse.top(amount) +	return function() +		local position = hs.mouse.getRelativePosition() +		position.y = position.y - amount +		hs.mouse.setRelativePosition(position) +	end  end -function mouse.top_right() -	local position = hs.mouse.getRelativePosition() -	position.x = position.x + 100 -	position.y = position.y - 100 -	hs.mouse.setRelativePosition(position) +function mouse.top_right(amount) +	return function() +		local position = hs.mouse.getRelativePosition() +		position.x = position.x + amount +		position.y = position.y - amount +		hs.mouse.setRelativePosition(position) +	end  end @@ -64,12 +80,32 @@ mouse_mode:bind({'ctrl', 'option', 'shift'}, 'm', 'Mouse Off', function()  	mouse_mode:exit()  end) -mouse_mode:bind({}, 'pad1', mouse.bottom_left, nil, mouse.bottom_left) -mouse_mode:bind({}, 'pad2', mouse.bottom, nil, mouse.bottom) -mouse_mode:bind({}, 'pad3', mouse.bottom_right, nil, mouse.bottom_right) -mouse_mode:bind({}, 'pad4', mouse.left, nil, mouse.left) +mouse_mode:bind({}, 'pad1', mouse.bottom_left(100), nil, mouse.bottom_left(100)) +mouse_mode:bind({}, 'pad2', mouse.bottom(100), nil, mouse.bottom(100)) +mouse_mode:bind({}, 'pad3', mouse.bottom_right(100), nil, mouse.bottom_right(100)) +mouse_mode:bind({}, 'pad4', mouse.left(100), nil, mouse.left(100))  mouse_mode:bind({}, 'pad5', mouse.click) -mouse_mode:bind({}, 'pad6', mouse.right, nil, mouse.right) -mouse_mode:bind({}, 'pad7', mouse.top_left, nil, mouse.top_left) -mouse_mode:bind({}, 'pad8', mouse.top, nil, mouse.top) -mouse_mode:bind({}, 'pad9', mouse.top_right, nil, mouse.top_right) +mouse_mode:bind({}, 'pad6', mouse.right(100), nil, mouse.right(100)) +mouse_mode:bind({}, 'pad7', mouse.top_left(100), nil, mouse.top_left(100)) +mouse_mode:bind({}, 'pad8', mouse.top(100), nil, mouse.top(100)) +mouse_mode:bind({}, 'pad9', mouse.top_right(100), nil, mouse.top_right(100)) + +mouse_mode:bind({'shift'}, 'pad1', mouse.bottom_left(10), nil, mouse.bottom_left(10)) +mouse_mode:bind({'shift'}, 'pad2', mouse.bottom(10), nil, mouse.bottom(10)) +mouse_mode:bind({'shift'}, 'pad3', mouse.bottom_right(10), nil, mouse.bottom_right(10)) +mouse_mode:bind({'shift'}, 'pad4', mouse.left(10), nil, mouse.left(10)) +mouse_mode:bind({'shift'}, 'pad5', mouse.click) +mouse_mode:bind({'shift'}, 'pad6', mouse.right(10), nil, mouse.right(10)) +mouse_mode:bind({'shift'}, 'pad7', mouse.top_left(10), nil, mouse.top_left(10)) +mouse_mode:bind({'shift'}, 'pad8', mouse.top(10), nil, mouse.top(10)) +mouse_mode:bind({'shift'}, 'pad9', mouse.top_right(10), nil, mouse.top_right(10)) + +mouse_mode:bind({'option'}, 'pad1', mouse.bottom_left(1), nil, mouse.bottom_left(1)) +mouse_mode:bind({'option'}, 'pad2', mouse.bottom(1), nil, mouse.bottom(1)) +mouse_mode:bind({'option'}, 'pad3', mouse.bottom_right(1), nil, mouse.bottom_right(1)) +mouse_mode:bind({'option'}, 'pad4', mouse.left(1), nil, mouse.left(1)) +mouse_mode:bind({'option'}, 'pad5', mouse.click) +mouse_mode:bind({'option'}, 'pad6', mouse.right(1), nil, mouse.right(1)) +mouse_mode:bind({'option'}, 'pad7', mouse.top_left(1), nil, mouse.top_left(1)) +mouse_mode:bind({'option'}, 'pad8', mouse.top(1), nil, mouse.top(1)) +mouse_mode:bind({'option'}, 'pad9', mouse.top_right(1), nil, mouse.top_right(1)) | 
