KDSenseSync is a modular synchronization engine for Kinky Dungeon. It bridges in-game events and persistent character states with physical haptic hardware. It uses a non-blocking, event-driven architecture designed to minimize API overhead while maximizing immersion.
The engine distinguishes between two types of sensory input:
- Pulse (
actionType: "pulse"): Short-lived haptic feedback (e.g., a shock or a slap). These have a setdurationand automatically expire via a timer. - Steady (
actionType: "steady"): Continuous haptic states (e.g., a vibrating belt or high arousal). These have no internal expiration timer and persist until the game sends a "Stop" command (intensity 0). They use a 5-minute safety ceiling to keep hardware active.
The KDSenseSyncManager calculates the final vibration level of a device by summing the intensities of all active events in its stack.
- If a Steady vibration (20%) is active and a Shock Pulse (40%) triggers, the device will vibrate at 60%.
- Final values are always clamped between 0% and 100%.
Specific high-priority events (e.g., Orgasm) are marked as uninterruptible.
- While an uninterruptible event is in the stack, the device ignores all incoming Pulse commands.
- Steady updates are still processed in the background stack but are not sent to the hardware until the uninterruptible event finishes. This ensures a smooth climax without jitter from small damage pings.
To prevent network lag and "command spam," the manager caches the last sent intensity. It only sends a new command to the hardware if the calculated total intensity actually changes.
The "brain" of the mod. It handles the deviceEventsStack, manages the lifecycles of pulses, and calculates the final haptic output. It uses refreshHardware() to nudge the physical devices only when necessary.
The "router" of the mod.
- Discovery: Scans for physical hardware via Providers.
- Routing: Maintains the
eventDeviceConfigurationMap. This map links a Game Event (e.g., "teaseDamage") to specific physical devices based on user settings, including per-device intensity multipliers.
The mod currently supports the Lovense ecosystem via their local API.
- Connection: Connects via a Host Address (default
127.0.0.1) and Port (default20010). - Capabilities: Automatically detects toy capabilities (Vibrate, Rotate, Thrust) and picks the primary action for the haptic pulse.
- Communication: Uses standard HTTP POST commands to Communicate with the Lovense Connect app.
| Event | Action | Trigger Source |
|---|---|---|
| PlaySelf | Pulse (1s) | Triggered by the "Play With Self" button or high desire. Intensity scales with current Distraction. |
| Orgasm | Pulse (10s) | Triggered on climax. Uninterruptible. Uses maximum intensity by default. |
| TeaseDamage | Pulse (0.7s) | Triggered by tickle, grope, charm, plush, happygas, and souldrain. |
| ShockDamage | Pulse (0.7s) | Triggered by shock, electric, and estim damage types. |
| Event | Action | Trigger Source |
|---|---|---|
| FullBody | Steady | A global state used for persistent vibrations anywhere on the body. |
The mod hooks into the following Kinky Dungeon events:
afterModSettingsLoad: Initializes the UI, discovers hardware, and builds the configuration maps.playSelf: Dispatches the PlaySelf pulse.orgasm: Dispatches the Orgasm pulse.afterPlayerDamage: Filters damage types to dispatch eitherShockDamageorTeaseDamage.- Special Logic: If the Masochist Perk is active and enabled in settings, standard
paindamage is processed asTeaseDamage.
- Special Logic: If the Masochist Perk is active and enabled in settings, standard
- Keep-Alive Ceiling: Set to 300,000ms (5 minutes).
- For Steady events, the manager tells the toy to run for 5 minutes.
- Any time a new pulse occurs or the intensity changes, this 5-minute timer is effectively "reset" on the hardware, ensuring that active play keeps the sensations alive without needing a performance-heavy heartbeat loop.