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

View file

@ -14,7 +14,7 @@ import org.dolphinemu.dolphinemu.features.settings.model.Settings
*/ */
abstract class SettingsItem { abstract class SettingsItem {
val name: CharSequence val name: CharSequence
val description: CharSequence var description: CharSequence
/** /**
* Base constructor. * Base constructor.
@ -71,6 +71,15 @@ abstract class SettingsItem {
setting!!.delete(settings) 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 { companion object {
const val TYPE_HEADER = 0 const val TYPE_HEADER = 0
const val TYPE_SWITCH = 1 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.model.GpuDriverMetadata
import org.dolphinemu.dolphinemu.ui.main.MainPresenter import org.dolphinemu.dolphinemu.ui.main.MainPresenter
import org.dolphinemu.dolphinemu.utils.* import org.dolphinemu.dolphinemu.utils.*
import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
import kotlin.math.ceil import kotlin.math.ceil
import kotlin.math.floor import kotlin.math.floor
@ -2265,7 +2264,6 @@ class SettingsFragmentPresenter(
private fun addWiimoteSubSettings(sl: ArrayList<SettingsItem>, wiimoteNumber: Int) { private fun addWiimoteSubSettings(sl: ArrayList<SettingsItem>, wiimoteNumber: Int) {
val wiimote = EmulatedController.getWiimote(wiimoteNumber) val wiimote = EmulatedController.getWiimote(wiimoteNumber)
if (!TextUtils.isEmpty(gameId)) { if (!TextUtils.isEmpty(gameId)) {
addControllerPerGameSettings(sl, wiimote, wiimoteNumber) addControllerPerGameSettings(sl, wiimote, wiimoteNumber)
} else { } else {
@ -2438,15 +2436,24 @@ class SettingsFragmentPresenter(
0, 0,
true true
) { clearControllerSettings(controller) }) ) { clearControllerSettings(controller) })
sl.add(
RunRunnable(
context, val profileSelector = RunRunnable(
R.string.input_profiles, context,
0, R.string.input_profiles,
0, 0,
0, 0,
true 0,
) { fragmentView.showDialogFragment(ProfileDialog.create(menuTag)) }) 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) updateOldControllerSettingsWarningVisibility(controller)
} }

View file

@ -37,6 +37,7 @@
<string name="input_profile">Profile</string> <string name="input_profile">Profile</string>
<string name="input_profiles_empty">You haven\'t created any profiles yet.</string> <string name="input_profiles_empty">You haven\'t created any profiles yet.</string>
<string name="input_profiles">Profiles</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_new">(New Profile)</string>
<string name="input_profile_load">Load</string> <string name="input_profile_load">Load</string>
<string name="input_profile_save">Save</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 JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_loadProfile( 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); 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)); ini.Load(GetJString(env, j_path));
controller->LoadConfig(ini.GetOrCreateSection("Profile")); controller->LoadConfig(ini.GetOrCreateSection("Profile"));
controller->SetProfileName(GetJString(env, j_profileName));
controller->UpdateReferences(g_controller_interface); controller->UpdateReferences(g_controller_interface);
controller->GetConfig()->GenerateControllerTextures(); controller->GetConfig()->GenerateControllerTextures();
} }
@ -154,6 +155,14 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro
return ToJString(env, EmulatedControllerFromJava(env, obj)->GetConfig()->GetProfileKey()); 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 JNIEXPORT jstring JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getUserProfileDirectoryPath( Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getUserProfileDirectoryPath(
JNIEnv* env, jobject obj) JNIEnv* env, jobject obj)

View file

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