mirror of
https://codeberg.org/yuzu-emu/yuzu.git
synced 2025-12-16 12:09:04 +00:00
feat: Improve thermal display and build system
- Replace emoji thermal indicators with modern progress bar UI - Switch temperature source to battery sensor for better accuracy - Adjust temperature thresholds (30°C-45°C range) - Add automatic Vulkan Validation Layer download for Android The thermal display now shows a visual progress bar with percentage instead of emojis, making it easier to gauge system temperature at a glance. Temperature reading now comes from the battery sensor which is more reliable across devices. Build system improvements include automated VVL binary downloads and installation for Android builds when CITRON_DOWNLOAD_ANDROID_VVL is enabled.
This commit is contained in:
parent
58eaee33b5
commit
9ce7c82b18
@ -117,10 +117,13 @@ if (ANDROID AND YUZU_DOWNLOAD_ANDROID_VVL)
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals")
|
||||
endif()
|
||||
|
||||
# Copy the arm64 binary to src/android/app/main/jniLibs
|
||||
# Copy the arm64 binary to src/android/app/main/jniLibs only if it doesn't exist
|
||||
set(vvl_lib_path "${CMAKE_CURRENT_SOURCE_DIR}/src/android/app/src/main/jniLibs/arm64-v8a/")
|
||||
file(COPY "${CMAKE_BINARY_DIR}/externals/android-binaries-${vvl_version}/arm64-v8a/libVkLayer_khronos_validation.so"
|
||||
DESTINATION "${vvl_lib_path}")
|
||||
set(vvl_lib_file "${vvl_lib_path}/libVkLayer_khronos_validation.so")
|
||||
if (NOT EXISTS "${vvl_lib_file}")
|
||||
file(COPY "${CMAKE_BINARY_DIR}/externals/android-binaries-${vvl_version}/arm64-v8a/libVkLayer_khronos_validation.so"
|
||||
DESTINATION "${vvl_lib_path}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (ANDROID)
|
||||
|
||||
@ -522,17 +522,57 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||
!emulationViewModel.isEmulationStopping.value
|
||||
) {
|
||||
val thermalStatus = when (powerManager.currentThermalStatus) {
|
||||
PowerManager.THERMAL_STATUS_LIGHT -> "😥"
|
||||
PowerManager.THERMAL_STATUS_MODERATE -> "🥵"
|
||||
PowerManager.THERMAL_STATUS_SEVERE -> "🔥"
|
||||
PowerManager.THERMAL_STATUS_LIGHT -> 0.25f
|
||||
PowerManager.THERMAL_STATUS_MODERATE -> 0.5f
|
||||
PowerManager.THERMAL_STATUS_SEVERE -> 0.75f
|
||||
PowerManager.THERMAL_STATUS_CRITICAL,
|
||||
PowerManager.THERMAL_STATUS_EMERGENCY,
|
||||
PowerManager.THERMAL_STATUS_SHUTDOWN -> "☢️"
|
||||
|
||||
else -> "🙂"
|
||||
PowerManager.THERMAL_STATUS_SHUTDOWN -> 1.0f
|
||||
else -> 0f
|
||||
}
|
||||
|
||||
// Get temperature from battery thermal sensor
|
||||
val temperature = try {
|
||||
val process = Runtime.getRuntime().exec("cat /sys/class/power_supply/battery/temp")
|
||||
val reader = process.inputStream.bufferedReader()
|
||||
val temp = reader.readLine().toFloat() / 10f // Convert from decidegrees to degrees
|
||||
reader.close()
|
||||
temp
|
||||
} catch (e: Exception) {
|
||||
0f
|
||||
}
|
||||
|
||||
// Convert to Fahrenheit
|
||||
val fahrenheit = (temperature * 9f / 5f) + 32f
|
||||
|
||||
if (_binding != null) {
|
||||
binding.showThermalsText.text = thermalStatus
|
||||
// Color interpolation based on temperature (green at 30°C, red at 45°C)
|
||||
val normalizedTemp = ((temperature - 30f) / 15f).coerceIn(0f, 1f)
|
||||
val red = (normalizedTemp * 255).toInt()
|
||||
val green = ((1f - normalizedTemp) * 255).toInt()
|
||||
val color = android.graphics.Color.rgb(red, green, 0)
|
||||
|
||||
// Create a modern progress bar using block elements
|
||||
val progressBarLength = 12
|
||||
val filledBars = (thermalStatus * progressBarLength).toInt()
|
||||
val progressBar = buildString {
|
||||
append("│") // Left border
|
||||
repeat(filledBars) { append("█") }
|
||||
repeat(progressBarLength - filledBars) { append("░") }
|
||||
append("│") // Right border
|
||||
|
||||
// Add percentage
|
||||
append(" ")
|
||||
append(String.format("%3d%%", (thermalStatus * 100).toInt()))
|
||||
}
|
||||
|
||||
binding.showThermalsText.setTextColor(color)
|
||||
binding.showThermalsText.text = String.format(
|
||||
"%s\n%.1f°C • %.1f°F",
|
||||
progressBar,
|
||||
temperature,
|
||||
fahrenheit
|
||||
)
|
||||
}
|
||||
thermalStatsUpdateHandler.postDelayed(thermalStatsUpdater!!, 1000)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user