buttplug-js icon indicating copy to clipboard operation
buttplug-js copied to clipboard

Support for SensorSubscribeCmd

Open salaink opened this issue 2 years ago • 1 comments

Currently support for SensorSubscribeCmd is missing.

This is my current workaround, but it's really ugly:

class SensorSubscribeCmd extends Buttplug.ButtplugDeviceMessage {
  static Name = "SensorSubscribeCmd"
  constructor(DeviceIndex, SensorIndex, SensorType) {
    super(DeviceIndex, Buttplug.DEFAULT_MESSAGE_ID);
		this.SensorIndex = SensorIndex
		this.SensorType = SensorType
  }
}

const sorter = Window.BP.bpClient._connector._sorter;
const old_pim = sorter.ParseIncomingMessages;
sorter.ParseIncomingMessages = (msgs) => { 
    for (const msg of msgs) {
        if (msg.Type == Buttplug.SensorReading) {
            // handle msg.Data[0]
        }
    }
    return old_pim.apply(sorter, [msgs]);
};
const dev = Window.BP.devices["Generic Vibrator"];
dev.sendExpectOk(new SensorSubscribeCmd(1, 0, "foo")).then(console.log);

salaink avatar Oct 16 '23 09:10 salaink

Ugh yeah I'm trying to rework the sensor system, it's broken in a fairly fundamental way right now. That's why this hadn't gotten implemented here yet. It is on my list tho.

qdot avatar Oct 16 '23 17:10 qdot