Compare commits

..

1 Commits

Author SHA1 Message Date
coolneng 9172cced29 Document the functions 2020-07-28 22:30:55 +02:00
15 changed files with 21 additions and 63 deletions
Generated
-41
View File
@@ -1,41 +0,0 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1654845941,
"narHash": "sha256-uXulXu4BQ9ch1ItV0FlL2Ns8X83m6unT5h/0X//VRLQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7b3e907a6fef935794b5049c2c57c519853deb90",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
-14
View File
@@ -1,14 +0,0 @@
{
description = "";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let pkgs = nixpkgs.legacyPackages.${system}; in
{
devShell = import ./shell.nix { inherit pkgs; };
}
);
}
+4
View File
@@ -167,6 +167,10 @@ def on_button(callback, args=(), buttons=(LEFT, MIDDLE, RIGHT, X, X2), types=(UP
_listener.add_handler(handler)
return handler
def on_pressed(callback, args=()):
""" Invokes `callback` with `args` when the left button is pressed. """
return on_button(callback, args, [LEFT], [DOWN])
def on_click(callback, args=()):
""" Invokes `callback` with `args` when the left button is clicked. """
return on_button(callback, args, [LEFT], [UP])
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+8 -2
View File
@@ -20,6 +20,8 @@ EV_REL = 0x02
EV_ABS = 0x03
EV_MSC = 0x04
INVALID_ARGUMENT_ERRNO = 22
def make_uinput():
import fcntl, struct
@@ -29,8 +31,12 @@ def make_uinput():
fcntl.ioctl(uinput, UI_SET_EVBIT, EV_KEY)
UI_SET_KEYBIT = 0x40045565
for i in range(256):
fcntl.ioctl(uinput, UI_SET_KEYBIT, i)
try:
for i in range(0x300):
fcntl.ioctl(uinput, UI_SET_KEYBIT, i)
except OSError as e:
if e.errno != INVALID_ARGUMENT_ERRNO:
raise e
BUS_USB = 0x03
uinput_user_dev = "80sHHHHi64i64i64i64i"
Binary file not shown.
Binary file not shown.
+9 -6
View File
@@ -3,22 +3,25 @@ from secrets import randbelow
from time import sleep
def erratic_movement(screen_width=800, screen_height=600):
def erratic_movement(screen_width, screen_height):
"""
Moves the cursor to a random position with the screen's width and height as an upper bound
Moves the cursor to a random position with the screen's
width and height as an upper bound
"""
move(
randbelow(screen_width),
randbelow(screen_height),
randbelow(screen_width), randbelow(screen_height),
)
def main():
"""
Calls the movement function in an infinite loop, with a random delay between each call
Calls the movement function in an infinite loop,
with a random delay between each call
"""
screen_width = 800
screen_height = 600
while True:
erratic_movement()
erratic_movement(screen_width, screen_height)
sleep(randbelow(90))