Browse Source

fix not working for non basic ssh setups (paramiko look for keys true), add cool new mapping mode that forces 1:1 aspect ratio in both spaces

master
Julia Luna 2 years ago
parent
commit
3e562bebec
Signed by: xenua
GPG Key ID: 6A0C04FA9A7D7582
  1. 25
      remarkable_mouse/common.py
  2. 20
      remarkable_mouse/evdev.py
  3. 5
      remarkable_mouse/remarkable_mouse.py

25
remarkable_mouse/common.py

@ -144,6 +144,31 @@ def remap(x, y, wacom_max_x, wacom_max_y, monitor_width, @@ -144,6 +144,31 @@ def remap(x, y, wacom_max_x, wacom_max_y, monitor_width,
scaling_y * (y - (wacom_max_y - monitor_height / scaling_y) / 2)
)
def the_cooler_remap(x, y, monitor: Monitor):
single_mon_ratio = monitor.width / monitor.height
input_ratio = wacom_max_x / wacom_max_y
if single_mon_ratio > input_ratio: # monitor is wider than input in ratio, set yscale >1
xscale = 1.0
yscale = single_mon_ratio / input_ratio
else: # opposite: monitor is taller than input
yscale = 1.0
xscale = single_mon_ratio / input_ratio
return (
x * xscale,
y * yscale
)
def cool_monitor_mapping(x, y, monitor, wmax, hmax):
return (
x * monitor.width / wmax,
y * monitor.height / hmax
)
# log evdev event to console
def log_event(e_time, e_millis, e_type, e_code, e_value):
log.debug('{}.{:0>6} - {: <9} {: <15} {: >6}'.format(

20
remarkable_mouse/evdev.py

@ -8,7 +8,7 @@ from socket import timeout as TimeoutError @@ -8,7 +8,7 @@ from socket import timeout as TimeoutError
import libevdev
from .codes import codes, types
from .common import get_monitor, remap, wacom_max_x, wacom_max_y, log_event
from .common import get_monitor, remap, wacom_max_x, wacom_max_y, log_event, the_cooler_remap, cool_monitor_mapping
logging.basicConfig(format='%(message)s')
log = logging.getLogger('remouse')
@ -118,12 +118,18 @@ def read_tablet(rm_inputs, *, orientation, monitor_num, region, threshold, mode) @@ -118,12 +118,18 @@ def read_tablet(rm_inputs, *, orientation, monitor_num, region, threshold, mode)
if codes[e_type][e_code] == 'ABS_Y':
y = e_value
mapped_x, mapped_y = remap(
x, y,
wacom_max_x, wacom_max_y,
wacom_max_x * (monitor.width / tot_width), wacom_max_y * (monitor.height / tot_height),
mode, orientation
)
if mode == 'cool':
mapx, mapy = the_cooler_remap(x, y, monitor)
mapped_x, mapped_y = cool_monitor_mapping(mapx, mapy, monitor, tot_width, tot_height)
else:
mapped_x, mapped_y = remap(
x, y,
wacom_max_x, wacom_max_y,
# 20k something | presumably 3840 | 7680 15k something,
# -> 10k something presumably 15k something
wacom_max_x * (monitor.width / tot_width), wacom_max_y * (monitor.height / tot_height),
mode, orientation
)
mapped_x += wacom_max_x * (monitor.x / tot_width)
mapped_y += wacom_max_y * (monitor.y / tot_height)

5
remarkable_mouse/remarkable_mouse.py

@ -115,10 +115,11 @@ def main(): @@ -115,10 +115,11 @@ 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='fill', choices=['fit', 'fill', 'stretch'], help="""Scale setting.
parser.add_argument('--mode', default='fill', choices=['fit', 'fill', 'stretch', 'cool'], help="""Scale setting.
Fit (default): take up the entire tablet, but not necessarily the entire monitor.
Fill: take up the entire monitor, but not necessarily the entire tablet.
Stretch: take up both the entire tablet and monitor, but don't maintain aspect ratio.""")
Stretch: take up both the entire tablet and monitor, but don't maintain aspect ratio.
Cool: fit the entire monitor on the tablet, ensure 1:1 aspect ratio on both.""")
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 output to")
parser.add_argument('--region', action='store_true', default=False, help="Use a GUI to position the output area. Overrides --monitor")

Loading…
Cancel
Save