Skip to content

Commit f8cae7b

Browse files
committed
Merge branch 'snapshot'
2 parents d4194c8 + 18b0a68 commit f8cae7b

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ Then add the following as dependency:
3636
<groupId>com.github.RalleYTN</groupId>
3737
<artifactId>XInput-Wrapper</artifactId>
3838
<!-- NOTE: You can also use the commit ID as version number -->
39-
<version>1.2.1</version>
39+
<version>1.2.2</version>
4040
</dependency>
4141
```
4242

4343
## Changelog
4444

45+
### Version 1.2.2
46+
47+
- Changed `XInputVibration.wLeftMotorSpeed` and `XInputVibration.wRightMotorSpeed` to the datatype `int` in order to fix a problem with conversion between uint16 and signed Java short.
48+
4549
### Version 1.2.1
4650

4751
- Added jitpack.yml to fix an issue with Jitpack IO not using JDK 11

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>de.ralleytn.wrapper.microsoft.xinput</groupId>
55
<artifactId>XInput-Wrapper</artifactId>
6-
<version>1.2.1</version>
6+
<version>1.2.2</version>
77
<name>XInput Wrapper</name>
88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

src/main/java/de/ralleytn/wrapper/microsoft/xinput/XInputVibration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ public final class XInputVibration extends Structure {
5353
* <p><code>Source: <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.xinput_vibration(v=vs.85).aspx">Microsoft Documentation</a></code></p>
5454
* @since 1.0.0
5555
*/
56-
public short wLeftMotorSpeed;
56+
public int wLeftMotorSpeed;
5757

5858
/**
5959
* <p>Speed of the right motor. Valid values are in the range {@code 0} to {@code 65535}. Zero signifies no motor use; {@code 65535} signifies 100 percent motor use.</p>
6060
* <p><code>Source: <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.xinput_vibration(v=vs.85).aspx">Microsoft Documentation</a></code></p>
6161
* @since 1.0.0
6262
*/
63-
public short wRightMotorSpeed;
63+
public int wRightMotorSpeed;
6464

6565
@Override
6666
protected List<String> getFieldOrder() {

src/test/java/de/ralleytn/wrapper/microsoft/xinput/TestGamepad.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public TestGamepad(XInput api, int userIndex) {
6161
public void setVibration(int leftMotorSpeed, int rightMotorSpeed) {
6262

6363
XInputVibration vibration = new XInputVibration();
64-
vibration.wLeftMotorSpeed = (short)leftMotorSpeed;
65-
vibration.wRightMotorSpeed = (short)rightMotorSpeed;
64+
vibration.wLeftMotorSpeed = leftMotorSpeed;
65+
vibration.wRightMotorSpeed = rightMotorSpeed;
6666
int code = this.api.XInputSetState(this.userIndex, vibration);
6767
this.connected = (code == ERROR_SUCCESS);
6868
}

src/test/java/de/ralleytn/wrapper/microsoft/xinput/TestXInput.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public void testGetCapabilities() {
6969
XInputGamepad gamepad = capabilities.Gamepad;
7070

7171
System.out.println("\n====");
72-
System.out.println("Left Motor: " + Short.toUnsignedInt(vibration.wLeftMotorSpeed));
73-
System.out.println("Right Motor: " + Short.toUnsignedInt(vibration.wRightMotorSpeed));
72+
System.out.println("Left Motor: " + vibration.wLeftMotorSpeed);
73+
System.out.println("Right Motor: " + vibration.wRightMotorSpeed);
7474
System.out.println("Type: " + capabilities.Type);
7575
System.out.println("Subtype: " + capabilities.SubType);
7676
System.out.println("Flags: " + Integer.toBinaryString(capabilities.Flags));
@@ -225,9 +225,10 @@ public void testRumble() {
225225

226226
try {
227227

228-
GAMEPAD.setVibration(Short.MAX_VALUE, Short.MAX_VALUE); // vibrate on 50%
228+
GAMEPAD.setVibration(65535, 65535); // vibrate on 100%
229229
Thread.sleep(5000);
230230
GAMEPAD.setVibration(0, 0); // stop vibrating
231+
Thread.sleep(5000);
231232

232233
} catch(InterruptedException exception) {}
233234
}

0 commit comments

Comments
 (0)