Browse Source

Merge pull request #7 from bordaigorl/fix-events

Fix too many PRESS events issue
master
Evan Widloski 6 years ago committed by GitHub
parent
commit
b46c1cc075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      remarkable_mouse/remarkable_mouse.py

12
remarkable_mouse/remarkable_mouse.py

@ -35,6 +35,10 @@ mouse = Controller() @@ -35,6 +35,10 @@ mouse = Controller()
logging.basicConfig(format='%(message)s')
log = logging.getLogger(__name__)
# mouse state
LIFTED = 0
PRESSED = 1
# remap wacom coordinates in various orientations
def fit(x, y, stylus_width, stylus_height, monitor, orientation):
@ -101,6 +105,7 @@ def open_eventfile(args, file='/dev/input/event0'): @@ -101,6 +105,7 @@ def open_eventfile(args, file='/dev/input/event0'):
def read_tablet(args):
"""Loop forever and map evdev events to mouse"""
state = LIFTED
new_x = new_y = False
monitor = get_monitors()[args.monitor]
@ -129,10 +134,17 @@ def read_tablet(args): @@ -129,10 +134,17 @@ def read_tablet(args):
if e_code == e_code_stylus_pressure:
log.debug('\t\t{}'.format(e_value))
if e_value > args.threshold:
if state == LIFTED:
log.info('PRESS')
state = PRESSED
mouse.press(Button.left)
else:
if state == PRESSED:
log.info('RELEASE')
state = LIFTED
mouse.release(Button.left)
# 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)

Loading…
Cancel
Save