[android] Fix charging indicator and dynamic state setting (#36)

Co-authored-by: Pavel Barabanov <pavelbarabanov94@gmail.com>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/36
This commit is contained in:
crueter 2025-07-11 10:05:01 +02:00
parent 2f421923a6
commit e5074c90ad
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
4 changed files with 20 additions and 7 deletions

View file

@ -5,6 +5,7 @@ package org.yuzu.yuzu_emu.features.settings.model.view
import androidx.annotation.ArrayRes import androidx.annotation.ArrayRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
import org.yuzu.yuzu_emu.features.settings.model.AbstractByteSetting
import org.yuzu.yuzu_emu.features.settings.model.AbstractIntSetting import org.yuzu.yuzu_emu.features.settings.model.AbstractIntSetting
import org.yuzu.yuzu_emu.features.settings.model.AbstractSetting import org.yuzu.yuzu_emu.features.settings.model.AbstractSetting
@ -24,8 +25,14 @@ class SingleChoiceSetting(
fun getSelectedValue(needsGlobal: Boolean = false) = fun getSelectedValue(needsGlobal: Boolean = false) =
when (setting) { when (setting) {
is AbstractIntSetting -> setting.getInt(needsGlobal) is AbstractIntSetting -> setting.getInt(needsGlobal)
is AbstractByteSetting -> setting.getByte(needsGlobal).toInt()
else -> -1 else -> -1
} }
fun setSelectedValue(value: Int) = (setting as AbstractIntSetting).setInt(value) fun setSelectedValue(value: Int) =
when (setting) {
is AbstractIntSetting -> setting.setInt(value)
is AbstractByteSetting -> setting.setByte(value.toByte())
else -> -1
}
} }

View file

@ -643,13 +643,19 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
val battery: BatteryManager = val battery: BatteryManager =
requireContext().getSystemService(Context.BATTERY_SERVICE) as BatteryManager requireContext().getSystemService(Context.BATTERY_SERVICE) as BatteryManager
val batteryIntent = requireContext().registerReceiver(null,
IntentFilter(Intent.ACTION_BATTERY_CHANGED))
val capacity = battery.getIntProperty(BATTERY_PROPERTY_CAPACITY) val capacity = battery.getIntProperty(BATTERY_PROPERTY_CAPACITY)
val nowUAmps = battery.getIntProperty(BATTERY_PROPERTY_CURRENT_NOW) val nowUAmps = battery.getIntProperty(BATTERY_PROPERTY_CURRENT_NOW)
sb.append(String.format("%.1fA (%d%%)", nowUAmps / 1000000.0, capacity)) sb.append(String.format("%.1fA (%d%%)", nowUAmps / 1000000.0, capacity))
if (battery.isCharging || nowUAmps > 0.0) { val status = batteryIntent?.getIntExtra(BatteryManager.EXTRA_STATUS, -1)
val isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
status == BatteryManager.BATTERY_STATUS_FULL
if (isCharging) {
sb.append(" ${getString(R.string.charging)}") sb.append(" ${getString(R.string.charging)}")
} }
} }

View file

