Last active
April 18, 2020 00:50
-
-
Save FoamyGuy/36b0873acee2420ba314a04f9a4f3d40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from adafruit_hid.mouse import Mouse | |
import time | |
import board | |
import touchio | |
import usb_hid | |
mouse = Mouse(usb_hid.devices) | |
touch_pad = board.A0 | |
touch = touchio.TouchIn(touch_pad) | |
prev_value = False | |
while True: | |
cur_value = touch.value | |
if cur_value and not prev_value: | |
print("Touched!") | |
# smash the mouse all the way to the top left | |
mouse.move(x=-2000, y=-2000) | |
# move to desired location | |
mouse.move(x=160, y=210) | |
# send click | |
mouse.click(Mouse.LEFT_BUTTON) | |
prev_value = cur_value | |
time.sleep(0.05) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment