Skip to content

Instantly share code, notes, and snippets.

@dglaude
Created May 16, 2021 00:11
Show Gist options
  • Save dglaude/aad3d9e19858b062306b2a514434fd6b to your computer and use it in GitHub Desktop.
Save dglaude/aad3d9e19858b062306b2a514434fd6b to your computer and use it in GitHub Desktop.
Hidden Mouse Jiggler
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)
@dhalbert
Copy link

dhalbert commented May 16, 2021

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