make --orientation correspond to location of tablet buttons
This commit is contained in:
@@ -18,25 +18,31 @@ e_code_stylus_pressure = 24
|
|||||||
# evcode_finger_ypos = 54
|
# evcode_finger_ypos = 54
|
||||||
# evcode_finger_pressure = 58
|
# evcode_finger_pressure = 58
|
||||||
|
|
||||||
stylus_width = 15725
|
# wacom digitizer dimensions
|
||||||
stylus_height = 20951
|
# 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_width = 767
|
||||||
# finger_height = 1023
|
# finger_height = 1023
|
||||||
|
|
||||||
|
|
||||||
# remap wacom coordinates in various orientations
|
# 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':
|
if orientation == 'bottom':
|
||||||
y = stylus_height - y
|
y = wacom_height - y
|
||||||
elif orientation == 'right':
|
elif orientation == 'right':
|
||||||
x, y = y, x
|
x, y = wacom_height - y, wacom_width - x
|
||||||
stylus_width, stylus_height = stylus_height, stylus_width
|
wacom_width, wacom_height = wacom_height, wacom_width
|
||||||
elif orientation == 'left':
|
elif orientation == 'left':
|
||||||
x, y = stylus_height - y, stylus_width - x
|
x, y = y, x
|
||||||
stylus_width, stylus_height = stylus_height, stylus_width
|
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':
|
if mode == 'fill':
|
||||||
scaling = max(ratio_width, ratio_height)
|
scaling = max(ratio_width, ratio_height)
|
||||||
@@ -44,8 +50,8 @@ def remap(x, y, stylus_width, stylus_height, monitor, orientation, mode):
|
|||||||
scaling = min(ratio_width, ratio_height)
|
scaling = min(ratio_width, ratio_height)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
scaling * (x - (stylus_width - monitor.width / scaling) / 2),
|
scaling * (x - (wacom_width - monitor.width / scaling) / 2),
|
||||||
scaling * (y - (stylus_height - monitor.height / scaling) / 2)
|
scaling * (y - (wacom_height - monitor.height / scaling) / 2)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -99,7 +105,7 @@ def read_tablet(args, remote_device):
|
|||||||
if new_x and new_y:
|
if new_x and new_y:
|
||||||
mapped_x, mapped_y = remap(
|
mapped_x, mapped_y = remap(
|
||||||
x, y,
|
x, y,
|
||||||
stylus_width, stylus_height,
|
wacom_width, wacom_height,
|
||||||
monitor, args.orientation,
|
monitor, args.orientation,
|
||||||
args.mode
|
args.mode
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ def main():
|
|||||||
parser.add_argument('--password', default=None, type=str, help="ssh password")
|
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('--address', default='10.11.99.1', type=str, help="device address")
|
||||||
parser.add_argument('--mode', default='fit', choices=['fit', 'fill'])
|
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('--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('--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)")
|
parser.add_argument('--evdev', action='store_true', default=False, help="use evdev to support pen tilt (requires root, no OSX support)")
|
||||||
|
|||||||
Reference in New Issue
Block a user