Browse Source

make --orientation correspond to location of tablet buttons

master
evan 5 years ago
parent
commit
293d527e39
  1. 32
      remarkable_mouse/pynput.py
  2. 2
      remarkable_mouse/remarkable_mouse.py

32
remarkable_mouse/pynput.py

@ -18,25 +18,31 @@ e_code_stylus_pressure = 24 @@ -18,25 +18,31 @@ e_code_stylus_pressure = 24
# evcode_finger_ypos = 54
# evcode_finger_pressure = 58
stylus_width = 15725
stylus_height = 20951
# wacom digitizer dimensions
# FIXME - I found these limits experimentally. We can probably get the
# exact values off the filesystem somewhere
wacom_width = 15725
wacom_height = 20951
# touchscreen dimensions
# finger_width = 767
# finger_height = 1023
# remap wacom coordinates in various orientations
def remap(x, y, stylus_width, stylus_height, monitor, orientation, mode):
def remap(x, y, wacom_width, wacom_height, monitor, orientation, mode):
if orientation == 'vertical':
y = stylus_height - y
if orientation == 'bottom':
y = wacom_height - y
elif orientation == 'right':
x, y = y, x
stylus_width, stylus_height = stylus_height, stylus_width
x, y = wacom_height - y, wacom_width - x
wacom_width, wacom_height = wacom_height, wacom_width
elif orientation == 'left':
x, y = stylus_height - y, stylus_width - x
stylus_width, stylus_height = stylus_height, stylus_width
x, y = y, x
wacom_width, wacom_height = wacom_height, wacom_width
elif orientation == 'top':
x = wacom_width - x
ratio_width, ratio_height = monitor.width / stylus_width, monitor.height / stylus_height
ratio_width, ratio_height = monitor.width / wacom_width, monitor.height / wacom_height
if mode == 'fill':
scaling = max(ratio_width, ratio_height)
@ -44,8 +50,8 @@ def remap(x, y, stylus_width, stylus_height, monitor, orientation, mode): @@ -44,8 +50,8 @@ def remap(x, y, stylus_width, stylus_height, monitor, orientation, mode):
scaling = min(ratio_width, ratio_height)
return (
scaling * (x - (stylus_width - monitor.width / scaling) / 2),
scaling * (y - (stylus_height - monitor.height / scaling) / 2)
scaling * (x - (wacom_width - monitor.width / scaling) / 2),
scaling * (y - (wacom_height - monitor.height / scaling) / 2)
)
@ -99,7 +105,7 @@ def read_tablet(args, remote_device): @@ -99,7 +105,7 @@ def read_tablet(args, remote_device):
if new_x and new_y:
mapped_x, mapped_y = remap(
x, y,
stylus_width, stylus_height,
wacom_width, wacom_height,
monitor, args.orientation,
args.mode
)

2
remarkable_mouse/remarkable_mouse.py

@ -85,7 +85,7 @@ def main(): @@ -85,7 +85,7 @@ def main():
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('--orientation', default='right', choices=['top', 'left', 'right', 'bottom'], help="position of tablet buttons")
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)")
parser.add_argument('--evdev', action='store_true', default=False, help="use evdev to support pen tilt (requires root, no OSX support)")

Loading…
Cancel
Save