Skip to content

Commit

Permalink
Fix sensor index
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyustorm authored and blackspherefollower committed Nov 19, 2024
1 parent f788e69 commit 1c21523
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.blackspherefollower.buttplug4j.client;

import io.github.blackspherefollower.buttplug4j.protocol.ButtplugConsts;
import io.github.blackspherefollower.buttplug4j.protocol.ButtplugMessage;
import io.github.blackspherefollower.buttplug4j.protocol.messages.*;
import io.github.blackspherefollower.buttplug4j.protocol.messages.Parts.*;
Expand Down Expand Up @@ -392,7 +393,7 @@ public final Future<ButtplugMessage> sendLinearCmd(final Pair<Double, Long>[] ve
* is thrown.
* </p>
*
* @param index The index of the sensor feature to read. This value specifies which sensor data
* @param sensorIndex The index of the sensor feature to read. This value specifies which sensor data
* to retrieve from the device.
* @param sensorType The type of sensor to read (e.g., "Battery"). This value indicates the specific
* type of sensor data requested.
Expand All @@ -404,16 +405,17 @@ public final Future<ButtplugMessage> sendLinearCmd(final Pair<Double, Long>[] ve
* @throws ButtplugDeviceException if the device does not support "SensorReadCmd" or if
* the sensor read command could not be created or sent.
*/
public final Future<ButtplugMessage> sendSensorReadCmd(final int index, final String sensorType)
public final Future<ButtplugMessage> sendSensorReadCmd(final int sensorIndex, final String sensorType)
throws ButtplugDeviceException {

MessageAttributes attrs = getDeviceMessages().get("SensorReadCmd");
if (!(attrs instanceof SensorMessageAttributes)) {
throw new ButtplugDeviceException("Device doesn't support SensorReadCmd!");
}

final SensorReadCmd cmd = new SensorReadCmd(index, index);
final SensorReadCmd cmd = new SensorReadCmd(this.deviceIndex, ButtplugConsts.DEFAULT_MSG_ID);
cmd.setSensorType(sensorType);
cmd.setSensorIndex(sensorIndex);

return client.sendDeviceMessage(this, cmd);
}
Expand Down

0 comments on commit 1c21523

Please sign in to comment.