Beispiel #1
0
def start_filtering(
        evdev: Device, filter: Callable[[InputEvent],
                                        Union[InputEvent, None]]) -> NoReturn:
    """Start filtering input from a device."""

    # grab the device to ourselves - now only we see the events it emits
    evdev.grab()
    # create a copy of the device that we can write to - this will emit the filtered events to anyone who listens
    uidev = evdev.create_uinput_device()

    while True:
        # since the descriptor is blocking, this blocks until there are events available
        for e in evdev.events():
            if (f := filter(e)) is not None:
                send_event_packet(uidev, f)
Beispiel #2
0
    events = [
        InputEvent(EV_KEY.KEY_NUMLOCK, 0),
        InputEvent(EV_SYN.SYN_REPORT, 0)
    ]
    udev.send_events(events)
    d_t.ungrab()
    subprocess.call(offCmd, shell=True)


numlock = False

# Process events while running #
while True:

    # If keyboard sends numlock event with F8 key tap, enable/disable touchpad events #
    for e in d_k.events():
        if e.matches(EV_KEY.KEY_F8) and e.value == 1:
            numlock = not numlock
            if numlock:
                activate_numlock()
            else:
                deactivate_numlock()

    # If touchpad sends tap events, convert x/y position to numlock key and send it #
    for e in d_t.events():
        # ignore others events, except position and finger events
        if not (e.matches(EV_ABS.ABS_MT_POSITION_X)
                or e.matches(EV_ABS.ABS_MT_POSITION_Y)
                or e.matches(EV_KEY.BTN_TOOL_FINGER)):
            continue
Beispiel #3
0
        brightness] + " 0xad"
    subprocess.call(numpad_cmd, shell=True)
    return brightness


# Run - process and act on events

numlock: bool = False
pos_x: int = 0
pos_y: int = 0
button_pressed: libevdev.const = None
brightness: int = 0

while True:
    # If touchpad sends tap events, convert x/y position to numlock key and send it #
    for e in d_t.events():

        # ignore others events, except position and finger events
        if not (e.matches(EV_ABS.ABS_MT_POSITION_X)
                or e.matches(EV_ABS.ABS_MT_POSITION_Y)
                or e.matches(EV_KEY.BTN_TOOL_FINGER)):
            continue

        # Get x position #
        if e.matches(EV_ABS.ABS_MT_POSITION_X):
            x = e.value
            continue

        # Get y position #
        if e.matches(EV_ABS.ABS_MT_POSITION_Y):
            y = e.value