Attach the profile name to the ControllerEmu.h, so that it can be retrieved by the android frontend.

This commit is contained in:
Felix Nüsse 2025-08-09 13:07:00 +02:00
commit c2e414ea7b
7 changed files with 50 additions and 16 deletions

View file

@ -35,10 +35,12 @@ class EmulatedController private constructor(private val pointer: Long) : Contro
external fun clearSettings()
external fun loadProfile(path: String)
external fun loadProfile(path: String, profileName: String)
external fun saveProfile(path: String)
external fun getProfileName(): String
external fun getProfileKey(): String
external fun getUserProfileDirectoryPath(): String

View file

@ -11,7 +11,7 @@ import org.dolphinemu.dolphinemu.R
import org.dolphinemu.dolphinemu.databinding.DialogInputStringBinding
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivityView
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization
import org.dolphinemu.dolphinemu.utils.Log
import java.io.File
import java.util.Locale
@ -47,9 +47,11 @@ class ProfileDialogPresenter {
.setMessage(context.getString(R.string.input_profile_confirm_load, profileName))
.setPositiveButton(R.string.yes) { _: DialogInterface?, _: Int ->
menuTag.correspondingEmulatedController
.loadProfile(getProfilePath(profileName, stock))
.loadProfile(getProfilePath(profileName, stock), profileName)
(dialog!!.requireActivity() as SettingsActivityView).onControllerSettingsChanged()
dialog.dismiss()
Log.error("Loaded Profile: $profileName, ${menuTag.correspondingEmulatedController.getProfileName()}")
}
.setNegativeButton(R.string.no, null)
.show()

View file

@ -14,7 +14,7 @@ import org.dolphinemu.dolphinemu.features.settings.model.Settings
*/
abstract class SettingsItem {
val name: CharSequence
val description: CharSequence
var description: CharSequence
/**
* Base constructor.
@ -71,6 +71,15 @@ abstract class SettingsItem {
setting!!.delete(settings)
}
/**
* Update Description of this SettingsItem
*
* @param description New text string to be displayed as this Setting's description.
*/
open fun updateDescription(description: String) {
this.description = description
}
companion object {
const val TYPE_HEADER = 0
const val TYPE_SWITCH = 1

View file

@ -34,7 +34,6 @@ import org.dolphinemu.dolphinemu.features.settings.model.view.*
import org.dolphinemu.dolphinemu.model.GpuDriverMetadata
import org.dolphinemu.dolphinemu.ui.main.MainPresenter
import org.dolphinemu.dolphinemu.utils.*
import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.ceil
import kotlin.math.floor
@ -2265,7 +2264,6 @@ class SettingsFragmentPresenter(
private fun addWiimoteSubSettings(sl: ArrayList<SettingsItem>, wiimoteNumber: Int) {
val wiimote = EmulatedController.getWiimote(wiimoteNumber)
if (!TextUtils.isEmpty(gameId)) {
addControllerPerGameSettings(sl, wiimote, wiimoteNumber)
} else {
@ -2438,15 +2436,24 @@ class SettingsFragmentPresenter(
0,
true
) { clearControllerSettings(controller) })
sl.add(
RunRunnable(
context,
R.string.input_profiles,
0,
0,
0,
true
) { fragmentView.showDialogFragment(ProfileDialog.create(menuTag)) })
val profileSelector = RunRunnable(
context,
R.string.input_profiles,
0,
0,
0,
true
) { fragmentView.showDialogFragment(ProfileDialog.create(menuTag)) }
sl.add(profileSelector)
profileSelector.updateDescription(context.getString(R.string.input_profiles_descríption, controller.getProfileName()))
/*var l = ""
ProfileDialogPresenter(menuTag).getProfileNames(false).forEach { l+= "$it, " }
Log.error("Profile: ${}")
Log.error("Profiles: $l")*/
updateOldControllerSettingsWarningVisibility(controller)
}

View file

@ -37,6 +37,7 @@
<string name="input_profile">Profile</string>
<string name="input_profiles_empty">You haven\'t created any profiles yet.</string>
<string name="input_profiles">Profiles</string>
<string name="input_profiles_descríption">Loaded Profile: %1$s</string>
<string name="input_profile_new">(New Profile)</string>
<string name="input_profile_load">Load</string>
<string name="input_profile_save">Save</string>

View file

@ -121,7 +121,7 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro
JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_loadProfile(
JNIEnv* env, jobject obj, jstring j_path)
JNIEnv* env, jobject obj, jstring j_path, jstring j_profileName)
{
ControllerEmu::EmulatedController* controller = EmulatedControllerFromJava(env, obj);
@ -129,6 +129,7 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro
ini.Load(GetJString(env, j_path));
controller->LoadConfig(ini.GetOrCreateSection("Profile"));
controller->SetProfileName(GetJString(env, j_profileName));
controller->UpdateReferences(g_controller_interface);
controller->GetConfig()->GenerateControllerTextures();
}
@ -154,6 +155,14 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro
return ToJString(env, EmulatedControllerFromJava(env, obj)->GetConfig()->GetProfileKey());
}
JNIEXPORT jstring JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getProfileName(
JNIEnv* env, jobject obj)
{
return ToJString(env, EmulatedControllerFromJava(env, obj)->GetProfileName());
}
JNIEXPORT jstring JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getUserProfileDirectoryPath(
JNIEnv* env, jobject obj)

View file

@ -244,6 +244,9 @@ public:
void LoadConfig(Common::IniFile::Section* sec);
void SaveConfig(Common::IniFile::Section* sec);
std::string GetProfileName(){ return m_profile_name; }
void SetProfileName(std::string name){ m_profile_name = name; }
bool IsDefaultDeviceConnected() const;
const ciface::Core::DeviceQualifier& GetDefaultDevice() const;
void SetDefaultDevice(const std::string& device);
@ -269,5 +272,6 @@ protected:
private:
ciface::Core::DeviceQualifier m_default_device;
bool m_default_device_is_connected{false};
std::string m_profile_name = "";
};
} // namespace ControllerEmu