buttplug.js

Constants

Exported constant values.


All constants are exported from the package root:

import {
  OUTPUT_TYPES,
  INPUT_TYPES,
  EASING_VALUES,
  PRESET_NAMES,
  ErrorCode,
} from "@zendrex/buttplug.js";

OUTPUT_TYPES

All output actuator types defined by the Buttplug v4 protocol. Typed as readonly OutputType[].

const OUTPUT_TYPES = [
  "Vibrate",
  "Rotate",
  "RotateWithDirection",
  "Oscillate",
  "Constrict",
  "Spray",
  "Temperature",
  "Led",
  "Position",
  "HwPositionWithDuration",
] as const;
ValueDescription
"Vibrate"Vibration motor control
"Rotate"Rotation motor (speed only)
"RotateWithDirection"Rotation motor with clockwise/counter-clockwise direction
"Oscillate"Oscillation motor control
"Constrict"Constriction pressure actuator
"Spray"Spray mechanism
"Temperature"Temperature control (signed values: positive = heat, negative = cool)
"Led"LED brightness control
"Position"Linear position actuator
"HwPositionWithDuration"Position actuator with timed movement duration

INPUT_TYPES

All input sensor types defined by the Buttplug v4 protocol. Typed as readonly InputType[].

const INPUT_TYPES = [
  "Battery",
  "RSSI",
  "Pressure",
  "Button",
  "Position",
] as const;
ValueDescription
"Battery"Battery level percentage
"RSSI"Bluetooth signal strength
"Pressure"Pressure sensor reading
"Button"Physical button state
"Position"Position sensor reading

EASING_VALUES

All easing curve identifiers used for keyframe interpolation. Typed as readonly Easing[].

const EASING_VALUES = [
  "linear",
  "easeIn",
  "easeOut",
  "easeInOut",
  "step",
] as const;
ValueDescription
"linear"Constant velocity interpolation
"easeIn"Starts slow, accelerates
"easeOut"Starts fast, decelerates
"easeInOut"Slow start and end, fast middle
"step"Instant jump to target value (no interpolation)

PRESET_NAMES

All available built-in pattern preset names. Typed as readonly PresetName[].

const PRESET_NAMES = [
  "pulse",
  "wave",
  "ramp_up",
  "ramp_down",
  "heartbeat",
  "surge",
  "stroke",
] as const;
NameDescriptionDefault LoopCompatible With
"pulse"Square wave on/offYesVibrate, Rotate, RotateWithDirection, Oscillate, Constrict
"wave"Smooth sine wave oscillationYesVibrate, Rotate, RotateWithDirection, Oscillate, Constrict
"ramp_up"Gradual increase to maximumNoVibrate, Rotate, RotateWithDirection, Oscillate, Constrict
"ramp_down"Gradual decrease to zeroNoVibrate, Rotate, RotateWithDirection, Oscillate, Constrict
"heartbeat"Ba-bump heartbeat rhythmYesVibrate, Rotate, RotateWithDirection, Oscillate, Constrict
"surge"Build to peak then releaseNoVibrate, Rotate, RotateWithDirection, Oscillate, Constrict
"stroke"Full-range position strokesYesPosition, HwPositionWithDuration

ErrorCode

Numeric error codes returned by the Buttplug protocol.

const ErrorCode = {
  UNKNOWN: 0,
  INIT: 1,
  PING: 2,
  MESSAGE: 3,
  DEVICE: 4,
} as const;
KeyValueDescription
UNKNOWN0Unknown or unclassified error
INIT1Initialization or handshake error
PING2Ping timeout -- server will halt devices
MESSAGE3Malformed or invalid message
DEVICE4Device-specific protocol error

See Errors for the error classes that use these codes.

  • Types -- OutputType, InputType, Easing type aliases
  • PatternEngine -- uses presets and easing values
  • Errors -- ErrorCode usage in ProtocolError
  • Presets -- preset pattern details and examples

On this page