Created
May 16, 2021 00:11
-
-
Save dglaude/aad3d9e19858b062306b2a514434fd6b to your computer and use it in GitHub Desktop.
Hidden Mouse Jiggler
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
import time | |
import board | |
import digitalio | |
import storage | |
import usb_hid | |
from adafruit_hid.mouse import Mouse | |
import usb_cdc | |
#usb_hid.enable(devices=(usb_hid.MOUSE,)) ###AttributeError: 'module' object has no attribute 'MOUSE' | |
switch = digitalio.DigitalInOut(board.SLIDE_SWITCH) | |
switch.direction = digitalio.Direction.INPUT | |
if switch.value: | |
print("Hiding Drive and Serial") | |
# storage.disable_usb_drive() ###RuntimeError: Cannot change USB devices now | |
# usb_cdc.disable() # <= This seems to work | |
else: | |
print("Debug mode") | |
mouse = Mouse(usb_hid.devices) | |
while True: | |
print("Looping") | |
mouse.move(x=20) | |
time.sleep(5) | |
mouse.move(x=-20) | |
time.sleep(5) |
As mentioned, you need to put
usb_hid.enable(devices=(usb_hid.Device.MOUSE,))
and storage.disable_usb_drive()
in boot.py
. By the time you get to code.py
, the USB devices are set already.
And it is usb_hid.Device.MOUSE
. That should work.
I will be writing a guide soon.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Running this code on a CPB with:
The behaviour should be a mouse jiggler with or without visibility of CIRCUITPY drive (and CDC console) depending on the slide switch position.
But:
usb_hid.enable(devices=(usb_hid.MOUSE,))
:storage.disable_usb_drive()
: