Skip to content

Commit

Permalink
Merge branch 'master' into touchcancel
Browse files Browse the repository at this point in the history
  • Loading branch information
obigu committed Jul 3, 2022
2 parents 4f08949 + 35e7b11 commit dfa1f60
Show file tree
Hide file tree
Showing 47 changed files with 1,133 additions and 182 deletions.
62 changes: 36 additions & 26 deletions .github/workflows/build-publish.yml
Expand Up @@ -17,10 +17,12 @@ jobs:
with:
fetch-depth: 0
submodules: 'recursive'
- name: Set up JDK 1.8
uses: actions/setup-java@v1

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 1.8
distribution: 'zulu'
java-version: '11'

- name: Cache Gradle packages
uses: actions/cache@v2
Expand Down Expand Up @@ -66,10 +68,12 @@ jobs:
with:
fetch-depth: 0
submodules: 'recursive'
- name: Set up JDK 1.8
uses: actions/setup-java@v1

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 1.8
distribution: 'zulu'
java-version: '11'

- name: Cache Gradle packages
uses: actions/cache@v2
Expand Down Expand Up @@ -115,10 +119,11 @@ jobs:
fetch-depth: 0
submodules: 'recursive'

- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 1.8
distribution: 'zulu'
java-version: '11'

- name: Install cross-compilation toolchains
run: |
Expand Down Expand Up @@ -164,10 +169,11 @@ jobs:
fetch-depth: 0
submodules: 'recursive'

- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 1.8
distribution: 'zulu'
java-version: '11'

- name: Install cross-compilation toolchains
run: |
Expand Down Expand Up @@ -211,10 +217,11 @@ jobs:
fetch-depth: 0
submodules: 'recursive'

- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 1.8
distribution: 'zulu'
java-version: '11'

- name: Cache Gradle packages
uses: actions/cache@v2
Expand Down Expand Up @@ -259,10 +266,11 @@ jobs:
fetch-depth: 0
submodules: 'recursive'

- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 1.8
distribution: 'zulu'
java-version: '11'

- name: Cache Gradle packages
uses: actions/cache@v2
Expand Down Expand Up @@ -348,10 +356,11 @@ jobs:
fetch-depth: 0
submodules: 'recursive'

- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 1.8
distribution: 'zulu'
java-version: '11'

- name: Download natives artifact
uses: actions/download-artifact@v2
Expand All @@ -378,11 +387,11 @@ jobs:
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Release build deploy
if: github.event_name == 'release' && github.repository_owner == 'libgdx'
run: ./gradlew build publish -PRELEASE -Psigning.gnupg.keyId=${{ secrets.GPG_KEYID }} -Psigning.gnupg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Psigning.gnupg.keyName=${{ secrets.GPG_KEYID }}


build-and-upload-runnables:
runs-on: ubuntu-18.04
env:
Expand All @@ -394,10 +403,12 @@ jobs:
fetch-depth: 0
submodules: 'recursive'

- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 1.8
distribution: 'zulu'
java-version: '11'

- name: Build Runnables
run: ./gradlew clean fetchNatives buildRunnables build

Expand All @@ -407,4 +418,3 @@ jobs:
aws s3 cp ./extensions/gdx-tools/build/libs/ s3://libgdx-nightlies/libgdx-runnables/ --recursive
aws s3 cp ./extensions/gdx-setup/build/libs/ s3://libgdx-nightlies/libgdx-runnables/ --recursive
7 changes: 4 additions & 3 deletions .github/workflows/build-pullrequest.yml
Expand Up @@ -16,10 +16,11 @@ jobs:
fetch-depth: 0
submodules: 'recursive'

- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 1.8
distribution: 'zulu'
java-version: '11'

- name: Cache Gradle packages
uses: actions/cache@v2
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/fix-formatting.yml
Expand Up @@ -9,10 +9,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 1.8
distribution: 'zulu'
java-version: '11'

- name: Cache Gradle packages
uses: actions/cache@v2
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Expand Up @@ -19,7 +19,6 @@ gwt-unitCache/
war/
gen/
gen-external-apklibs/
armeabi/
armeabi-v7a/
arm64-v8a/
linux32/
Expand All @@ -33,7 +32,6 @@ Release/
x64/
x86/
x86_64/
robovm-build/
ipch/
/dist

Expand Down
7 changes: 7 additions & 0 deletions CHANGES
@@ -1,8 +1,15 @@
[1.11.1]
- [BREAKING CHANGE] Added #touchCancelled to InputProcessor interface, see #6871.
- [BREAKING CHANGE] Android: Immersive mode is now true by default. Set `useImmersiveMode` config to `false` to disable it.
- [BREAKING CHANGE] iOS: `hideHomeIndicator` set to `false` by default (was `true`).
- [BREAKING CHANGE] iOS: `screenEdgesDeferringSystemGestures` set to `UIRectEdge.All` by default (was `UIRectEdge.None`).
- iOS: Add new MobiVM MetalANGLE backend
- API Addition: Added Haptics API with 4 different Input#vibrate() methods with complete Android and iOS implementations.
- Fix: Fixed Android and iOS touch cancelled related issues, see #6871.
- Javadoc: Add "-use" flag to javadoc generation
- Android: gdx-setup now uses AGP 7.0.4 and SDK 31, requiring Android Studio Arctic Fox or IntelliJ IDEA 2021.3 and JDK 11.
- libGDX is now built using Java 11 due to new Android requirements. The rest of libGDX can still be built with JDK 8 and runtime compatibility of libGDX projects should be unaffected.
- Fixed glViewport when using HdpiMode.Logical with the LWJGL3 backend.

