mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-06-19 06:47:52 +00:00
Use numeric codes for Android versions, to avoid SDK dependencies
(cherry picked from commit 3f6b2d1a61d0c0dcd6af7cc951c1d8c267ed1526)
This commit is contained in:
parent
a2f4783e75
commit
0ad0347acb
|
@ -93,7 +93,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||||
|
|
||||||
s2 = s_copy & InputDevice.SOURCE_ANY; // keep source only, no class;
|
s2 = s_copy & InputDevice.SOURCE_ANY; // keep source only, no class;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= 23) {
|
||||||
tst = InputDevice.SOURCE_BLUETOOTH_STYLUS;
|
tst = InputDevice.SOURCE_BLUETOOTH_STYLUS;
|
||||||
if ((s & tst) == tst) src += " BLUETOOTH_STYLUS";
|
if ((s & tst) == tst) src += " BLUETOOTH_STYLUS";
|
||||||
s2 &= ~tst;
|
s2 &= ~tst;
|
||||||
|
@ -107,7 +107,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||||
if ((s & tst) == tst) src += " GAMEPAD";
|
if ((s & tst) == tst) src += " GAMEPAD";
|
||||||
s2 &= ~tst;
|
s2 &= ~tst;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
tst = InputDevice.SOURCE_HDMI;
|
tst = InputDevice.SOURCE_HDMI;
|
||||||
if ((s & tst) == tst) src += " HDMI";
|
if ((s & tst) == tst) src += " HDMI";
|
||||||
s2 &= ~tst;
|
s2 &= ~tst;
|
||||||
|
@ -146,7 +146,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||||
if ((s & tst) == tst) src += " TOUCHSCREEN";
|
if ((s & tst) == tst) src += " TOUCHSCREEN";
|
||||||
s2 &= ~tst;
|
s2 &= ~tst;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
if (Build.VERSION.SDK_INT >= 18) {
|
||||||
tst = InputDevice.SOURCE_TOUCH_NAVIGATION;
|
tst = InputDevice.SOURCE_TOUCH_NAVIGATION;
|
||||||
if ((s & tst) == tst) src += " TOUCH_NAVIGATION";
|
if ((s & tst) == tst) src += " TOUCH_NAVIGATION";
|
||||||
s2 &= ~tst;
|
s2 &= ~tst;
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class SDLAudioManager {
|
||||||
mAudioRecord = null;
|
mAudioRecord = null;
|
||||||
mAudioDeviceCallback = null;
|
mAudioDeviceCallback = null;
|
||||||
|
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
if(Build.VERSION.SDK_INT >= 24)
|
||||||
{
|
{
|
||||||
mAudioDeviceCallback = new AudioDeviceCallback() {
|
mAudioDeviceCallback = new AudioDeviceCallback() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -237,7 +237,7 @@ public class SDLAudioManager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && deviceId != 0) {
|
if (Build.VERSION.SDK_INT >= 24 && deviceId != 0) {
|
||||||
mAudioRecord.setPreferredDevice(getOutputAudioDeviceInfo(deviceId));
|
mAudioRecord.setPreferredDevice(getOutputAudioDeviceInfo(deviceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ public class SDLAudioManager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && deviceId != 0) {
|
if (Build.VERSION.SDK_INT >= 24 && deviceId != 0) {
|
||||||
mAudioTrack.setPreferredDevice(getInputAudioDeviceInfo(deviceId));
|
mAudioTrack.setPreferredDevice(getInputAudioDeviceInfo(deviceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ public class SDLAudioManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AudioDeviceInfo getInputAudioDeviceInfo(int deviceId) {
|
private static AudioDeviceInfo getInputAudioDeviceInfo(int deviceId) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||||
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS))
|
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS))
|
||||||
.filter(deviceInfo -> deviceInfo.getId() == deviceId)
|
.filter(deviceInfo -> deviceInfo.getId() == deviceId)
|
||||||
|
@ -295,7 +295,7 @@ public class SDLAudioManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AudioDeviceInfo getOutputAudioDeviceInfo(int deviceId) {
|
private static AudioDeviceInfo getOutputAudioDeviceInfo(int deviceId) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||||
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS))
|
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS))
|
||||||
.filter(deviceInfo -> deviceInfo.getId() == deviceId)
|
.filter(deviceInfo -> deviceInfo.getId() == deviceId)
|
||||||
|
@ -307,14 +307,14 @@ public class SDLAudioManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerAudioDeviceCallback() {
|
private static void registerAudioDeviceCallback() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||||
audioManager.registerAudioDeviceCallback(mAudioDeviceCallback, null);
|
audioManager.registerAudioDeviceCallback(mAudioDeviceCallback, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void unregisterAudioDeviceCallback(Context context) {
|
private static void unregisterAudioDeviceCallback(Context context) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||||
audioManager.unregisterAudioDeviceCallback(mAudioDeviceCallback);
|
audioManager.unregisterAudioDeviceCallback(mAudioDeviceCallback);
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ public class SDLAudioManager {
|
||||||
* This method is called by SDL using JNI.
|
* This method is called by SDL using JNI.
|
||||||
*/
|
*/
|
||||||
public static int[] getAudioOutputDevices() {
|
public static int[] getAudioOutputDevices() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||||
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS)).mapToInt(AudioDeviceInfo::getId).toArray();
|
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS)).mapToInt(AudioDeviceInfo::getId).toArray();
|
||||||
} else {
|
} else {
|
||||||
|
@ -336,7 +336,7 @@ public class SDLAudioManager {
|
||||||
* This method is called by SDL using JNI.
|
* This method is called by SDL using JNI.
|
||||||
*/
|
*/
|
||||||
public static int[] getAudioInputDevices() {
|
public static int[] getAudioInputDevices() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||||
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS)).mapToInt(AudioDeviceInfo::getId).toArray();
|
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS)).mapToInt(AudioDeviceInfo::getId).toArray();
|
||||||
} else {
|
} else {
|
||||||
|
@ -360,7 +360,7 @@ public class SDLAudioManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
|
if (android.os.Build.VERSION.SDK_INT < 21) {
|
||||||
Log.e(TAG, "Attempted to make an incompatible audio call with uninitialized audio! (floating-point output is supported since Android 5.0 Lollipop)");
|
Log.e(TAG, "Attempted to make an incompatible audio call with uninitialized audio! (floating-point output is supported since Android 5.0 Lollipop)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue