Skip to content

Commit

Permalink
Merge pull request #2 from libgdx/sdl/2_0_14
Browse files Browse the repository at this point in the history
Update to SDL 2.0.14
  • Loading branch information
MrStahlfelge authored Jan 9, 2021
2 parents ef362ad + 05f35fb commit c0610ab
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pushaction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- run: mkdir -p SDL/build-macos64
# No --disable-video for macOS https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c70c727c98b24ad8b44e05285b8785be15062af0
- run: ../configure CFLAGS="-fPIC" CPPFLAGS="-fPIC" --disable-audio --disable-video-vulkan --disable-render --disable-filesystem --disable-threads --disable-directx --disable-mmx --disable-3dnow --disable-sse --disable-sse2 --disable-sse3 --disable-cpuinfo --disable-sensor --enable-hidapi
- run: ../configure CFLAGS="-fPIC -mmacosx-version-min=10.7" CPPFLAGS="-fPIC -mmacosx-version-min=10.7" LDFLAGS="-mmacosx-version-min=10.7" --disable-audio --disable-video-vulkan --disable-render --disable-filesystem --disable-threads --disable-directx --disable-mmx --disable-3dnow --disable-sse --disable-sse2 --disable-sse3 --disable-cpuinfo --disable-sensor --enable-hidapi --disable-joystick-mfi
working-directory: SDL/build-macos64
- run: make -j
working-directory: SDL/build-macos64
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/releaseaction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
java-version: 1.8
- run: mkdir -p SDL/build-macos64
# No --disable-video for macOS https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c70c727c98b24ad8b44e05285b8785be15062af0
- run: ../configure CFLAGS="-fPIC" CPPFLAGS="-fPIC" --disable-audio --disable-video-vulkan --disable-render --disable-filesystem --disable-threads --disable-directx --disable-mmx --disable-3dnow --disable-sse --disable-sse2 --disable-sse3 --disable-cpuinfo --disable-sensor --enable-hidapi
- run: ../configure CFLAGS="-fPIC -mmacosx-version-min=10.7" CPPFLAGS="-fPIC -mmacosx-version-min=10.7" LDFLAGS="-mmacosx-version-min=10.7" --disable-audio --disable-video-vulkan --disable-render --disable-filesystem --disable-threads --disable-directx --disable-mmx --disable-3dnow --disable-sse --disable-sse2 --disable-sse3 --disable-cpuinfo --disable-sensor --enable-hidapi --disable-joystick-mfi
working-directory: SDL/build-macos64
- run: make -j
working-directory: SDL/build-macos64
Expand Down
11 changes: 11 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

Jamepad is built on Github Actions. Take a look at the workflow files to see what's happening.

Updating SDL version submodule to a new version:

```
cd SDL
git checkout release-x.x.x
cd..
git add SDL
git commit -m "Update to SDL x.x.x"
git push
```

If you need to built locally, follow the steps taken there.


Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ The following information is only needed for non-gdx Java projects.

### Getting Jamepad

