This commit is contained in:
PlayXboxtion963 2025-12-15 20:20:33 +08:00 committed by GitHub
commit 5a46a976ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 91 additions and 16 deletions

View File

@ -931,6 +931,13 @@ enum class BooleanSetting(
Settings.SECTION_ACHIEVEMENTS,
"ProgressEnabled",
true
),
SERVERS_ENABLED(
Settings.FILE_DUALSHOCKUDPCLIENT,
Settings.SECTION_INI_SERVER,
key = "Enabled",
false
);
override val isOverridden: Boolean

View File

@ -106,6 +106,7 @@ class Settings : Closeable {
const val FILE_WIIMOTE = "WiimoteNew"
const val FILE_ACHIEVEMENTS = "RetroAchievements"
const val FILE_GAME_SETTINGS_ONLY = "GameSettingsOnly"
const val FILE_DUALSHOCKUDPCLIENT = "DualShockUDPClient"
const val SECTION_INI_ANDROID = "Android"
const val SECTION_INI_ANDROID_OVERLAY_BUTTONS = "AndroidOverlayButtons"
const val SECTION_INI_GENERAL = "General"
@ -124,5 +125,6 @@ class Settings : Closeable {
const val SECTION_STEREOSCOPY = "Stereoscopy"
const val SECTION_ANALYTICS = "Analytics"
const val SECTION_ACHIEVEMENTS = "Achievements"
const val SECTION_INI_SERVER = "Server"
}
}

View File

@ -92,6 +92,13 @@ enum class StringSetting(
Settings.SECTION_ACHIEVEMENTS,
"ApiToken",
""
),
SERVERS(
Settings.FILE_DUALSHOCKUDPCLIENT,
Settings.SECTION_INI_SERVER,
"Entries",
""
);
override val isOverridden: Boolean

View File

