mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-04 23:55:08 +01:00
Rename SettingsValues
to NativeSettings
The previous name was chosen as an afterthought and didn't clearly indicate what the purpose of the class is. We needed a separate, simple class without delegates members (like PreferenceSettings), so that its fields can be easily accessed via JNI to get settings values from native code.
This commit is contained in:
parent
f734c4d145
commit
5aa2a4cd1c
@ -231,13 +231,13 @@ extern "C" JNIEXPORT void JNICALL Java_emu_skyline_EmulationActivity_setTouchSta
|
||||
env->ReleaseIntArrayElements(pointsJni, reinterpret_cast<jint *>(points.data()), JNI_ABORT);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_emu_skyline_utils_SettingsValues_updateNative(JNIEnv *env, jobject) {
|
||||
extern "C" JNIEXPORT void JNICALL Java_emu_skyline_utils_NativeSettings_updateNative(JNIEnv *env, jobject) {
|
||||
auto settings{SettingsWeak.lock()};
|
||||
if (!settings)
|
||||
return; // We don't mind if we miss settings updates while settings haven't been initialized
|
||||
settings->Update();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_emu_skyline_utils_SettingsValues_00024Companion_setLogLevel(JNIEnv *, jobject, jint logLevel) {
|
||||
extern "C" JNIEXPORT void JNICALL Java_emu_skyline_utils_NativeSettings_00024Companion_setLogLevel(JNIEnv *, jobject, jint logLevel) {
|
||||
skyline::Logger::configLevel = static_cast<skyline::Logger::LogLevel>(logLevel);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import emu.skyline.input.*
|
||||
import emu.skyline.loader.getRomFormat
|
||||
import emu.skyline.utils.PreferenceSettings
|
||||
import emu.skyline.utils.ByteBufferSerializable
|
||||
import emu.skyline.utils.SettingsValues
|
||||
import emu.skyline.utils.NativeSettings
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.util.concurrent.FutureTask
|
||||
@ -85,13 +85,13 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
||||
* @param romUri The URI of the ROM as a string, used to print out in the logs
|
||||
* @param romType The type of the ROM as an enum value
|
||||
* @param romFd The file descriptor of the ROM object
|
||||
* @param settingsValues The SettingsValues instance
|
||||
* @param nativeSettings The settings to be used by libskyline
|
||||
* @param publicAppFilesPath The full path to the public app files directory
|
||||
* @param privateAppFilesPath The full path to the private app files directory
|
||||
* @param nativeLibraryPath The full path to the app native library directory
|
||||
* @param assetManager The asset manager used for accessing app assets
|
||||
*/
|
||||
private external fun executeApplication(romUri : String, romType : Int, romFd : Int, settingsValues : SettingsValues, publicAppFilesPath : String, privateAppFilesPath : String, nativeLibraryPath : String, assetManager : AssetManager)
|
||||
private external fun executeApplication(romUri : String, romType : Int, romFd : Int, nativeSettings : NativeSettings, publicAppFilesPath : String, privateAppFilesPath : String, nativeLibraryPath : String, assetManager : AssetManager)
|
||||
|
||||
/**
|
||||
* @param join If the function should only return after all the threads join or immediately
|
||||
@ -249,7 +249,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
||||
val romFd = contentResolver.openFileDescriptor(rom, "r")!!
|
||||
|
||||
emulationThread = Thread {
|
||||
executeApplication(rom.toString(), romType, romFd.detachFd(), SettingsValues(preferenceSettings), applicationContext.getPublicFilesDir().canonicalPath + "/", applicationContext.filesDir.canonicalPath + "/", applicationInfo.nativeLibraryDir + "/", assets)
|
||||
executeApplication(rom.toString(), romType, romFd.detachFd(), NativeSettings(preferenceSettings), applicationContext.getPublicFilesDir().canonicalPath + "/", applicationContext.filesDir.canonicalPath + "/", applicationInfo.nativeLibraryDir + "/", assets)
|
||||
returnFromEmulation()
|
||||
}
|
||||
|
||||
|
@ -8,12 +8,12 @@ package emu.skyline.preference
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.preference.R
|
||||
import emu.skyline.utils.SettingsValues
|
||||
import emu.skyline.utils.NativeSettings
|
||||
|
||||
class LogLevelPreference @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = R.attr.dialogPreferenceStyle) : IntegerListPreference(context, attrs, defStyleAttr) {
|
||||
init {
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
SettingsValues.setLogLevel(newValue as Int)
|
||||
NativeSettings.setLogLevel(newValue as Int)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,10 @@
|
||||
|
||||
package emu.skyline.utils
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
class SettingsValues(pref: PreferenceSettings) : Serializable {
|
||||
/**
|
||||
* The settings that will be passed to libskyline when running and executable
|
||||
*/
|
||||
class NativeSettings(pref: PreferenceSettings) {
|
||||
var isDocked : Boolean = pref.isDocked
|
||||
var usernameValue : String = pref.usernameValue
|
||||
var systemLanguage : Int = pref.systemLanguage
|
||||
@ -21,7 +22,7 @@ class SettingsValues(pref: PreferenceSettings) : Serializable {
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Setter for native log level
|
||||
* Sets libskyline logger level to the given one
|
||||
*/
|
||||
external fun setLogLevel(logLevel : Int)
|
||||
}
|
Loading…
Reference in New Issue
Block a user