mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
Android: Add Log Configuration to UI
This commit is contained in:
@ -15,6 +15,7 @@ import org.dolphinemu.dolphinemu.utils.Log;
|
||||
import org.dolphinemu.dolphinemu.utils.Rumble;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* Class which contains methods that interact
|
||||
@ -370,6 +371,8 @@ public final class NativeLibrary
|
||||
|
||||
public static native int DefaultCPUCore();
|
||||
|
||||
public static native int GetMaxLogLevel();
|
||||
|
||||
public static native void ReloadConfig();
|
||||
|
||||
/**
|
||||
@ -452,6 +455,10 @@ public final class NativeLibrary
|
||||
|
||||
public static native void ReloadWiimoteConfig();
|
||||
|
||||
public static native LinkedHashMap<String, String> GetLogTypeNames();
|
||||
|
||||
public static native void ReloadLoggerConfig();
|
||||
|
||||
public static native boolean InstallWAD(String file);
|
||||
|
||||
public static native String FormatSize(long bytes, int decimals);
|
||||
|
@ -39,7 +39,6 @@ public abstract class Setting
|
||||
return mSection;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return A representation of this Setting's backing value converted to a String (e.g. for serialization).
|
||||
*/
|
||||
|
@ -23,6 +23,9 @@ public class Settings
|
||||
public static final String SECTION_INI_INTERFACE = "Interface";
|
||||
public static final String SECTION_INI_DSP = "DSP";
|
||||
|
||||
public static final String SECTION_LOGGER_LOGS = "Logs";
|
||||
public static final String SECTION_LOGGER_OPTIONS = "Options";
|
||||
|
||||
public static final String SECTION_GFX_SETTINGS = "Settings";
|
||||
public static final String SECTION_GFX_ENHANCEMENTS = "Enhancements";
|
||||
public static final String SECTION_GFX_HACKS = "Hacks";
|
||||
@ -57,6 +60,8 @@ public class Settings
|
||||
configFileSectionsMap.put(SettingsFile.FILE_NAME_GFX,
|
||||
Arrays.asList(SECTION_GFX_SETTINGS, SECTION_GFX_ENHANCEMENTS, SECTION_GFX_HACKS,
|
||||
SECTION_STEREOSCOPY));
|
||||
configFileSectionsMap.put(SettingsFile.FILE_NAME_LOGGER,
|
||||
Arrays.asList(SECTION_LOGGER_LOGS, SECTION_LOGGER_OPTIONS));
|
||||
configFileSectionsMap.put(SettingsFile.FILE_NAME_WIIMOTE,
|
||||
Arrays.asList(SECTION_WIIMOTE + 1, SECTION_WIIMOTE + 2, SECTION_WIIMOTE + 3,
|
||||
SECTION_WIIMOTE + 4));
|
||||
@ -226,6 +231,7 @@ public class Settings
|
||||
// Notify the native code of the changes
|
||||
NativeLibrary.ReloadConfig();
|
||||
NativeLibrary.ReloadWiimoteConfig();
|
||||
NativeLibrary.ReloadLoggerConfig();
|
||||
|
||||
if (modifiedSettings.contains(SettingsFile.KEY_RECURSIVE_ISO_PATHS))
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ public enum MenuTag
|
||||
CONFIG_GAME_CUBE("config_gamecube"),
|
||||
CONFIG_WII("config_wii"),
|
||||
CONFIG_ADVANCED("config_advanced"),
|
||||
CONFIG_LOG("config_log"),
|
||||
WIIMOTE("wiimote"),
|
||||
WIIMOTE_EXTENSION("wiimote_extension"),
|
||||
GCPAD_TYPE("gc_pad_type"),
|
||||
|
@ -50,6 +50,7 @@ import org.dolphinemu.dolphinemu.utils.Log;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolder>
|
||||
implements DialogInterface.OnClickListener, SeekBar.OnSeekBarChangeListener
|
||||
@ -369,6 +370,15 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||
sView.onSettingChanged(null);
|
||||
}
|
||||
|
||||
public static void setAllLogTypes(String value)
|
||||
{
|
||||
for (Map.Entry<String, String> entry : SettingsFragmentPresenter.LOG_TYPE_NAMES.entrySet())
|
||||
{
|
||||
sView.putSetting(new StringSetting(entry.getKey(), Settings.SECTION_LOGGER_LOGS, value));
|
||||
}
|
||||
sView.onSettingChanged(null);
|
||||
}
|
||||
|
||||
private void handleMenuTag(MenuTag menuTag, int value)
|
||||
{
|
||||
if (menuTag != null)
|
||||
|
@ -48,6 +48,7 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
|
||||
titles.put(MenuTag.GCPAD_TYPE, R.string.grid_menu_gcpad_settings);
|
||||
titles.put(MenuTag.GRAPHICS, R.string.grid_menu_graphics_settings);
|
||||
titles.put(MenuTag.HACKS, R.string.hacks_submenu);
|
||||
titles.put(MenuTag.CONFIG_LOG, R.string.log_submenu);
|
||||
titles.put(MenuTag.DEBUG, R.string.debug_submenu);
|
||||
titles.put(MenuTag.ENHANCEMENTS, R.string.enhancements_submenu);
|
||||
titles.put(MenuTag.STEREOSCOPY, R.string.stereoscopy_submenu);
|
||||
|
@ -31,11 +31,16 @@ import org.dolphinemu.dolphinemu.utils.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class SettingsFragmentPresenter
|
||||
{
|
||||
private SettingsFragmentView mView;
|
||||
|
||||
public static final LinkedHashMap<String, String> LOG_TYPE_NAMES =
|
||||
NativeLibrary.GetLogTypeNames();
|
||||
|
||||
public static final String ARG_CONTROLLER_TYPE = "controller_type";
|
||||
private MenuTag mMenuTag;
|
||||
private String mGameID;
|
||||
@ -176,6 +181,10 @@ public final class SettingsFragmentPresenter
|
||||
addHackSettings(sl);
|
||||
break;
|
||||
|
||||
case CONFIG_LOG:
|
||||
addLogConfigurationSettings(sl);
|
||||
break;
|
||||
|
||||
case DEBUG:
|
||||
addDebugSettings(sl);
|
||||
break;
|
||||
@ -223,6 +232,7 @@ public final class SettingsFragmentPresenter
|
||||
sl.add(new SubmenuSetting(null, null, R.string.gamecube_submenu, MenuTag.CONFIG_GAME_CUBE));
|
||||
sl.add(new SubmenuSetting(null, null, R.string.wii_submenu, MenuTag.CONFIG_WII));
|
||||
sl.add(new SubmenuSetting(null, null, R.string.advanced_submenu, MenuTag.CONFIG_ADVANCED));
|
||||
sl.add(new SubmenuSetting(null, null, R.string.log_submenu, MenuTag.CONFIG_LOG));
|
||||
sl.add(new SubmenuSetting(null, null, R.string.debug_submenu, MenuTag.DEBUG));
|
||||
sl.add(new HeaderSetting(null, null, R.string.gametdb_thanks, 0));
|
||||
}
|
||||
@ -729,6 +739,36 @@ public final class SettingsFragmentPresenter
|
||||
fastDepth));
|
||||
}
|
||||
|
||||
private void addLogConfigurationSettings(ArrayList<SettingsItem> sl)
|
||||
{
|
||||
SettingSection logsSection = mSettings.getSection(Settings.SECTION_LOGGER_LOGS);
|
||||
SettingSection optionsSection = mSettings.getSection(Settings.SECTION_LOGGER_OPTIONS);
|
||||
Setting enableLogging = optionsSection.getSetting(SettingsFile.KEY_ENABLE_LOGGING);
|
||||
Setting logVerbosity = optionsSection.getSetting(SettingsFile.KEY_LOG_VERBOSITY);
|
||||
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_ENABLE_LOGGING, Settings.SECTION_LOGGER_OPTIONS,
|
||||
R.string.enable_logging, R.string.enable_logging_description, false, enableLogging));
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_LOG_VERBOSITY, Settings.SECTION_LOGGER_OPTIONS,
|
||||
R.string.log_verbosity, 0, getLogVerbosityEntries(), getLogVerbosityValues(), 1,
|
||||
logVerbosity));
|
||||
sl.add(new ConfirmRunnable(R.string.log_enable_all, 0, R.string.log_enable_all_confirmation, 0,
|
||||
() -> SettingsAdapter.setAllLogTypes("True")));
|
||||
sl.add(
|
||||
new ConfirmRunnable(R.string.log_disable_all, 0, R.string.log_disable_all_confirmation,
|
||||
0,
|
||||
() -> SettingsAdapter.setAllLogTypes("False")));
|
||||
|
||||
sl.add(new HeaderSetting(null, null, R.string.log_types, 0));
|
||||
for (Map.Entry<String, String> entry : LOG_TYPE_NAMES.entrySet())
|
||||
{
|
||||
Setting setting = logsSection.getSetting(entry.getKey());
|
||||
// TitleID is handled by special case in CheckBoxSettingViewHolder.
|
||||
sl.add(
|
||||
new CheckBoxSetting(entry.getKey(), Settings.SECTION_LOGGER_LOGS, 0, 0, false,
|
||||
setting));
|
||||
}
|
||||
}
|
||||
|
||||
private void addDebugSettings(ArrayList<SettingsItem> sl)
|
||||
{
|
||||
SettingSection debugSection = mSettings.getSection(Settings.SECTION_DEBUG);
|
||||
@ -1599,4 +1639,30 @@ public final class SettingsFragmentPresenter
|
||||
{
|
||||
return DirectoryInitialization.getUserDirectory() + "/Wii/sd.raw";
|
||||
}
|
||||
|
||||
private static int getLogVerbosityEntries()
|
||||
{
|
||||
// Value obtained from LOG_LEVELS in Common/Logging/Log.h
|
||||
if (NativeLibrary.GetMaxLogLevel() == 5)
|
||||
{
|
||||
return R.array.logVerbosityEntriesMaxLevelDebug;
|
||||
}
|
||||
else
|
||||
{
|
||||
return R.array.logVerbosityEntriesMaxLevelInfo;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getLogVerbosityValues()
|
||||
{
|
||||
// Value obtained from LOG_LEVELS in Common/Logging/Log.h
|
||||
if (NativeLibrary.GetMaxLogLevel() == 5)
|
||||
{
|
||||
return R.array.logVerbosityValuesMaxLevelDebug;
|
||||
}
|
||||
else
|
||||
{
|
||||
return R.array.logVerbosityValuesMaxLevelInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,11 @@ import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.view.CheckBoxSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
|
||||
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
|
||||
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsFragmentPresenter;
|
||||
|
||||
public final class CheckBoxSettingViewHolder extends SettingViewHolder
|
||||
{
|
||||
@ -36,7 +38,15 @@ public final class CheckBoxSettingViewHolder extends SettingViewHolder
|
||||
{
|
||||
mItem = (CheckBoxSetting) item;
|
||||
|
||||
mTextSettingName.setText(item.getNameId());
|
||||
// Special case for LogTypes retrieved via JNI since those aren't string references.
|
||||
if (item.getNameId() == 0 && item.getSection().equals(Settings.SECTION_LOGGER_LOGS))
|
||||
{
|
||||
mTextSettingName.setText(SettingsFragmentPresenter.LOG_TYPE_NAMES.get(item.getKey()));
|
||||
}
|
||||
else
|
||||
{
|
||||
mTextSettingName.setText(item.getNameId());
|
||||
}
|
||||
|
||||
if (item.getDescriptionId() > 0)
|
||||
{
|
||||
|
@ -36,6 +36,7 @@ public final class SettingsFile
|
||||
{
|
||||
public static final String FILE_NAME_DOLPHIN = "Dolphin";
|
||||
public static final String FILE_NAME_GFX = "GFX";
|
||||
public static final String FILE_NAME_LOGGER = "Logger";
|
||||
public static final String FILE_NAME_GCPAD = "GCPadNew";
|
||||
public static final String FILE_NAME_WIIMOTE = "WiimoteNew";
|
||||
|
||||
@ -286,6 +287,9 @@ public final class SettingsFile
|
||||
public static final String KEY_WIIMOTE_SCAN = "WiimoteContinuousScanning";
|
||||
public static final String KEY_WIIMOTE_SPEAKER = "WiimoteEnableSpeaker";
|
||||
|
||||
public static final String KEY_ENABLE_LOGGING = "WriteToFile";
|
||||
public static final String KEY_LOG_VERBOSITY = "Verbosity";
|
||||
|
||||
private static BiMap<String, String> sectionsMap = new BiMap<>();
|
||||
|
||||
static
|
||||
|
@ -71,7 +71,7 @@
|
||||
<item>5</item>
|
||||
</integer-array>
|
||||
|
||||
<!-- Slot A Device Selection -->
|
||||
<!-- Slot A & B Device selection -->
|
||||
<string-array name="slotDeviceEntries" translatable="false">
|
||||
<item>Nothing</item>
|
||||
<item>Dummy</item>
|
||||
@ -85,6 +85,34 @@
|
||||
<item>8</item>
|
||||
</integer-array>
|
||||
|
||||
<!-- Log Verbosity selection based on LOG_LEVELS in Common/Logging/Log.h -->
|
||||
<string-array name="logVerbosityEntriesMaxLevelInfo" translatable="false">
|
||||
<item>Notice</item>
|
||||
<item>Error</item>
|
||||
<item>Warning</item>
|
||||
<item>Info</item>
|
||||
</string-array>
|
||||
<integer-array name="logVerbosityValuesMaxLevelInfo" translatable="false">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
</integer-array>
|
||||
<string-array name="logVerbosityEntriesMaxLevelDebug" translatable="false">
|
||||
<item>Notice</item>
|
||||
<item>Error</item>
|
||||
<item>Warning</item>
|
||||
<item>Info</item>
|
||||
<item>Debug</item>
|
||||
</string-array>
|
||||
<integer-array name="logVerbosityValuesMaxLevelDebug" translatable="false">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
</integer-array>
|
||||
|
||||
<!-- Video backend selection -->
|
||||
<string-array name="videoBackendEntries">
|
||||
<item>OpenGL</item>
|
||||
|
@ -265,6 +265,17 @@
|
||||
<string name="overclock_title">Emulated CPU Clock Speed</string>
|
||||
<string name="overclock_title_description">Adjusts the emulated CPU\'s clock rate if \"Override Emulated CPU Clock Speed\" is enabled.</string>
|
||||
|
||||
<!-- Log Configuration -->
|
||||
<string name="log_submenu">Log</string>
|
||||
<string name="enable_logging">Enable Logging</string>
|
||||
<string name="enable_logging_description">Log messages from enabled log types to dolphin-emu/Logs/. Will decrease performance.</string>
|
||||
<string name="log_verbosity">Verbosity</string>
|
||||
<string name="log_enable_all">Enable all Log Types</string>
|
||||
<string name="log_enable_all_confirmation">Are you sure you want to enable all log types?</string>
|
||||
<string name="log_disable_all">Disable all Log Types</string>
|
||||
<string name="log_disable_all_confirmation">Are you sure you want to disable all log types?</string>
|
||||
<string name="log_types">Log Types</string>
|
||||
|
||||
<!-- Debug -->
|
||||
<string name="debug_submenu">Debug</string>
|
||||
<string name="debug_warning">Warning: These settings will slow emulation</string>
|
||||
|
Reference in New Issue
Block a user