@ -74,7 +74,7 @@
<string name="veil_extensions">GPU Extensions</string> <string name="veil_extensions">GPU Extensions</string>
<string name="dyna_state">Extended Dynamic State</string> <string name="dyna_state">Extended Dynamic State</string>
<string name="dyna_state_description">Enables Vulkan features to improve performance, rendering, and save resources on pipeline creation while maintaining lower CPU/GPU usage. These extensions may increase device temperature, and GPUs belonging to the older A6XX line may not react properly. Set to 0 to use Legacy emulated formats.</string> <string name="dyna_state_description">Enables Vulkan features to improve performance, rendering, and save resources on pipeline creation while maintaining lower CPU/GPU usage. These extensions may increase device temperature, and GPUs belonging to the older A6XX line may not react properly. Disable to emulate scaled formats.</string>
<string name="disabled">Disabled</string> <string name="disabled">Disabled</string>
<string name="provoking_vertex">Provoking Vertex</string> <string name="provoking_vertex">Provoking Vertex</string>
<string name="provoking_vertex_description">Improves lighting and vertex handling in certain games. Only supported on Vulkan 1.0+ GPUs.</string> <string name="provoking_vertex_description">Improves lighting and vertex handling in certain games. Only supported on Vulkan 1.0+ GPUs.</string>
@ -95,11 +95,11 @@
<string name="firmware_uninstalling">Uninstalling firmware</string> <string name="firmware_uninstalling">Uninstalling firmware</string>
<string name="firmware_uninstalled_success">Firmware uninstalled successfully</string> <string name="firmware_uninstalled_success">Firmware uninstalled successfully</string>
<string name="veil_misc">Miscellaneous</string> <string name="veil_misc">CPU and Memory</string>
<string name="use_sync_core">Synchronize Core Speed</string> <string name="use_sync_core">Synchronize Core Speed</string>
<string name="use_sync_core_description">Synchronize the core tick speed to the maximum speed percentage to improve performance without altering the game\'s actual speed.</string> <string name="use_sync_core_description">Synchronize the core tick speed to the maximum speed percentage to improve performance without altering the game\'s actual speed.</string>
<string name="use_lru_cache">Enable LRU Cache</string> <string name="use_lru_cache">Enable LRU Cache</string>
<string name="use_lru_cache_description">Enable or disable the Least Recently Used (LRU) cache, increasing performance by saving CPU process usage. Some games have issue with it, notably TotK 1.2.1, so disable if the game doesn\'t boot or crashes randomly.</string> <string name="use_lru_cache_description">Enable or disable the Least Recently Used (LRU) cache, increasing performance by saving CPU process usage. Some games have issues with it, notably TotK 1.2.1, so disable if the game doesn\'t boot or crashes randomly.</string>
<string name="use_fast_cpu_time">Fast CPU Time</string> <string name="use_fast_cpu_time">Fast CPU Time</string>
<string name="use_fast_cpu_time_description">Forces the emulated CPU to run at a higher clock, reducing certain FPS limiters. This option is hacky and may cause issues, and weaker CPUs may see reduced performance.</string> <string name="use_fast_cpu_time_description">Forces the emulated CPU to run at a higher clock, reducing certain FPS limiters. This option is hacky and may cause issues, and weaker CPUs may see reduced performance.</string>
<string name="custom_cpu_ticks">Custom CPU Ticks</string> <string name="custom_cpu_ticks">Custom CPU Ticks</string>

View file

@ -331,7 +331,7 @@ struct Values {
SwitchableSetting<bool> use_disk_shader_cache{linkage, true, "use_disk_shader_cache", SwitchableSetting<bool> use_disk_shader_cache{linkage, true, "use_disk_shader_cache",
Category::Renderer}; Category::Renderer};
SwitchableSetting<SpirvOptimizeMode, true> optimize_spirv_output{linkage, SwitchableSetting<SpirvOptimizeMode, true> optimize_spirv_output{linkage,
SpirvOptimizeMode::OnLoad, SpirvOptimizeMode::Never,
SpirvOptimizeMode::Never, SpirvOptimizeMode::Never,
SpirvOptimizeMode::Always, SpirvOptimizeMode::Always,
"optimize_spirv_output", "optimize_spirv_output",
@ -477,7 +477,7 @@ struct Values {
SwitchableSetting<bool> use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", SwitchableSetting<bool> use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders",
Category::RendererAdvanced}; Category::RendererAdvanced};
SwitchableSetting<bool> use_fast_gpu_time{linkage, SwitchableSetting<bool> use_fast_gpu_time{linkage,
false, true,
"use_fast_gpu_time", "use_fast_gpu_time",
Category::RendererAdvanced, Category::RendererAdvanced,
Specialization::Paired, Specialization::Paired,