Browse Source

add --mode

master
evan 4 years ago
parent
commit
7459ae2f49
  1. 15
      remarkable_mouse/pynput.py
  2. 1
      remarkable_mouse/remarkable_mouse.py

15
remarkable_mouse/pynput.py

@ -25,7 +25,7 @@ stylus_height = 20951 @@ -25,7 +25,7 @@ stylus_height = 20951
# remap wacom coordinates in various orientations
def fit(x, y, stylus_width, stylus_height, monitor, orientation):
def remap(x, y, stylus_width, stylus_height, monitor, orientation, mode):
if orientation == 'vertical':
y = stylus_height - y
@ -37,7 +37,11 @@ def fit(x, y, stylus_width, stylus_height, monitor, orientation): @@ -37,7 +37,11 @@ def fit(x, y, stylus_width, stylus_height, monitor, orientation):
stylus_width, stylus_height = stylus_height, stylus_width
ratio_width, ratio_height = monitor.width / stylus_width, monitor.height / stylus_height
scaling = ratio_width if ratio_width > ratio_height else ratio_height
if mode == 'fill':
scaling = max(ratio_width, ratio_height)
else:
scaling = min(ratio_width, ratio_height)
return (
scaling * (x - (stylus_width - monitor.width / scaling) / 2),
@ -93,7 +97,12 @@ def read_tablet(args, remote_device): @@ -93,7 +97,12 @@ def read_tablet(args, remote_device):
# only move when x and y are updated for smoother mouse
if new_x and new_y:
mapped_x, mapped_y = fit(x, y, stylus_width, stylus_height, monitor, args.orientation)
mapped_x, mapped_y = remap(
x, y,
stylus_width, stylus_height,
monitor, args.orientation,
args.mode
)
mouse.move(
monitor.x + mapped_x - mouse.position[0],
monitor.y + mapped_y - mouse.position[1]

1
remarkable_mouse/remarkable_mouse.py

@ -73,6 +73,7 @@ def main(): @@ -73,6 +73,7 @@ def main():
parser.add_argument('--key', type=str, metavar='PATH', help="ssh private key")
parser.add_argument('--password', default=None, type=str, help="ssh password")
parser.add_argument('--address', default='10.11.99.1', type=str, help="device address")
parser.add_argument('--mode', default='fit', choices=['fit', 'fill'])
parser.add_argument('--orientation', default='left', choices=['vertical', 'left', 'right'])
parser.add_argument('--monitor', default=0, type=int, metavar='NUM', help="monitor to use")
parser.add_argument('--threshold', default=1000, type=int, help="stylus pressure threshold (default 1000)")

Loading…
Cancel
Save