@ -502,16 +502,16 @@ class SettingsFragmentPresenter(
override val isOverridden: Boolean
get() = BooleanSetting.MAIN_DSP_HLE.isOverridden ||
BooleanSetting.MAIN_DSP_JIT.isOverridden
BooleanSetting.MAIN_DSP_JIT.isOverridden
override val isRuntimeEditable: Boolean
get() = BooleanSetting.MAIN_DSP_HLE.isRuntimeEditable &&
BooleanSetting.MAIN_DSP_JIT.isRuntimeEditable
BooleanSetting.MAIN_DSP_JIT.isRuntimeEditable
override fun delete(settings: Settings): Boolean {
// Not short circuiting
return BooleanSetting.MAIN_DSP_HLE.delete(settings) and
BooleanSetting.MAIN_DSP_JIT.delete(settings)
BooleanSetting.MAIN_DSP_JIT.delete(settings)
}
}
@ -962,8 +962,8 @@ class SettingsFragmentPresenter(
0,
false
) {
fragmentView.showDialogFragment(LoginDialog(this))
loadSettingsList()
fragmentView.showDialogFragment(LoginDialog(this))
loadSettingsList()
})
} else {
sl.add(
@ -975,8 +975,8 @@ class SettingsFragmentPresenter(
0,
false
) {
logout()
loadSettingsList()
logout()
loadSettingsList()
})
}
sl.add(
@ -1073,16 +1073,16 @@ class SettingsFragmentPresenter(
override val isOverridden: Boolean
get() = BooleanSetting.MAIN_SYNC_ON_SKIP_IDLE.isOverridden ||
BooleanSetting.MAIN_SYNC_GPU.isOverridden
BooleanSetting.MAIN_SYNC_GPU.isOverridden
override val isRuntimeEditable: Boolean
get() = BooleanSetting.MAIN_SYNC_ON_SKIP_IDLE.isRuntimeEditable &&
BooleanSetting.MAIN_SYNC_GPU.isRuntimeEditable
BooleanSetting.MAIN_SYNC_GPU.isRuntimeEditable
override fun delete(settings: Settings): Boolean {
// Not short circuiting
return BooleanSetting.MAIN_SYNC_ON_SKIP_IDLE.delete(settings) and
BooleanSetting.MAIN_SYNC_GPU.delete(settings)
BooleanSetting.MAIN_SYNC_GPU.delete(settings)
}
}
@ -1422,6 +1422,21 @@ class SettingsFragmentPresenter(
IntSetting.WIIMOTE_BB_SOURCE.setInt(settings, if (newValue) 2 else 0)
}
}, R.string.real_balance_board, 0))
sl.add(SwitchSetting(context,
BooleanSetting.SERVERS_ENABLED,
R.string.dualshockudp_client,
R.string.dualshockudp_client_description)
)
sl.add(
InputStringSetting(
context,
StringSetting.SERVERS,
R.string.dualshockudp_entries,
R.string.dualshockudp_entries_description
)
)
}
private fun addGraphicsSettings(sl: ArrayList<SettingsItem>) {
@ -2189,7 +2204,7 @@ class SettingsFragmentPresenter(
BooleanSetting.MAIN_DEBUG_JIT_ENABLE_PROFILING,
R.string.debug_jit_enable_block_profiling,
0
)
)
)
sl.add(
RunRunnable(
@ -2355,6 +2370,7 @@ class SettingsFragmentPresenter(
addControllerMappingSettings(sl, gcPad, null)
}
}
7 -> {
// Emulated keyboard controller
val gcKeyboard = EmulatedController.getGcKeyboard(gcPadNumber)
@ -2367,6 +2383,7 @@ class SettingsFragmentPresenter(
addControllerMappingSettings(sl, gcKeyboard, null)
}
}
12 -> {
// Adapter
sl.add(
@ -2585,11 +2602,11 @@ class SettingsFragmentPresenter(
* @param groupTypeFilter If this is non-null, only groups whose types match this are considered.
*/
private fun addControllerMappingSettings(
sl: ArrayList<SettingsItem>,
controller: EmulatedController,
groupTypeFilter: Set<Int>?
sl: ArrayList<SettingsItem>,
controller: EmulatedController,
groupTypeFilter: Set<Int>?
) {
addContainerMappingSettings(sl, controller, controller, groupTypeFilter)
addContainerMappingSettings(sl, controller, controller, groupTypeFilter)
}
/**
@ -2684,7 +2701,7 @@ class SettingsFragmentPresenter(
val defaultDevice = controller.getDefaultDevice()
hasOldControllerSettings = defaultDevice.startsWith("Android/") &&
defaultDevice.endsWith("/Touchscreen")
defaultDevice.endsWith("/Touchscreen")
fragmentView.setOldControllerSettingsWarningVisibility(hasOldControllerSettings)
}

View File

@ -24,6 +24,10 @@
<string name="wiimote_extension_3">Wii Remote Extension 4</string>
<string name="real_balance_board">Real Balance Board</string>
<string name="dualshockudp_client">DSU Input</string>
<string name="dualshockudp_entries">DualshockUDP Server Info (Alternate Input Source)</string>
<string name="dualshockudp_entries_description">Description:IP:Port;</string>
<string name="wiimote">Wii Remote</string>
<string name="wiimote_general">Buttons</string>
@ -120,6 +124,7 @@
<string name="wiimote_scanning_description">Leave this on if you are using a DolphinBar for real Wii Remote support.</string>
<string name="wiimote_speaker">Wii Remote Speaker</string>
<string name="wiimote_speaker_description">Enable sound output through the speaker on a real Wii Remote (DolphinBar required).</string>
<string name="dualshockudp_client_description">DSU protocol enables the use of input and motion data from compatible sources, like PlayStation, Nintendo Switch and Steam controllers.</string>
<string name="override_region_settings">Allow Mismatched Region Settings</string>
<string name="auto_disc_change">Change Discs Automatically</string>
<string name="fallback_region">Fallback Region</string>

View File

@ -6,6 +6,9 @@
#include "Common/Logging/Log.h"
#include "Core/AchievementManager.h"
// Minimal bridge to notify native code to pause/resume background input updates.
extern "C" void SetBackgroundInputExecutionAllowed(bool allowed);
extern "C" {
JNIEXPORT void JNICALL
@ -17,5 +20,6 @@ Java_org_dolphinemu_dolphinemu_utils_ActivityTracker_setBackgroundExecutionAllow
INFO_LOG_FMT(CORE, "SetBackgroundExecutionAllowed {}", allowed);
AchievementManager::GetInstance().SetBackgroundExecutionAllowed(allowed);
SetBackgroundInputExecutionAllowed(static_cast<bool>(allowed));
}
}

View File

@ -52,6 +52,10 @@ static Config::Location GetLocation(JNIEnv* env, jstring file, jstring section,
{
system = Config::System::Achievements;
}
else if (decoded_file == "DualShockUDPClient")
{
system = Config::System::DualShockUDPClient;
}
else
{
ASSERT(false);

View File

@ -9,6 +9,7 @@
#include <optional>
#include <string>
#include <thread>
#include <atomic>
#include <utility>
#include <vector>
@ -57,6 +58,7 @@
#include "DiscIO/Volume.h"
#include "InputCommon/GCAdapter.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "UICommon/GameFile.h"
#include "UICommon/UICommon.h"
@ -86,6 +88,8 @@ bool s_need_nonblocking_alert_msg;
Common::Flag s_is_booting;
bool s_game_metadata_is_valid = false;
// When false, the controller-update thread will pause updates to save battery.
std::atomic<bool> s_background_execution_allowed{true};
} // Anonymous namespace
void UpdatePointer()
@ -562,6 +566,24 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Initialize(J
UICommon::InitControllers(WindowSystemInfo(WindowSystemType::Android, nullptr, nullptr, nullptr));
AchievementManager::GetInstance().Init(nullptr);
// Start a background thread to periodically update controller input (every 10ms).
// The thread checks `s_background_execution_allowed` and pauses updates when
// background execution is disallowed (to save battery).
std::thread([]() {
while (true)
{
if (!s_background_execution_allowed.load())
{
std::this_thread::sleep_for(std::chrono::milliseconds(100));
continue;
}
g_controller_interface.SetCurrentInputChannel(ciface::InputChannel::Host);
g_controller_interface.UpdateInput();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}).detach();
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReportStartToAnalytics(JNIEnv*,
@ -576,6 +598,13 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GenerateNewS
DolphinAnalytics::Instance().GenerateNewIdentity();
}
// Called from Java-side ActivityTracker native shim to allow/disable background
// controller updates. Kept minimal: just flip the flag the thread checks.
extern "C" void SetBackgroundInputExecutionAllowed(bool allowed)
{
s_background_execution_allowed.store(allowed);
}
// Returns the scale factor for imgui rendering.
// Based on the scaledDensity of the device's display metrics.
static float GetRenderSurfaceScale(JNIEnv* env)