Add Haptics to Your App

Two ways to trigger haptic feedback: WebSocket for low-latency, or REST for simplicity.

Building a native plugin?

If you're implementing haptics directly using the Logitech Actions SDK (C#), check out the official documentation for best practices.

Logitech Actions SDK Haptics Docs

Connect to test the examples

Connect your mouse to try the live examples on this page.

WebSocket API

Recommended for real-time, low-latency feedback

JavaScript
const ws = new WebSocket('wss://local.jmw.nz:41443/ws');

ws.onopen = () => {
  console.log('Connected to HapticWeb');
  
  // Trigger "sharp_collision" (index 0)
  ws.send(new Uint8Array([0]));
  
  // Trigger "completed" (index 7)
  ws.send(new Uint8Array([7]));
};

How it works

  • Connect to wss://local.jmw.nz:41443/ws
  • Send a single byte containing the waveform index (0-15)
  • No response is sent back — connection stays open for repeated triggers
  • The connection uses a pre-allocated buffer for zero-allocation sends

REST API

Simple HTTP requests, works from any language

JavaScript
// Trigger a haptic waveform
await fetch('https://local.jmw.nz:41443/haptic/sharp_collision', {
  method: 'POST',
  body: ''
});

// Get available waveforms
const waveforms = await fetch('https://local.jmw.nz:41443/waveforms')
  .then(res => res.json());

Note about POST requests

POST requests require a Content-Length header. When using curl, include -d '' to send an empty body with the proper header, otherwise the request will hang.

Waveform Quick Reference

Click any waveform to trigger it (connect your mouse first).

Best Practices

Use sparingly

Haptic feedback is most effective when used for key interactions, not every mouse movement.

Match the waveform to the action

Use subtle waveforms for hover states, sharp ones for button clicks, and alerts for notifications.

Handle disconnection gracefully

Not all users will have the plugin. Make haptics optional and don't break your app if the connection fails.

Prefer WebSocket for real-time

For slider drags, game feedback, or high-frequency events, use WebSocket for lower latency.