Modded from Spunkle’s original script: Stash-TCode
MAIN Download: tcode-usb-v5.3 ← Updated to version 5.3 with axis inversion
BETA-5.6: tcode-usb-v5.6 ← Updated with possible 5.6 Multi Axis Fix by buffering the tcodes sent and sending them as a single packet verses streaming them.
USE BETA VERSIONS AT YOUR OWN RISK
Stash-TCode-USB is a userscript that integrates TCode-compatible haptic devices with the Stash media server via USB Web Serial. This modified version includes USB connectivity fixes to enable direct serial communication with TCode devices like the OSR2, SR6, and other compatible hardware.
this is in Beta currently
Purpose
This script bridges the gap between your Stash media library and TCode-compatible haptic devices by:
-
Connecting to TCode devices via USB using the Web Serial API
-
Loading and parsing funscript files (both single-axis and multi-axis formats)
-
Synchronizing device movements with video playback in real-time
-
Managing up to 6 axes (L0, L1, L2, R0, R1, R2)
-
Providing a user-friendly settings interface for device configuration
Technical Requirements
Browser Requirements
| Requirement | Details |
| Web Serial API Support | Chrome/Edge 89+, Opera 75+ |
| Secure Context | HTTPS OR localhost/127.0.0.1 OR chrome://flags insecure origins whitelist |
| UserScript Manager | Tampermonkey, Violentmonkey, or Greasemonkey |
Hardware Requirements
-
TCode-compatible device (OSR2, SR6, etc.)
-
USB connection to the device
-
Device must support TCode serial protocol at 115200 baud
Software Requirements
-
Stash media server running on port 9999
-
Stash Interactive Tools plugin (for multi-funscript support)
-
Funscript files (.funscript) associated with your media
Key Features
1. USB Serial Connection
-
Direct connection via Web Serial API (no WebSocket server needed)
-
115200 baud rate (TCode standard)
-
Automatic device detection and axis capability discovery
2. Multi-Axis Funscript Support
Supports both formats:
-
Legacy single-axis (
.funscript) -
Multi-axis format (funscript version 1, 1.1, and V2 with
axesarray containing multiple axis definitions)
3. Axis Management
| Axis | TCode Name | Common Usage |
|------|-----------|--------------|
| L0 | Stroke | Up/down linear motion |
| L1 | Sway | Left/right motion |
| L2 | Surge | Forward/backward motion |
| R0 | Twist | Rotation around vertical axis |
| R1 | Pitch | Tilt forward/backward |
| R2 | Roll | Tilt left/right |
4. Live Range Adjustment
-
Mouse wheel + modifier keys to adjust min/max ranges on the fly
-
Initial Key (Shift): Save current ranges as baseline
-
Min Key (Meta/Win): Adjust minimum range
-
Visual overlay shows current axis limits
5. Random Motion Generation
-
Generate procedural motion for axes without funscripts
-
Based on timing from another axis with offset variation
6. Settings Interface
Beautiful dark-themed modal with tabs:
-
Device: USB connection, sync offset adjustment
-
Keys: Customize keyboard shortcuts
-
Axes: Enable/disable axes, set ranges (0-9999), configure random motion
-
Advanced: Debug mode, notifications, settings hotkey
Setup Instructions
Step 1: Install UserScript Manager
Install Tampermonkey or Violentmonkey for your browser.
Step 2: Install The Script
-
Copy the contents of
Stash-TCode.js -
Create a new userscript in Tampermonkey/Violentmonkey
-
Paste the code and save
Step 3: Enable Web Serial API
If using a custom domain (not localhost):
-
Open
chrome://flags -
Find “Insecure origins treated as secure”
-
Add your Stash URL (e.g.,
http://example.lan:9999) -
Restart browser
Step 4: Connect Your Device
-
Navigate to a scene in Stash (
http://your-stash:9999/scenes/[ID]) -
Press F2 (default settings key) to open settings
-
Click “
Connect Serial (USB)” -
Select your TCode device from the browser’s serial port picker
-
The script will auto-detect available axes
Step 5: Verify Funscripts
Ensure your scene has associated .funscript files:
-
Single axis:
SceneName.funscript -
Multi-axis:
SceneName.funscript(with axes array) OR separate files: -
SceneName.sway.funscript(L1) -
SceneName.surge.funscript(L2) -
SceneName.twist.funscript(R0) -
SceneName.pitch.funscript(R1) -
SceneName.roll.funscript(R2)
Usage
Keyboard Shortcuts (Default)
| Key | Action |
|-----|--------|
| F2 | Open settings menu |
| Shift + Scroll | Set initial range baseline |
| Win/Meta + Scroll | Adjust minimum range |
| Mouse wheel (while holding modifier) | Adjust max range |
| Middle click | Reset to saved range |
Video Playback
Once connected, the script automatically:
-
Loads funscripts when you navigate to a scene
-
Syncs device motion with video playback
-
Updates device position every 10ms during playback
-
Resets axis positions when seeking in video
Sync Adjustment
If your device motion is ahead/behind the video:
-
Open settings (F2)
-
Go to Device tab
-
Adjust Sync slider (-250ms to +250ms)
-
Positive values delay device, negative values advance it
Configuration Options
Axis Settings
For each axis (L0-R2):
-
Enable/Disable: Toggle whether the axis is active
-
Range: Set min/max values (0-9999) to limit motion
-
Random: Generate motion based on another axis’s timing
Advanced Options
-
Debug Mode: Enable console logging for troubleshooting
-
Show Notifications: Display toast messages for script events
-
Settings Hotkey: Change the key to open settings
Known Issues:
- multi axis scripts are still a titch funky trying to figure out why If someone understands Tcode better please feel free to modify it or tell me