diff --git a/buttplug4j/src/main/java/io/github/blackspherefollower/buttplug4j/client/ButtplugClientDeviceFeature.java b/buttplug4j/src/main/java/io/github/blackspherefollower/buttplug4j/client/ButtplugClientDeviceFeature.java index 8d7ce10..a8a9d63 100644 --- a/buttplug4j/src/main/java/io/github/blackspherefollower/buttplug4j/client/ButtplugClientDeviceFeature.java +++ b/buttplug4j/src/main/java/io/github/blackspherefollower/buttplug4j/client/ButtplugClientDeviceFeature.java @@ -118,7 +118,13 @@ private int getStepFromFloat(final ButtplugOutput type, final float value) throw if (desc instanceof DeviceFeature.SteppedOutputDescriptor) { double steps = ((DeviceFeature.SteppedOutputDescriptor) desc).getValue()[1]; steps *= value; - return (int) Math.floor(steps); + int result; + if (steps >= 0) { + result = (int) Math.ceil(steps); + } else { + result = (int) Math.floor(steps); + } + return result; } else { throw new ButtplugDeviceFeatureException(type); } diff --git a/buttplug4j/src/test/java/io/github/blackspherefollower/buttplug4j/client/ButtplugClientDeviceFeatureTest.java b/buttplug4j/src/test/java/io/github/blackspherefollower/buttplug4j/client/ButtplugClientDeviceFeatureTest.java index e835b7b..a84586e 100644 --- a/buttplug4j/src/test/java/io/github/blackspherefollower/buttplug4j/client/ButtplugClientDeviceFeatureTest.java +++ b/buttplug4j/src/test/java/io/github/blackspherefollower/buttplug4j/client/ButtplugClientDeviceFeatureTest.java @@ -276,7 +276,7 @@ void testSprayFloatWithValidValue() throws Exception { ArgumentCaptor captor = ArgumentCaptor.forClass(OutputCmd.IOutputCommand.class); verify(mockDevice).runOutput(eq(0), captor.capture()); assertInstanceOf(OutputCmd.Spray.class, captor.getValue()); - assertEquals(3, ((OutputCmd.Spray) captor.getValue()).getValue()); + assertEquals(4, ((OutputCmd.Spray) captor.getValue()).getValue()); } @Test @@ -304,7 +304,7 @@ void testPositionFloatWithValidValue() throws Exception { ArgumentCaptor captor = ArgumentCaptor.forClass(OutputCmd.IOutputCommand.class); verify(mockDevice).runOutput(eq(0), captor.capture()); assertInstanceOf(OutputCmd.Position.class, captor.getValue()); - assertEquals(20, ((OutputCmd.Position) captor.getValue()).getValue()); + assertEquals(21, ((OutputCmd.Position) captor.getValue()).getValue()); } @Test @@ -341,7 +341,7 @@ void testPositionWithDurationFloatWithValidValue() throws Exception { ArgumentCaptor captor = ArgumentCaptor.forClass(OutputCmd.IOutputCommand.class); verify(mockDevice).runOutput(eq(0), captor.capture()); assertInstanceOf(OutputCmd.HwPositionWithDuration.class, captor.getValue()); - assertEquals(20, ((OutputCmd.HwPositionWithDuration) captor.getValue()).getValue()); + assertEquals(21, ((OutputCmd.HwPositionWithDuration) captor.getValue()).getValue()); assertEquals(500, ((OutputCmd.HwPositionWithDuration) captor.getValue()).getDuration()); } @@ -370,7 +370,7 @@ void testLedFloatWithValidValue() throws Exception { ArgumentCaptor captor = ArgumentCaptor.forClass(OutputCmd.IOutputCommand.class); verify(mockDevice).runOutput(eq(0), captor.capture()); assertInstanceOf(OutputCmd.Led.class, captor.getValue()); - assertEquals(127, ((OutputCmd.Led) captor.getValue()).getValue()); + assertEquals(128, ((OutputCmd.Led) captor.getValue()).getValue()); } @Test