Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.venv
/typings
/.idea
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/picoUSB.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ That is it! Modify `pico_usb.txt` to change the functionality. See below to know
- scroll(x) - scrolls the mouse. Negative number scrolls down, possitive scroll up
- volume(x) - Modifies the system volume. Negative numbers move the volume slider down by x, possitive move it up by x. min volume = 0. max = 100. `volume(mute)` mutes the speakers.
- loop() - loops everything before this command
- payload() - allows you to launch a bat file present on the “picousb” in the “payload” folder, for example `payload(test.bat)` (only on window).

## Development

Expand Down
17 changes: 15 additions & 2 deletions src/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,27 @@
storage.remount("/", readonly=True)
storage.enable_usb_drive()


time.sleep(0.1) #wait a bit so the button gets pulled up

if mode.value:
storage.disable_usb_drive()
if microcontroller.nvm[0] == 1:
microcontroller.nvm[0] = 0
storage.enable_usb_drive()
microcontroller.on_next_reset(microcontroller.RunMode.SAFE_MODE)
microcontroller.reset()
else:
storage.disable_usb_drive()
else:
time.sleep(0.1) #check again after 100ms to see if the button is still pressed
if mode.value:
storage.disable_usb_drive()
if microcontroller.nvm[0] == 1:
microcontroller.nvm[0] = 0
storage.enable_usb_drive()
microcontroller.on_next_reset(microcontroller.RunMode.SAFE_MODE)
microcontroller.reset()
else:
storage.disable_usb_drive()
else:
storage.enable_usb_drive()
microcontroller.on_next_reset(microcontroller.RunMode.SAFE_MODE)
Expand Down
16 changes: 16 additions & 0 deletions src/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
import time
import board
import microcontroller
import storage
import usb_hid
import digitalio
Expand All @@ -25,6 +26,7 @@
led.direction = digitalio.Direction.OUTPUT
led.value = True

flag = microcontroller.nvm[0]
looping = False
loop_pos = 0

Expand All @@ -41,6 +43,20 @@ def execute_command(function, command):
for idx in range(0, len(command), 1):
keys[idx] = getattr(Keycode, command[idx])
kb.send(*keys)
elif function == "PAYLOAD":
kb.send(Keycode.WINDOWS, Keycode.R)
time.sleep(0.1)
volume_label = "PICOUSB"
powershell_cmd = (
'powershell -NoExit -Command "Start-Sleep 3; '
'Get-Volume | Where-Object { $_.FileSystemLabel -eq \'' + volume_label + '\' } | '
'ForEach-Object { Start-Process (\'{0}:\\payload\\' + command + '\' -f $_.DriveLetter) }"'
)
layout.write(powershell_cmd)
kb.send(Keycode.ENTER)
time.sleep(0.1)
microcontroller.nvm[0] = 1
microcontroller.reset()
elif function == "WRITE":
layout.write(command)
elif function == "HOLD":
Expand Down
2 changes: 1 addition & 1 deletion src/layout.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
layout(CRO)
layout(FR)

# to change layout, edit the country layout in between the brackets. Example: layout(US)
# layouts generated using Circuitpython_Keyboard_Layouts
Expand Down
2 changes: 2 additions & 0 deletions src/payload/test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo HelloWorld
pause
1 change: 1 addition & 0 deletions src/pico_usb.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# PicoUSB Payloads go in this file
# DO NOT FORGET to change your country keyboard layout in layout.txt!
######################################################################################
Expand Down