Skip to content

antoinemerc/kd-sense-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KDSenseSync: Project Overview

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.

1. Core Concepts & Features

Action Types

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 set duration and 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.

Intensity Stacking

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%.

Uninterruptible Locks

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.

Hardware Throttling

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.


2. Architecture & Hooks

The Manager (KDSenseSyncManager)

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 Registry (KDSenseSyncRegistry)

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.

Provider Setup (Lovense)

The mod currently supports the Lovense ecosystem via their local API.

  • Connection: Connects via a Host Address (default 127.0.0.1) and Port (default 20010).
  • 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.

3. Supported Events & Hooks

Pulse Events (Short Feedback)

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.

Body Events (Continuous States)

Event Action Trigger Source
FullBody Steady A global state used for persistent vibrations anywhere on the body.

Registry Hooks

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 either ShockDamage or TeaseDamage.
    • Special Logic: If the Masochist Perk is active and enabled in settings, standard pain damage is processed as TeaseDamage.

4. Hardware Management

  • 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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors