示例#1
0
)


# TODO: Pull this out once talon exposes mouse mode scopes by default
@module.scope
def scope(*_):
    zoom_mouse = zoom_mouse_active()
    return {
        "zoom_mouse_active": zoom_mouse,
        "zoom_mouse_zooming": zoom_mouse and is_zooming(),
    }


speech_system.register("pre:phrase", scope.update)
# Noises won't trigger pre:phrase - bind them so we definitely catch the zoom.
noise.register("post:pop", scope.update)
noise.register("pre:hiss", scope.update)


@module.action_class
class Actions:
    def end_zoom() -> Point2d:
        """Terminate the zoom.

        Mouse will be moved to the user's gaze position.

        :returns: the final position

        """
        # TODO: Will this be reactive enough, or should we make this accessible
        #   anywhere in the zoom mouse?
示例#2
0
            ctrl.mouse_click(button=0, hold=16000)


def on_hiss(active):
    if not active:
        return
    print("Detected")
    global reading_mode
    if reading_mode:
        actions.key("pageup")
        return
    else:
        actions.mouse_click(1)


noise.register("pop", on_pop)
# noise.register("hiss", on_hiss)


def mouse_scroll(amount):
    def scroll():
        global scroll_amount
        if (scroll_amount >= 0) == (amount >= 0):
            scroll_amount += amount
        else:
            scroll_amount = amount
        actions.mouse_scroll(y=int(amount))

    return scroll

示例#3
0
        except WindowsError:
            print("Unable to show_cursor({})".format(str(show)))
    else:
        ctrl.cursor_visible(show)


def on_pop(active):
    if (gaze_job or scroll_job):
        if settings.get("user.mouse_enable_pop_stops_scroll") >= 1:
            stop_scroll()
    elif not eye_zoom_mouse.zoom_mouse.enabled and eye_mouse.mouse.attached_tracker is not None:
        if settings.get("user.mouse_enable_pop_click") >= 1:
            ctrl.mouse_click(button=0, hold=16000)


noise.register('pop', on_pop)


def mouse_scroll(amount):
    def scroll():
        global scroll_amount
        if (scroll_amount >= 0) == (amount >= 0):
            scroll_amount += amount
        else:
            scroll_amount = amount
        actions.mouse_scroll(y=int(amount))

    return scroll


def scroll_continuous_helper():
示例#4
0
        print(f"speech_system event: {topic}", m)


if debugEngine:
    speech_system.register("", listener)


def on_mic_ev(topic, arg):
    print(f"mic event: {topic} {arg}")


if debugMic:
    manager.register("", on_mic_ev)

# def on_pop(active):
#     print(f"pop active:{active}")
#
# def on_hiss(active):
#     print(f"hiss active:{active}")
#
# noise.register('pop', on_pop)
# noise.register('hiss', on_hiss)


def on_noise(noise, active):
    print(f"noise {noise} active:{active}")


if debugNoise:
    noise.register("", on_noise)
示例#5
0
 def __init__(self, noise_):
     self._handlers = _HandlerMapper()
     noise.register(noise_, self._on_noise)
示例#6
0
 def __init__(self, noise_):
     self._handlers = _HandlerMapper()
     self.noise = noise_
     self._active_handlers = []
     self._active_handlers_lock = threading.Lock()
     noise.register(noise_, self._on_noise)
示例#7
0
from talon import noise, ctrl, settings


def on_pop(active):
    # for pop active = False always
    if settings.get('user.noise_enabled') == 'True':
        ctrl.mouse_click(button=1)


def on_hiss(active):
    if settings.get('user.noise_enabled') == 'True':
        ctrl.mouse_click(button=0, down=active, up=not active)


noise.register('pop', on_pop)
noise.register('hiss', on_hiss)
示例#8
0
            raise

        if hiss_mode == '':
            actions.mode.disable('user.hiss_to_scroll')
        elif hiss_mode == 'scroll':
            actions.mode.enable('user.hiss_to_scroll')

#     def noise_hiss_scroll_reverse():
#         """reverse the direction of the hissing scroll"""
         
currently_hissing = False

