From f2394b8c9118efb50698833526c8362982d91ce0 Mon Sep 17 00:00:00 2001 From: weihuoya Date: Sun, 24 Mar 2019 17:14:31 +0800 Subject: [PATCH 1/3] android: simple config load code --- Source/Android/jni/ButtonManager.cpp | 37 ++-------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/Source/Android/jni/ButtonManager.cpp b/Source/Android/jni/ButtonManager.cpp index c6bcb262ab..bae07f8948 100644 --- a/Source/Android/jni/ButtonManager.cpp +++ b/Source/Android/jni/ButtonManager.cpp @@ -559,41 +559,8 @@ void Init(const std::string& gameId) } // Init our controller bindings IniFile ini; - ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string("Dolphin.ini")); - for (u32 a = 0; a < configStrings.size(); ++a) - { - for (int padID = 0; padID < 8; ++padID) - { - std::ostringstream config; - config << configStrings[a] << "_" << padID; - BindType type; - int bindnum; - char dev[128]; - bool hasbind = false; - char modifier = '+'; - std::string value; - ini.GetOrCreateSection("Android")->Get(config.str(), &value, "None"); - if (value == "None") - continue; - if (std::string::npos != value.find("Axis")) - { - hasbind = true; - type = BIND_AXIS; - sscanf(value.c_str(), "Device '%127[^\']'-Axis %d%c", dev, &bindnum, &modifier); - } - else if (std::string::npos != value.find("Button")) - { - hasbind = true; - type = BIND_BUTTON; - sscanf(value.c_str(), "Device '%127[^\']'-Button %d", dev, &bindnum); - } - if (hasbind) - AddBind(std::string(dev), - new sBind(padID, configTypes[a], type, bindnum, modifier == '-' ? -1.0f : 1.0f)); - } - } - - ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + std::string(gameId + ".ini")); + ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string("Dolphin.ini"), true); + ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + std::string(gameId + ".ini"), true); for (u32 a = 0; a < configStrings.size(); ++a) { for (int padID = 0; padID < 8; ++padID) From 04ebee686c46d24c0745072879cb3824e434d8cd Mon Sep 17 00:00:00 2001 From: weihuoya Date: Tue, 9 Apr 2019 21:46:04 +0800 Subject: [PATCH 2/3] simplify config save --- .../activities/EmulationActivity.java | 8 +++-- .../features/settings/utils/SettingsFile.java | 33 +++---------------- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java index 3ba7e5f893..2ee9cbb9f5 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java @@ -944,13 +944,15 @@ public final class EmulationActivity extends AppCompatActivity builder.setView(view); builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> { - SettingsFile.saveSingleCustomSetting(mSelectedGameId, Settings.SECTION_CONTROLS, + NativeLibrary.LoadGameIniFile(mSelectedGameId); + NativeLibrary.SetUserSetting(mSelectedGameId, Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_PITCH, text_slider_value_pitch.getText().toString()); - SettingsFile.saveSingleCustomSetting(mSelectedGameId, Settings.SECTION_CONTROLS, + NativeLibrary.SetUserSetting(mSelectedGameId, Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_YAW, text_slider_value_yaw.getText().toString()); - SettingsFile.saveSingleCustomSetting(mSelectedGameId, Settings.SECTION_CONTROLS, + NativeLibrary.SetUserSetting(mSelectedGameId, Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET, text_slider_value_vertical_offset.getText().toString()); + NativeLibrary.SaveGameIniFile(mSelectedGameId); NativeLibrary.ReloadWiimoteConfig(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java index ff24a7a6d3..7ba9bcfd38 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java @@ -452,11 +452,10 @@ public final class SettingsFile final HashMap sections) { Set sortedSections = new TreeSet<>(sections.keySet()); - + NativeLibrary.LoadGameIniFile(gameId); for (String sectionKey : sortedSections) { SettingSection section = sections.get(sectionKey); - HashMap settings = section.getSettings(); Set sortedKeySet = new TreeSet<>(settings.keySet()); @@ -465,10 +464,7 @@ public final class SettingsFile { continue; } - else - { - NativeLibrary.LoadGameIniFile(gameId); - } + for (String settingKey : sortedKeySet) { Setting setting = settings.get(settingKey); @@ -478,7 +474,6 @@ public final class SettingsFile String padId = setting.getKey() .substring(setting.getKey().length() - 1, setting.getKey().length()); - saveCustomWiimoteSetting(gameId, KEY_WIIMOTE_EXTENSION, setting.getValueAsString(), padId); } @@ -488,17 +483,7 @@ public final class SettingsFile setting.getKey(), setting.getValueAsString()); } } - NativeLibrary.SaveGameIniFile(gameId); } - } - - public static void saveSingleCustomSetting(final String gameId, final String section, - final String key, - final String value) - { - NativeLibrary.LoadGameIniFile(gameId); - NativeLibrary.SetUserSetting(gameId, section, - key, value); NativeLibrary.SaveGameIniFile(gameId); } @@ -510,12 +495,11 @@ public final class SettingsFile * @param value * @param padId */ - public static void saveCustomWiimoteSetting(final String gameId, final String key, + private static void saveCustomWiimoteSetting(final String gameId, final String key, final String value, final String padId) { String profile = gameId + "_Wii" + padId; - String wiiConfigPath = DirectoryInitialization.getUserDirectory() + "/Config/Profiles/Wiimote/" + profile + ".ini"; @@ -532,14 +516,11 @@ public final class SettingsFile "Android/" + (Integer.valueOf(padId) + 4) + "/Touchscreen"); } - NativeLibrary.SetProfileSetting(profile, Settings.SECTION_PROFILE, key, - value); + NativeLibrary.SetProfileSetting(profile, Settings.SECTION_PROFILE, key, value); // Enable the profile - NativeLibrary.LoadGameIniFile(gameId); NativeLibrary.SetUserSetting(gameId, Settings.SECTION_CONTROLS, KEY_WIIMOTE_PROFILE + (Integer.valueOf(padId) + 1), profile); - NativeLibrary.SaveGameIniFile(gameId); } private static String mapSectionNameFromIni(String generalSectionName) @@ -733,10 +714,4 @@ public final class SettingsFile { return "[" + section.getName() + "]"; } - - private static String customWiimoteExtSettingAsString(Setting setting) - { - return setting.getKey().substring(0, setting.getKey().length() - 1) + " = " + - setting.getValueAsString(); - } } From 47e776d3789f7127fd2e80bc4988653a3ef001c2 Mon Sep 17 00:00:00 2001 From: weihuoya Date: Wed, 17 Apr 2019 20:15:56 +0800 Subject: [PATCH 3/3] rm unused code --- .../activities/EmulationActivity.java | 2 +- .../dolphinemu/ui/main/MainActivity.java | 17 ----------------- .../dolphinemu/ui/main/MainPresenter.java | 6 ------ .../dolphinemu/dolphinemu/ui/main/MainView.java | 9 --------- .../dolphinemu/ui/main/TvMainActivity.java | 10 ---------- 5 files changed, 1 insertion(+), 43 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java index 2ee9cbb9f5..81b090373e 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java @@ -195,7 +195,7 @@ public final class EmulationActivity extends AppCompatActivity launcher.putExtra(EXTRA_SELECTED_TITLE, gameFile.getTitle()); launcher.putExtra(EXTRA_SELECTED_GAMEID, gameFile.getGameId()); launcher.putExtra(EXTRA_PLATFORM, gameFile.getPlatform()); - activity.startActivityForResult(launcher, MainPresenter.REQUEST_EMULATE_GAME); + activity.startActivity(launcher); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java index f5eee1bc68..4aed5bf166 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java @@ -131,19 +131,6 @@ public final class MainActivity extends AppCompatActivity implements MainView mToolbar.setSubtitle(version); } - @Override - public void refreshFragmentScreenshot(int fragmentPosition) - { - // Invalidate Picasso image so that the new screenshot is animated in. - Platform platform = Platform.fromPosition(mViewPager.getCurrentItem()); - PlatformGamesView fragment = getPlatformGamesView(platform); - - if (fragment != null) - { - fragment.refreshScreenshotAtPosition(fragmentPosition); - } - } - @Override public void launchSettingsActivity(MenuTag menuTag) { @@ -173,10 +160,6 @@ public final class MainActivity extends AppCompatActivity implements MainView mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedDirectory(result)); } break; - - case MainPresenter.REQUEST_EMULATE_GAME: - mPresenter.refreshFragmentScreenshot(resultCode); - break; } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java index b68c8e1466..29afda89fe 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java @@ -15,7 +15,6 @@ import org.dolphinemu.dolphinemu.services.GameFileCacheService; public final class MainPresenter { public static final int REQUEST_ADD_DIRECTORY = 1; - public static final int REQUEST_EMULATE_GAME = 2; private final MainView mView; private final Context mContext; @@ -105,9 +104,4 @@ public final class MainPresenter { mDirToAdd = dir; } - - public void refreshFragmentScreenshot(int resultCode) - { - mView.refreshFragmentScreenshot(resultCode); - } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainView.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainView.java index a24784f3a1..d9ef95cdf1 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainView.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainView.java @@ -17,15 +17,6 @@ public interface MainView */ void setVersionString(String version); - /** - * Tell the view to tell the currently displayed {@link android.support.v4.app.Fragment} - * to refresh the screenshot at the given position in its list of games. - * - * @param fragmentPosition An index corresponding to the list or grid of games. - */ - void refreshFragmentScreenshot(int fragmentPosition); - - void launchSettingsActivity(MenuTag menuTag); void launchFileListActivity(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java index 1fc4db171f..0457de51e6 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java @@ -131,12 +131,6 @@ public final class TvMainActivity extends FragmentActivity implements MainView mBrowseFragment.setTitle(version); } - @Override - public void refreshFragmentScreenshot(int fragmentPosition) - { - mRowsAdapter.notifyArrayItemRangeChanged(0, mRowsAdapter.size()); - } - @Override public void launchSettingsActivity(MenuTag menuTag) { @@ -177,10 +171,6 @@ public final class TvMainActivity extends FragmentActivity implements MainView mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedDirectory(result)); } break; - - case MainPresenter.REQUEST_EMULATE_GAME: - mPresenter.refreshFragmentScreenshot(resultCode); - break; } }