mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-11-03 16:39:01 -06:00 
			
		
		
		
	android: Refactor native and corresponding variables
This commit is contained in:
		@@ -286,7 +286,7 @@ object NativeLibrary {
 | 
			
		||||
    /**
 | 
			
		||||
     * Unpauses emulation from a paused state.
 | 
			
		||||
     */
 | 
			
		||||
    external fun unPauseEmulation()
 | 
			
		||||
    external fun unpauseEmulation()
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Pauses emulation.
 | 
			
		||||
@@ -321,7 +321,7 @@ object NativeLibrary {
 | 
			
		||||
    /**
 | 
			
		||||
     * Unmutes emulation sound
 | 
			
		||||
     */
 | 
			
		||||
    external fun unMuteAudio(): Boolean
 | 
			
		||||
    external fun unmuteAudio(): Boolean
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns true if emulation audio is muted.
 | 
			
		||||
 
 | 
			
		||||
@@ -64,7 +64,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
 | 
			
		||||
    private val actionPause = "ACTION_EMULATOR_PAUSE"
 | 
			
		||||
    private val actionPlay = "ACTION_EMULATOR_PLAY"
 | 
			
		||||
    private val actionMute = "ACTION_EMULATOR_MUTE"
 | 
			
		||||
    private val actionSound = "ACTION_EMULATOR_SOUND"
 | 
			
		||||
    private val actionUnmute = "ACTION_EMULATOR_UNMUTE"
 | 
			
		||||
 | 
			
		||||
    private val settingsViewModel: SettingsViewModel by viewModels()
 | 
			
		||||
 | 
			
		||||
@@ -308,20 +308,23 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (NativeLibrary.isMuted()) {
 | 
			
		||||
            val soundIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_sound)
 | 
			
		||||
            val soundPendingIntent = PendingIntent.getBroadcast(
 | 
			
		||||
            val unmuteIcon = Icon.createWithResource(
 | 
			
		||||
                this@EmulationActivity,
 | 
			
		||||
                R.drawable.ic_pip_sound,
 | 
			
		||||
                Intent(actionSound),
 | 
			
		||||
                R.drawable.ic_pip_unmute
 | 
			
		||||
            )
 | 
			
		||||
            val unmutePendingIntent = PendingIntent.getBroadcast(
 | 
			
		||||
                this@EmulationActivity,
 | 
			
		||||
                R.drawable.ic_pip_unmute,
 | 
			
		||||
                Intent(actionUnmute),
 | 
			
		||||
                pendingFlags
 | 
			
		||||
            )
 | 
			
		||||
            val soundRemoteAction = RemoteAction(
 | 
			
		||||
                soundIcon,
 | 
			
		||||
                getString(R.string.sound),
 | 
			
		||||
                getString(R.string.sound),
 | 
			
		||||
                soundPendingIntent
 | 
			
		||||
            val unmuteRemoteAction = RemoteAction(
 | 
			
		||||
                unmuteIcon,
 | 
			
		||||
                getString(R.string.unmute),
 | 
			
		||||
                getString(R.string.unmute),
 | 
			
		||||
                unmutePendingIntent
 | 
			
		||||
            )
 | 
			
		||||
            pictureInPictureActions.add(soundRemoteAction)
 | 
			
		||||
            pictureInPictureActions.add(unmuteRemoteAction)
 | 
			
		||||
        } else {
 | 
			
		||||
            val muteIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_mute)
 | 
			
		||||
            val mutePendingIntent = PendingIntent.getBroadcast(
 | 
			
		||||
@@ -356,12 +359,12 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
 | 
			
		||||
    private var pictureInPictureReceiver = object : BroadcastReceiver() {
 | 
			
		||||
        override fun onReceive(context: Context?, intent: Intent) {
 | 
			
		||||
            if (intent.action == actionPlay) {
 | 
			
		||||
                if (NativeLibrary.isPaused()) NativeLibrary.unPauseEmulation()
 | 
			
		||||
                if (NativeLibrary.isPaused()) NativeLibrary.unpauseEmulation()
 | 
			
		||||
            } else if (intent.action == actionPause) {
 | 
			
		||||
                if (!NativeLibrary.isPaused()) NativeLibrary.pauseEmulation()
 | 
			
		||||
            }
 | 
			
		||||
            if (intent.action == actionSound) {
 | 
			
		||||
                if (NativeLibrary.isMuted()) NativeLibrary.unMuteAudio()
 | 
			
		||||
            if (intent.action == actionUnmute) {
 | 
			
		||||
                if (NativeLibrary.isMuted()) NativeLibrary.unmuteAudio()
 | 
			
		||||
            } else if (intent.action == actionMute) {
 | 
			
		||||
                if (!NativeLibrary.isMuted()) NativeLibrary.muteAudio()
 | 
			
		||||
            }
 | 
			
		||||
@@ -379,7 +382,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
 | 
			
		||||
                addAction(actionPause)
 | 
			
		||||
                addAction(actionPlay)
 | 
			
		||||
                addAction(actionMute)
 | 
			
		||||
                addAction(actionSound)
 | 
			
		||||
                addAction(actionUnmute)
 | 
			
		||||
            }.also {
 | 
			
		||||
                registerReceiver(pictureInPictureReceiver, it)
 | 
			
		||||
            }
 | 
			
		||||
@@ -389,7 +392,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
 | 
			
		||||
            } catch (ignored: Exception) {
 | 
			
		||||
            }
 | 
			
		||||
            // Always resume audio, since there is no UI button
 | 
			
		||||
            if (NativeLibrary.isMuted()) NativeLibrary.unMuteAudio()
 | 
			
		||||
            if (NativeLibrary.isMuted()) NativeLibrary.unmuteAudio()
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -714,7 +714,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
 | 
			
		||||
                State.PAUSED -> {
 | 
			
		||||
                    Log.debug("[EmulationFragment] Resuming emulation.")
 | 
			
		||||
                    NativeLibrary.surfaceChanged(surface)
 | 
			
		||||
                    NativeLibrary.unPauseEmulation()
 | 
			
		||||
                    NativeLibrary.unpauseEmulation()
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                else -> Log.debug("[EmulationFragment] Bug, run called while already running.")
 | 
			
		||||
 
 | 
			
		||||
@@ -583,7 +583,7 @@ jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_reloadKeys(JNIEnv* env, jclass cl
 | 
			
		||||
    return static_cast<jboolean>(Core::Crypto::KeyManager::Instance().AreKeysLoaded());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_unPauseEmulation(JNIEnv* env, jclass clazz) {
 | 
			
		||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_unpauseEmulation(JNIEnv* env, jclass clazz) {
 | 
			
		||||
    EmulationSession::GetInstance().UnPauseEmulation();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -611,7 +611,7 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_muteAduio(JNIEnv* env, jclass clazz)
 | 
			
		||||
    Settings::values.audio_muted = true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_unMuteAudio(JNIEnv* env, jclass clazz) {
 | 
			
		||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_unmuteAudio(JNIEnv* env, jclass clazz) {
 | 
			
		||||
    Settings::values.audio_muted = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -388,7 +388,7 @@
 | 
			
		||||
    <string name="pause">Pause</string>
 | 
			
		||||
    <string name="play">Play</string>
 | 
			
		||||
    <string name="mute">Mute</string>
 | 
			
		||||
    <string name="sound">Sound</string>
 | 
			
		||||
    <string name="unmute">Unmute</string>
 | 
			
		||||
 | 
			
		||||
    <!-- Licenses screen strings -->
 | 
			
		||||
    <string name="licenses">Licenses</string>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user