Esempio n. 1
0
    def draw(self, canvas):

        if mouse.origin == None:
            print("Is the tobii disconnected?")
            return

        pos = smooth_location()

        # Append the smoothed dot to history > to smooth it some more
        mouse.xy_hist.append(Point2d(pos[0], pos[1]))
        mouse.xy_hist.append(Point2d(pos[0], pos[1]))

        if pos == None: return

        paint = canvas.paint

        paint.stroke_width = 1
        paint.style = paint.Style.STROKE
        paint.color = '44444444'

        canvas.draw_circle(pos[0], pos[1], 7)

        paint.style = paint.Style.FILL
        paint.color = '99999944'
        canvas.draw_circle(pos[0], pos[1], 7)
Esempio n. 2
0
    def __init__(self):
        tracker.register("gaze", self.on_gaze)

        self.xy_hist = [Point2d(0, 0)]
        self.origin = Point2d(0, 0)

        canvas.register("overlay", self.draw)
        self.enabled = True
    def on_pop(self, noise):
        if len(mouse.eye_hist) < 2:
            return
        if noise != 'hiss_start':
            return
        now = time.time()
        if self.state == STATE_IDLE:
            if now - self.last_click < config.double_click:
                ctrl.mouse_click(hold=32000)
                return

            l, r = mouse.eye_hist[-1]
            p = (l.gaze + r.gaze) / 2
            main_gaze = -0.02 < p.x < 1.02 and -0.02 < p.y < 1.02 and bool(
                l or r)
            if not main_gaze:
                pass  # return

            ctrl.cursor_visible(False)

            self.gaze = eye_config.size_px * p
            capture = self.gaze - (config.screen_area / 2)
            capture.x = min(max(capture.x, 0),
                            main_screen.width - config.screen_area.x)
            capture.y = min(max(capture.y, 0),
                            main_screen.height - config.screen_area.y)
            self.rect = (capture.x, capture.y, config.screen_area.x,
                         config.screen_area.y)
            self.pos = self.gaze - (config.screen_area * config.img_scale) / 2
            self.pos.x = min(
                max(self.pos.x, 0),
                main_screen.width - config.screen_area.x * config.img_scale)
            self.pos.y = min(
                max(self.pos.y, 0),
                main_screen.height - config.screen_area.y * config.img_scale)
            self.size = Point2d(config.screen_area.x * config.img_scale,
                                config.screen_area.y * config.img_scale)
            self.off = Point2d(0, 0)

            self.frame = 0
            self.canvas = canvas.Canvas(self.pos.x, self.pos.y, self.size.x,
                                        self.size.y)
            if not config.live:
                self.capture()
            self.canvas.register('draw', self.draw)
            self.state = STATE_OVERLAY
        elif self.state == STATE_OVERLAY:
            self.state = STATE_IDLE
            ctrl.cursor_visible(True)
            self.canvas.unregister('draw', self.draw)
            self.canvas.close()
            self.canvas = None
            dot, origin = self.get_pos()
            if origin:
                ctrl.mouse(origin.x, origin.y)
                ctrl.mouse_click(hold=32000)
                self.last_click = time.time()
Esempio n. 4
0
 def __init__(self):
     self.hiss_start = 0
     self.hiss_last = 0
     self.button = 0
     self.mouse_origin = Point2d(0, 0)
     self.mouse_last = Point2d(0, 0)
     self.dragging = False
     self.short_click = True
     self.morse_mode = False
     self.lens_mode = False
Esempio n. 5
0
    def __init__(self):
        self.hiss_start = 0
        self.hiss_last = 0
        self.button = 0
        self.mouse_origin = Point2d(0, 0)
        self.mouse_last = Point2d(0, 0)
        self.dragging = False

        tap.register(tap.MMOVE, self.on_move)
        noise.register('noise', self.on_noise)
Esempio n. 6
0
    def __init__(self):

        self.xy_hist = [Point2d(0, 0)]
        self.origin = Point2d(0, 0)

        # tracker.register('gaze', self.on_gaze)
        # canvas.register('overlay', self.draw)

        self.enabled = False
        self.alpha = not_transparent
        self.size = regular_size
    def get_pos(self):
        dot = Point2d(0, 0)
        hist = mouse.eye_hist[-config.eye_avg:]
        for l, r in hist:
            dot += (l.gaze + r.gaze) / 2
        dot /= len(hist)
        dot *= Point2d(main_screen.width, main_screen.height)

        off = dot - (self.pos - self.off)
        origin = self.img.rect.pos + off / config.img_scale
        if self.img.rect.contains(origin.x, origin.y):
            return dot, origin
        return None, None
Esempio n. 8
0
 def on_move(self, typ, e):
     if typ != tap.MMOVE: return
     p = Point2d(e.x, e.y)
     on_main = is_on_main(p)
     if not on_main:
         self.saved_mouse = p
     self.main_mouse = on_main
class config:
    screen_area = Point2d(400, 300)
    img_scale = 3
    img_alpha = 0.9
    eye_avg = 20
    double_click = 0.25
    frames = 10
    live = True
 def __init__(self):
     self.state = STATE_IDLE
     self.img = None
     self.handle_size = Point2d(0, 0)
     self.last_click = 0
     self.enabled = False
     self.rect = None
     self.canvas = None
Esempio n. 11
0
 def on_move(self, typ, e):
     if typ != tap.MMOVE: return
     self.mouse_last = pos = Point2d(e.x, e.y)
     if self.hiss_start and not self.dragging:
         if (pos - self.mouse_origin).len() > 10:
             self.dragging = True
             self.button = 0
             x, y = self.mouse_origin.x, self.mouse_origin.y
             ctrl.mouse(x, y)
             ctrl.mouse_click(x, y, button=0, down=True)
Esempio n. 12
0
 def on_click(self, typ, e):
     # print(typ, e.flags & tap.UP)
     if e.flags & tap.UP:
         p = Point2d(e.x, e.y)
         # print(f"Checking for left/right saved update {p}")
         if self.right is None or (p.x < main.x and self.left is not None):
             # print("Updated left")
             self.saved_mouse_left = p
         elif p.x > main.x + 30 and self.right is not None:
             # print("Updated right")
             self.saved_mouse_right = p
Esempio n. 13
0
    def draw(self, canvas):
        paint = canvas.paint
        paint.color = "ff00ff"
        paint.stroke_width = 5
        # print(paint.__dir__())
        now = time.time()
        pos = Point2d(self.radius, 0)
        pos.rot(self.angle)

        ctrl.mouse_move(pos.x, pos.y)
        canvas.draw_line(self.center_x, self.center_y, pos.x, pos.y)
        self.last_draw = now
Esempio n. 14
0
    def draw(self, canvas):

        if mouse.origin == None:
            print("Is the tobii disconnected?")
            return

        # # avoid drawing distracting circle
        # if mouse.alpha == transparent:
        #     return

        pos = smooth_location()

        # Append the smoothed dot to history > to smooth it some more
        mouse.xy_hist.append(Point2d(pos[0], pos[1]))
        mouse.xy_hist.append(Point2d(pos[0], pos[1]))

        if pos == None: return

        paint = canvas.paint

        # paint.stroke_width = 0
        # paint.style = paint.Style.STROKE
        # paint.color = 'cbd14d40'

        # canvas.draw_circle(pos[0], pos[1], 25)

        paint.style = paint.Style.FILL

        now = time.time()
        if last_click is not None and now - last_click < 0.20:
            color = '044d63'
            alpha = '99'
        else:
            color = 'cbd14d'
            alpha = self.alpha

        paint.color = color + alpha
        # canvas.draw_circle(pos[0], pos[1], 25)
        canvas.draw_circle(pos[0], pos[1], self.size)
Esempio n. 15
0
 def __init__(self):
     """Set up sleep states"""
     self.nosignal = 0  # Number of ticks there have been no signal
     self.sleeping = False
     self.main_screen = ui.main_screen()
     self.size_px = Point2d(self.main_screen.width, self.main_screen.height)
     self.settings = {
         "max_eyeless_ticks": settings.get(
             "user.mouse_sleep_tracker_timeout_frames"
         ),
         "sleep_mode": settings.get("user.mouse_sleep_tracker_sleep_mode"),
         "suspend_screen": settings.get("user.mouse_sleep_tracker_suspend_screen"),
     }
