buttplug-js
buttplug-js copied to clipboard
Support for SensorSubscribeCmd
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);
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.