[1.11.0]
- [BREAKING CHANGE] iOS: Increased min supported iOS version to 9.0. Update your Info.plist file if necessary.
Expand Down
Expand Up @@ -88,7 +88,7 @@ public class AndroidApplicationConfiguration {
public boolean getTouchEventsForLiveWallpaper = false;

/** set this to true to enable Android 4.4 KitKat's 'Immersive mode' **/
public boolean useImmersiveMode = false;
public boolean useImmersiveMode = true;

/** Experimental, whether to enable OpenGL ES 3 if supported. If not supported it will fall-back to OpenGL ES 2.0. When GL ES
* 3* is enabled, {@link com.badlogic.gdx.Gdx#gl30} can be used to access its functionality. Requires at least Android 4.3 (API
Expand Down
@@ -0,0 +1,112 @@
/*******************************************************************************
* Copyright 2011 See AUTHORS file.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/

package com.badlogic.gdx.backends.android;

import android.content.Context;
import android.media.AudioAttributes;
import android.os.Build;
import android.os.VibrationEffect;
import android.os.Vibrator;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.math.MathUtils;

public class AndroidHaptics {

private final Vibrator vibrator;
private AudioAttributes audioAttributes;
private boolean vibratorSupport;
private boolean amplitudeSupport;

public AndroidHaptics (Context context) {
vibratorSupport = false;
amplitudeSupport = false;
this.vibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
if (vibrator != null && vibrator.hasVibrator()) {
vibratorSupport = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (vibrator.hasAmplitudeControl()) {
amplitudeSupport = true;
}
this.audioAttributes = new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_GAME).build();
}
}
}

public void vibrate (int milliseconds) {
if (vibratorSupport) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
vibrator.vibrate(VibrationEffect.createOneShot(milliseconds, VibrationEffect.DEFAULT_AMPLITUDE));
else
vibrator.vibrate(milliseconds);
}
}

public void vibrate (Input.VibrationType vibrationType) {
if (amplitudeSupport) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
int vibrationEffect;
switch (vibrationType) {
case LIGHT:
vibrationEffect = VibrationEffect.EFFECT_TICK;
break;
case MEDIUM:
vibrationEffect = VibrationEffect.EFFECT_CLICK;
break;
case HEAVY:
vibrationEffect = VibrationEffect.EFFECT_HEAVY_CLICK;
break;
default:
throw new IllegalArgumentException("Unknown VibrationType " + vibrationType);
}
vibrator.vibrate(VibrationEffect.createPredefined(vibrationEffect), audioAttributes);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
int amplitude;
switch (vibrationType) {
case LIGHT:
amplitude = 50;
break;
case MEDIUM:
amplitude = VibrationEffect.DEFAULT_AMPLITUDE;
break;
case HEAVY:
amplitude = 250;
break;
default:
throw new IllegalArgumentException("Unknown VibrationType " + vibrationType);
}
vibrator.vibrate(VibrationEffect.createOneShot(25, amplitude));
}
}
}

public void vibrate (int milliseconds, int intensity, boolean fallback) {
if (amplitudeSupport) {
intensity = MathUtils.clamp(intensity, 0, 255);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
vibrator.vibrate(VibrationEffect.createOneShot(milliseconds, intensity));
} else if (fallback) vibrate(milliseconds);
}

public boolean hasVibratorAvailable () {
return vibratorSupport;
}

public boolean hasAmplitudeSupport () {
return amplitudeSupport;
}
}
Expand Up @@ -102,7 +102,7 @@ public long loop () {
@Override
public long loop (float volume) {
if (streamIds.size == 8) streamIds.pop();
int streamId = soundPool.play(soundId, volume, volume, 1, -1, 1);
int streamId = soundPool.play(soundId, volume, volume, 2, -1, 1);
// standardise error code with other backends
if (streamId == 0) return -1;
streamIds.insert(0, streamId);
Expand All @@ -112,9 +112,12 @@ public long loop (float volume) {
@Override
public void setLooping (long soundId, boolean looping) {
int streamId = (int)soundId;

soundPool.pause(streamId);
soundPool.setLoop(streamId, looping ? -1 : 0);
if (looping)
soundPool.setPriority(streamId, 2);
else
soundPool.setPriority(streamId, 1);
soundPool.resume(streamId);
}

Expand Down Expand Up @@ -159,7 +162,7 @@ public long loop (float volume, float pitch, float pan) {
} else if (pan > 0) {
leftVolume *= (1 - Math.abs(pan));
}
int streamId = soundPool.play(soundId, leftVolume, rightVolume, 1, -1, pitch);
int streamId = soundPool.play(soundId, leftVolume, rightVolume, 2, -1, pitch);
// standardise error code with other backends
if (streamId == 0) return -1;
streamIds.insert(0, streamId);
Expand Down

0 comments on commit dfa1f60

Please sign in to comment.