Esempio n. 16
0
 def __init__(self):
     if len(ui.screens()) == 1:
         return
     tap.register(tap.MMOVE, self.on_move)
     tap.register(tap.MCLICK, self.on_click)
     tracker.register("gaze", self.on_gaze)
     self.left = None
     self.right = None
     if len(ui.screens()) >= 2:
         print("Have left screen")
         self.left = ui.screens()[1]
         self.saved_mouse_left = Point2d(
             self.left.x + self.left.width // 2,
             self.left.y + self.left.height // 2)
     if len(ui.screens()) == 3:
         print("Have right screen")
         self.right = ui.screens()[2]
         self.saved_mouse_right = Point2d(
             self.right.x + self.right.width // 2,
             self.right.y + self.right.height // 2)
     self.main_mouse = False
     self.main_gaze = False
     self.restore_counter = 0
    def draw(self, canvas):
        if not self.canvas:
            return False
        if config.live and self.rect:
            self.capture()
        self.frame += 1
        if self.frame < config.frames:
            t = ((self.frame + 1) / config.frames)**2

            anim_pos_from = Point2d(self.rect[0], self.rect[1])
            anim_pos_to = Point2d(canvas.x, canvas.y)
            anim_size_from = config.screen_area
            anim_size_to = Point2d(canvas.width, canvas.height)

            pos = anim_pos_from + (anim_pos_to - anim_pos_from) * t
            size = anim_size_from + (anim_size_to - anim_size_from) * t

            dst = Rect(pos.x, pos.y, size.x, size.y)
        elif self.frame == config.frames:
            self.canvas.set_panel(True)
            dst = Rect(canvas.x, canvas.y, canvas.width, canvas.height)
        else:
            dst = Rect(canvas.x, canvas.y, canvas.width, canvas.height)
        src = Rect(0, 0, self.img.width, self.img.height)
        canvas.draw_image_rect(self.img, src, dst)

        dot, origin = self.get_pos()
        if not dot: return
        paint = canvas.paint
        paint.style = paint.Style.FILL
        paint.color = 'ffffff'
        canvas.draw_circle(dot.x, dot.y, config.img_scale + 1)
        canvas.draw_circle(origin.x, origin.y, 2)
        paint.color = '000000'
        canvas.draw_circle(dot.x, dot.y, config.img_scale)
        canvas.draw_circle(origin.x, origin.y, 1)
        ctrl.mouse(origin.x, origin.y)
Esempio n. 18
0
    def __init__(self):
        if len(ui.screens()) == 1:
            return
        tap.register(tap.MMOVE, self.on_move)
        tracker.register("gaze", self.on_gaze)
        self.top = None

        if len(ui.screens()) >= 2:
            print("Have top screen")
            self.top = ui.screens()[1]
            self.saved_mouse_top = Point2d(self.top.x + self.top.width // 2,
                                           self.top.y + self.top.height // 2)
        self.main_mouse = False
        self.main_gaze = False
        self.restore_counter = 0
Esempio n. 19
0
    def on_gaze(self, b):

        l = b["Left Eye 2D Gaze Point"]['$point2d']
        r = b["Right Eye 2D Gaze Point"]['$point2d']

        x = (l["x"] + r["x"]) / 2
        y = (l["y"] + r["y"]) / 2

        # Don't pass edges of screen
        if x < 0: x = 0
        if y < 0: y = 0

        # Multiply by screen width
        x *= size_px.x
        y *= size_px.y

        self.origin = Point2d(x, y)
        self.xy_hist.append(self.origin)
        self.xy_hist = self.xy_hist[-200:]
Esempio n. 20
0
    def __init__(self):
        # tweakable variables
        self.beep = False  # requires windows
        self.two_blinks = (
            True  # depricated - one blink means you will have lots of misclicks
        )
        self.magic = 24  # works on 4c might not be optimized # CHANGME if not clicking accuratley (won't work on 4C speed probably like =35)
        self.scroll_sensitivity = 1  # I like it kinda fast. 6-7 slower.

        # state tracking
        self.second = False
        self.blinking = False
        self.nosignal = 0
        self.sleep = False
        self.right_px, self.right_py = 0, 0
        self.lcurclosed = 0
        self.rcurclosed = 0
        self.signal = 0
        self.left_px, self.left_py = 0, 0
        self.counter = 0
        self.invalid_left = 0
        self.invalid_right = 0
        self.left_closed_count = 0
        self.right_closed_count = 0
        self.expire = 700  # lower if you blink twice a lot
        self.focus_sensitivity = 48  # can go lower on 4C Tobii 5 recomended = 50
        self.MAXSIZE = 120  # if memory starts to be a problem
        self.eye_history = []
        self.main_screen = ui.main_screen()
        self.size_px = Point2d(self.main_screen.width, self.main_screen.height)
        self.get_time = lambda: int(round(time() * 1000))
        self.current_time = 0
        self.first_blink = 0
        self.eyes = True
        self.last_blink = False
        self.right_history = self.momentum_state()
        self.left_history = self.momentum_state()
        self.right_open = 1
        self.left_open = 1
Esempio n. 21
0
    def draw(self, canvas):
        paint = canvas.paint
        paint.color = "ff00ff"
        paint.stroke_width = 5
        # print(paint.__dir__())
        now = time.time()
        elapsed = now - self.last_draw
        hiss_dt = now - self.hiss_start
        c = cos(self.angle)
        s = sin(self.angle)
        delta = Point2d(self.speed * c, self.speed * s)
        # print(delta)
        delta = delta.apply(self.accel, hiss_dt / 100)
        # print(delta)
        self.offset_x += delta.x
        if self.offset_x < 0:
            self.offset_x = 0
        elif self.offset_x > self.main_screen.width:
            self.offset_x = self.main_screen.width
        self.offset_y += delta.y
        if self.offset_y < 0:
            self.offset_y = 0
        elif self.offset_y > self.main_screen.height:
            self.offset_y = self.main_screen.height
        ctrl.mouse_move(self.offset_x, self.offset_y)
        line1 = self.rotate(c, s, 0, 0, -2 * SIZE, SIZE)
        line2 = self.rotate(c, s, 0, 0, -2 * SIZE, -SIZE)
        line3 = (line1[2], line1[3], line2[2], line2[3])

        canvas.draw_line(self.offset_x + line1[0], self.offset_y + line1[1],
                         self.offset_x + line1[2], self.offset_y + line1[3])
        canvas.draw_line(self.offset_x + line2[0], self.offset_y + line2[1],
                         self.offset_x + line2[2], self.offset_y + line2[3])
        canvas.draw_line(self.offset_x + line3[0], self.offset_y + line3[1],
                         self.offset_x + line3[2], self.offset_y + line3[3])
        self.last_draw = now
Esempio n. 22
0
def DeriveScreenArea(img_scale, zoom_box_width, zoom_box_height):
    """Derive the area to zoom in on from the target window and zoom level."""
    return Point2d(
        round(zoom_box_width / img_scale), round(zoom_box_height / img_scale)
    )
Esempio n. 23
0
            if debounced._timer is None:
                debounced._timer = threading.Timer(wait - time_since_last_call,
                                                   call_it)
                debounced._timer.start()

        debounced._timer = None
        debounced._last_call = 0

        return debounced

    return decorator


screen = ui.main_screen()
size_px = Point2d(screen.width, screen.height)

transparent = '01'
not_transparent = '40'

regular_size = 7
demo_size = 30

last_click = None


# Shows crazy circles
def smooth_location():

    # Calculate smooth location of point
    x = mouse.origin.x
Esempio n. 24
0
 def on_move(self, typ, e):
     if typ != tap.MMOVE:
         return
     p = Point2d(e.x, e.y)
     on_main = is_on_main(p)
     self.main_mouse = on_main
Esempio n. 25
0
from talon import app
from talon.track.geom import Point2d
from talon_plugins import eye_mouse, eye_zoom_mouse, speech

if app.platform == "mac":
    eye_zoom_mouse.config.screen_area = Point2d(100, 75)
    eye_zoom_mouse.config.img_scale = 6
elif app.platform == "win":
    eye_zoom_mouse.config.screen_area = Point2d(200, 150)
    eye_zoom_mouse.config.img_scale = 4.5
elif app.platform == "linux":
    eye_zoom_mouse.config.screen_area = Point2d(200, 150)
    eye_zoom_mouse.config.img_scale = 6