[![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/com.badlogicgames.jamepad/jamepad?nexusVersion=2&server=https%3A%2F%2Foss.sonatype.org&label=release)](https://search.maven.org/artifact/com.badlogicgames.jamepad/jamepad)
[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/com.badlogicgames.jamepad/jamepad?server=https%3A%2F%2Foss.sonatype.org&label=snapshot)](https://oss.sonatype.org/#nexus-search;gav~com.badlogicgames.jamepad~jamepad)

##### gradle
If you use gradle, you can pull this package in from Maven Central.
Add this line to your dependencies section. Update the version number to whatever the latest release is.
Expand Down
2 changes: 1 addition & 1 deletion SDL
Submodule SDL updated 506 files
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=com.badlogicgames.jamepad
version=2.0.12.2
version=2.0.14.0
POM_DESCRIPTION=libGDX jamepad build
POM_NAME=libGDX jamepad build
POM_URL=https://github.com/libgdx/jamepad
Expand Down
77 changes: 55 additions & 22 deletions res/gamecontrollerdb.txt

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/main/java/com/studiohartman/jamepad/ControllerButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ public enum ControllerButton {
DPAD_DOWN,
DPAD_LEFT,
DPAD_RIGHT,
BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button */
BUTTON_PADDLE1, /* Xbox Elite paddle P1 */
BUTTON_PADDLE2, /* Xbox Elite paddle P3 */
BUTTON_PADDLE3, /* Xbox Elite paddle P2 */
BUTTON_PADDLE4, /* Xbox Elite paddle P4 */
BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
}
28 changes: 4 additions & 24 deletions src/main/java/com/studiohartman/jamepad/ControllerIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,33 +108,21 @@ public int getIndex() {
}


/**
* Start vibrating the controller.
*
* @deprecated use doVibration instead
* @param leftMagnitude The speed for the left motor to vibrate (this should be between 0 and 1)
* @param rightMagnitude The speed for the right motor to vibrate (this should be between 0 and 1)
* @return Whether or not the controller was able to be vibrated (i.e. if haptics are supported)
* @throws ControllerUnpluggedException If the controller is not connected
*/
@Deprecated
public boolean startVibration(float leftMagnitude, float rightMagnitude) throws ControllerUnpluggedException {
return doVibration(leftMagnitude,rightMagnitude , 1000);
}

private native boolean nativeDoVibration(long controllerPtr, int leftMagnitude, int rightMagnitude, int duration_ms); /*
SDL_Joystick* joystick = SDL_GameControllerGetJoystick((SDL_GameController*) controllerPtr);
return SDL_JoystickRumble(joystick, leftMagnitude, rightMagnitude, duration_ms) == 0;
*/

/**
* Vibrate the controller using the new rumble API
* Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
*
* This will return false if the controller doesn't support vibration or if SDL was unable to start
* vibration (maybe the controller doesn't support left/right vibration, maybe it was unplugged in the
* middle of trying, etc...)
*
* @param leftMagnitude The speed for the left motor to vibrate (this should be between 0 and 1)
* @param rightMagnitude The speed for the right motor to vibrate (this should be between 0 and 1)
* @param leftMagnitude The intensity of the left rumble motor (this should be between 0 and 1)
* @param rightMagnitude The intensity of the right rumble motor (this should be between 0 and 1)
* @return Whether or not the controller was able to be vibrated (i.e. if haptics are supported)
* @throws ControllerUnpluggedException If the controller is not connected
*/
Expand All @@ -151,14 +139,6 @@ public boolean doVibration(float leftMagnitude, float rightMagnitude, int durati
return nativeDoVibration(controllerPtr, (int) (65535 * leftMagnitude), (int) (65535 * rightMagnitude), duration_ms);
}

/**
* Does nothing
* @deprecated not needed by new rumble API
*/
@Deprecated
public void stopVibration() {
}

/**
* Returns whether or not a given button has been pressed.
*
Expand Down
38 changes: 6 additions & 32 deletions src/main/java/com/studiohartman/jamepad/ControllerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public void initSDLGamepad() throws IllegalStateException {
}
}
private native boolean nativeInitSDLGamepad(); /*
SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, "0");
if (SDL_Init(SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) != 0) {
printf("NATIVE METHOD: SDL_Init failed: %s\n", SDL_GetError());
return JNI_FALSE;
Expand Down Expand Up @@ -164,9 +166,11 @@ public ControllerState getState(int index) throws IllegalStateException {
* the controller at that index doesn't support haptics, or if there is no controller at that index),
* this method will return false.
*
* Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
*
* @param index The index of the controller that will be vibrated
* @param leftMagnitude The magnitude the left vibration motor will be set to
* @param rightMagnitude The magnitude the right vibration motor will be set to
* @param leftMagnitude The intensity of the left rumble motor (0-1)
* @param rightMagnitude The intensity of the rught rumble motor (0-1)
* @return Whether or not vibration was successfully started
* @throws IllegalStateException if Jamepad was not initialized
*/
Expand All @@ -184,36 +188,6 @@ public boolean doVibration(int index, float leftMagnitude, float rightMagnitude,
return false;
}

/**
* Use doVibration instead
*
* @deprecated Hatpics replaced by new rumble API, use doVibrarion instead
* @param index The index of the controller that will be vibrated
* @param leftMagnitude The magnitude the left vibration motor will be set to
* @param rightMagnitude The magnitude the right vibration motor will be set to
* @return Whether or not vibration was successfully started
* @throws IllegalStateException if Jamepad was not initialized
*/
@Deprecated
public boolean startVibration(int index, float leftMagnitude, float rightMagnitude) throws IllegalStateException {
return doVibration(index, leftMagnitude, rightMagnitude, 1000);
}

/**
* Does nothing
*
* @deprecated new rumble API does not need this
* @param index The index of the controller whose vibration effects will be stopped
*/
@Deprecated
public void stopVibration(int index) {
verifyInitialized();

if(index < controllers.length && index >= 0) {
controllers[index].stopVibration();
}
}

/**
* Returns a the ControllerIndex object with the passed index (0 for p1, 1 for p2, etc.).
*
Expand Down

0 comments on commit c0610ab

Please sign in to comment.