def on_hiss(active):

    global hiss_mode
    global currently_hissing

    currently_hissing = not currently_hissing

    if hiss_mode == 'scroll':
        if currently_hissing:
            # actions.speech.disable()
            actions.user.mouse_scroll_down_continuous()
            # print('hiss started')
        else:
            # actions.speech.enable()
            actions.user.mouse_scroll_stop()
            # print('hiss stopped')

noise.register("hiss", on_hiss)
示例#9
0
hiss_quick_action = None
hiss_quick_action_last = None
hiss_quick_action_history = []


def on_hiss(active):
    global hiss_quick_action
    print("on_hiss", active)
    if not active:
        if hiss_quick_action is None:
            actions.user.hiss()
        else:
            actions.user.hiss_quick_action_run()


try:
    noise.register("pop", on_pop)
    # noise.register("hiss", on_hiss)
except talon.lib.cubeb.CubebError as e:
    app.notify("Failed to register pop. Is possible audio error")
    print("Failed to register pop. Is possible audio error")
    print(e)

try:
    noise.register("hiss", on_hiss)
except talon.lib.cubeb.CubebError as e:
    app.notify("Failed to register hiss. Is possible audio error")
    print("Failed to register hiss. Is possible audio error")
    print(e)
示例#10
0
debugEngine = True
debugNoise = True


def listener(topic, m):
    if topic == 'cmd' and m['cmd']['cmd'] == 'g.load' and m['success'] == True:
        print('engine event: [grammar reloaded]')
    else:
        print(f'engine event: {topic}', m)


if debugEngine:
    engine.register('', listener)

# def on_pop(active):
#     print(f"pop active:{active}")
#
# def on_hiss(active):
#     print(f"hiss active:{active}")
#
# noise.register('pop', on_pop)
# noise.register('hiss', on_hiss)


def on_noise(noise, active):
    print(f"noise {noise} active:{active}")


if debugNoise:
    noise.register('', on_noise)
示例#11
0
            if pop_mode == 'drag_once':
                pop_mode = 'click'

    elif pop_mode == 'macro':
        ignore_knausj_click = True
        actions.user.macro_play()


ignore_knausj_click = False

## This has been moved and adapted from knausj/code/mouse.py
## TEMPORARY Clean this up so the two files play nicer together
setting_mouse_enable_pop_click = mod.setting(
    "mouse_enable_pop_click",
    type=int,
    default=0,
    desc="Enable pop to click when control mouse is enabled.",
)


def on_pop_knausj(active):
    if eye_mouse_is_on():
        if setting_mouse_enable_pop_click.get() >= 1:
            global ignore_knausj_click  ### This line has been added
            if not ignore_knausj_click:  ### This line has been added
                ctrl.mouse_click(button=0, hold=16000)


noise.register("pop", on_pop_knausj)
noise.register("pop", on_pop)
示例#12
0

def start_hiss_action():
    global is_active

    if is_active:
        actions.key('k:down')


def on_hiss(active):
    global is_active, start, noise_length, t

    if 'Minecraft' not in ui.active_window().title:
        return

    if 'java' != ui.active_app().name:
        return

    if active:
        is_active = True
        t = Timer(noise_length, start_hiss_action)
        t.start()
    else:
        is_active = False
        start = 0
        t.cancel()
        actions.key('k:up')


noise.register('hiss', on_hiss)
示例#13
0
def on_hiss(active):
    global hiss_quick_action
    if hiss_quick_action is None:
        actions.user.hiss()
    else:
        actions.user.hiss_quick_action_run()


try:
    # we have to disable the existing pop mouse, so we can override it with
    # a custom version that allows us to do quick actions, etc

    # Unbind before every pop to reset the unbind when the zoom mouse is
    # restarted.
    noise.register(
        "pre:pop",
        lambda *_: noise.unregister("pop", eye_zoom_mouse.zoom_mouse.on_pop))

    noise.register("pop", on_pop)

    # noise.register("hiss", on_hiss)
except talon.lib.cubeb.CubebError as e:
    app.notify("Failed to register pop. Is possible audio error")
    print("Failed to register pop. Is possible audio error")
    print(e)

try:
    noise.register("hiss", on_hiss)
except talon.lib.cubeb.CubebError as e:
    app.notify("Failed to register hiss. Is possible audio error")
    print("Failed to register hiss. Is possible audio error")