Skip to content

Support for SensorSubscribeCmd #255

@salaink

Description

@salaink

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions