early-access version 4083

This commit is contained in:
pineappleEA 2024-01-22 19:05:04 +01:00
parent 757b2a0c83
commit 9b38babf6f
10 changed files with 172 additions and 81 deletions

View file

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 4082. This is the source code for early-access 4083.
## Legal Notice ## Legal Notice

View file

@ -3,9 +3,6 @@
package org.yuzu.yuzu_emu.adapters package org.yuzu.yuzu_emu.adapters
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.LayerDrawable
import android.net.Uri import android.net.Uri
import android.text.TextUtils import android.text.TextUtils
import android.view.LayoutInflater import android.view.LayoutInflater
@ -15,10 +12,6 @@ import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.pm.ShortcutInfoCompat import androidx.core.content.pm.ShortcutInfoCompat
import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.drawable.IconCompat
import androidx.core.graphics.drawable.toBitmap
import androidx.core.graphics.drawable.toDrawable
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -30,7 +23,6 @@ import kotlinx.coroutines.withContext
import org.yuzu.yuzu_emu.HomeNavigationDirections import org.yuzu.yuzu_emu.HomeNavigationDirections
import org.yuzu.yuzu_emu.R import org.yuzu.yuzu_emu.R
import org.yuzu.yuzu_emu.YuzuApplication import org.yuzu.yuzu_emu.YuzuApplication
import org.yuzu.yuzu_emu.activities.EmulationActivity
import org.yuzu.yuzu_emu.databinding.CardGameBinding import org.yuzu.yuzu_emu.databinding.CardGameBinding
import org.yuzu.yuzu_emu.model.Game import org.yuzu.yuzu_emu.model.Game
import org.yuzu.yuzu_emu.model.GamesViewModel import org.yuzu.yuzu_emu.model.GamesViewModel
@ -89,36 +81,13 @@ class GameAdapter(private val activity: AppCompatActivity) :
) )
.apply() .apply()
val openIntent =
Intent(YuzuApplication.appContext, EmulationActivity::class.java).apply {
action = Intent.ACTION_VIEW
data = Uri.parse(game.path)
}
activity.lifecycleScope.launch { activity.lifecycleScope.launch {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
val layerDrawable = ResourcesCompat.getDrawable(
YuzuApplication.appContext.resources,
R.drawable.shortcut,
null
) as LayerDrawable
layerDrawable.setDrawableByLayerId(
R.id.shortcut_foreground,
GameIconUtils.getGameIcon(activity, game)
.toDrawable(YuzuApplication.appContext.resources)
)
val inset = YuzuApplication.appContext.resources
.getDimensionPixelSize(R.dimen.icon_inset)
layerDrawable.setLayerInset(1, inset, inset, inset, inset)
val shortcut = val shortcut =
ShortcutInfoCompat.Builder(YuzuApplication.appContext, game.path) ShortcutInfoCompat.Builder(YuzuApplication.appContext, game.path)
.setShortLabel(game.title) .setShortLabel(game.title)
.setIcon( .setIcon(GameIconUtils.getShortcutIcon(activity, game))
IconCompat.createWithAdaptiveBitmap( .setIntent(game.launchIntent)
layerDrawable.toBitmap(config = Bitmap.Config.ARGB_8888)
)
)
.setIntent(openIntent)
.build() .build()
ShortcutManagerCompat.pushDynamicShortcut(YuzuApplication.appContext, shortcut) ShortcutManagerCompat.pushDynamicShortcut(YuzuApplication.appContext, shortcut)
} }

View file

@ -4,6 +4,8 @@
package org.yuzu.yuzu_emu.fragments package org.yuzu.yuzu_emu.fragments
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.pm.ShortcutInfo
import android.content.pm.ShortcutManager
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils import android.text.TextUtils
import android.view.LayoutInflater import android.view.LayoutInflater
@ -84,6 +86,24 @@ class GamePropertiesFragment : Fragment() {
view.findNavController().popBackStack() view.findNavController().popBackStack()
} }
val shortcutManager = requireActivity().getSystemService(ShortcutManager::class.java)
binding.buttonShortcut.isEnabled = shortcutManager.isRequestPinShortcutSupported
binding.buttonShortcut.setOnClickListener {
viewLifecycleOwner.lifecycleScope.launch {
withContext(Dispatchers.IO) {
val shortcut = ShortcutInfo.Builder(requireContext(), args.game.title)
.setShortLabel(args.game.title)
.setIcon(
GameIconUtils.getShortcutIcon(requireActivity(), args.game)
.toIcon(requireContext())
)
.setIntent(args.game.launchIntent)
.build()
shortcutManager.requestPinShortcut(shortcut, null)
}
}
}
GameIconUtils.loadGameIcon(args.game, binding.imageGameScreen) GameIconUtils.loadGameIcon(args.game, binding.imageGameScreen)
binding.title.text = args.game.title binding.title.text = args.game.title
binding.title.postDelayed( binding.title.postDelayed(

View file

@ -3,6 +3,7 @@
package org.yuzu.yuzu_emu.model package org.yuzu.yuzu_emu.model
import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Parcelable import android.os.Parcelable
import java.util.HashSet import java.util.HashSet
@ -11,6 +12,7 @@ import kotlinx.serialization.Serializable
import org.yuzu.yuzu_emu.NativeLibrary import org.yuzu.yuzu_emu.NativeLibrary
import org.yuzu.yuzu_emu.R import org.yuzu.yuzu_emu.R
import org.yuzu.yuzu_emu.YuzuApplication import org.yuzu.yuzu_emu.YuzuApplication
import org.yuzu.yuzu_emu.activities.EmulationActivity
import org.yuzu.yuzu_emu.utils.DirectoryInitialization import org.yuzu.yuzu_emu.utils.DirectoryInitialization
import org.yuzu.yuzu_emu.utils.FileUtil import org.yuzu.yuzu_emu.utils.FileUtil
import java.time.LocalDateTime import java.time.LocalDateTime
@ -61,6 +63,12 @@ class Game(
val addonDir: String val addonDir: String
get() = DirectoryInitialization.userDirectory + "/load/" + programIdHex + "/" get() = DirectoryInitialization.userDirectory + "/load/" + programIdHex + "/"
val launchIntent: Intent
get() = Intent(YuzuApplication.appContext, EmulationActivity::class.java).apply {
action = Intent.ACTION_VIEW
data = Uri.parse(path)
}
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (other !is Game) { if (other !is Game) {
return false return false

View file

@ -5,7 +5,10 @@ package org.yuzu.yuzu_emu.utils
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import android.graphics.drawable.LayerDrawable
import android.widget.ImageView import android.widget.ImageView
import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.drawable.IconCompat
import androidx.core.graphics.drawable.toBitmap import androidx.core.graphics.drawable.toBitmap
import androidx.core.graphics.drawable.toDrawable import androidx.core.graphics.drawable.toDrawable
import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleOwner
@ -85,4 +88,22 @@ object GameIconUtils {
return imageLoader.execute(request) return imageLoader.execute(request)
.drawable!!.toBitmap(config = Bitmap.Config.ARGB_8888) .drawable!!.toBitmap(config = Bitmap.Config.ARGB_8888)
} }
suspend fun getShortcutIcon(lifecycleOwner: LifecycleOwner, game: Game): IconCompat {
val layerDrawable = ResourcesCompat.getDrawable(
YuzuApplication.appContext.resources,
R.drawable.shortcut,
null
) as LayerDrawable
layerDrawable.setDrawableByLayerId(
R.id.shortcut_foreground,
getGameIcon(lifecycleOwner, game).toDrawable(YuzuApplication.appContext.resources)
)
val inset = YuzuApplication.appContext.resources
.getDimensionPixelSize(R.dimen.icon_inset)
layerDrawable.setLayerInset(1, inset, inset, inset, inset)
return IconCompat.createWithAdaptiveBitmap(
layerDrawable.toBitmap(config = Bitmap.Config.ARGB_8888)
)
}
} }

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="?attr/colorControlNormal"
android:pathData="M280,920q-33,0 -56.5,-23.5T200,840v-720q0,-33 23.5,-56.5T280,40h400q33,0 56.5,23.5T760,120v160h-80v-40L280,240v480h400v-40h80v160q0,33 -23.5,56.5T680,920L280,920ZM686,520L480,520v120h-80v-120q0,-33 23.5,-56.5T480,440h206l-62,-64 56,-56 160,160 -160,160 -56,-56 62,-64Z" />
</vector>

View file

@ -43,16 +43,35 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
<Button <Button
android:id="@+id/button_back" android:id="@+id/button_back"
style="?attr/materialIconButtonStyle" style="?attr/materialIconButtonStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_margin="8dp"
app:icon="@drawable/ic_back" app:icon="@drawable/ic_back"
app:iconSize="24dp" app:iconSize="24dp"
app:iconTint="?attr/colorOnSurface" /> app:iconTint="?attr/colorOnSurface"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button_shortcut"
style="?attr/materialIconButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:icon="@drawable/ic_shortcut"
app:iconSize="24dp"
app:iconTint="?attr/colorOnSurface"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
style="?attr/materialCardViewElevatedStyle" style="?attr/materialCardViewElevatedStyle"

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -22,16 +21,35 @@
android:orientation="vertical" android:orientation="vertical"
android:gravity="center_horizontal"> android:gravity="center_horizontal">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
<Button <Button
android:id="@+id/button_back" android:id="@+id/button_back"
style="?attr/materialIconButtonStyle" style="?attr/materialIconButtonStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_gravity="start"
app:icon="@drawable/ic_back" app:icon="@drawable/ic_back"
app:iconSize="24dp" app:iconSize="24dp"
app:iconTint="?attr/colorOnSurface" /> app:iconTint="?attr/colorOnSurface"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button_shortcut"
style="?attr/materialIconButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:icon="@drawable/ic_shortcut"
app:iconSize="24dp"
app:iconTint="?attr/colorOnSurface"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
style="?attr/materialCardViewElevatedStyle" style="?attr/materialCardViewElevatedStyle"
@ -45,7 +63,7 @@
android:id="@+id/image_game_screen" android:id="@+id/image_game_screen"
android:layout_width="175dp" android:layout_width="175dp"
android:layout_height="175dp" android:layout_height="175dp"
tools:src="@drawable/default_icon"/> tools:src="@drawable/default_icon" />
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>

View file

@ -119,15 +119,21 @@ void ServiceManager::Handle_GetStaticServiceAsServiceManager(HLERequestContext&
void ServiceManager::Handle_SetupStandardSteadyClockCore(HLERequestContext& ctx) { void ServiceManager::Handle_SetupStandardSteadyClockCore(HLERequestContext& ctx) {
LOG_DEBUG(Service_Time, "called."); LOG_DEBUG(Service_Time, "called.");
IPC::RequestParser rp{ctx}; struct Parameters {
auto clock_source_id{rp.PopRaw<Common::UUID>()}; bool reset_detected;
auto rtc_offset{rp.Pop<s64>()}; Common::UUID clock_source_id;
auto internal_offset{rp.Pop<s64>()}; s64 rtc_offset;
auto test_offset{rp.Pop<s64>()}; s64 internal_offset;
auto is_rtc_reset_detected{rp.Pop<bool>()}; s64 test_offset;
};
static_assert(sizeof(Parameters) == 0x30);
auto res = SetupStandardSteadyClockCore(clock_source_id, rtc_offset, internal_offset, IPC::RequestParser rp{ctx};
test_offset, is_rtc_reset_detected); auto params{rp.PopRaw<Parameters>()};
auto res = SetupStandardSteadyClockCore(params.clock_source_id, params.rtc_offset,
params.internal_offset, params.test_offset,
params.reset_detected);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(res); rb.Push(res);
@ -162,11 +168,16 @@ void ServiceManager::Handle_SetupStandardNetworkSystemClockCore(HLERequestContex
void ServiceManager::Handle_SetupStandardUserSystemClockCore(HLERequestContext& ctx) { void ServiceManager::Handle_SetupStandardUserSystemClockCore(HLERequestContext& ctx) {
LOG_DEBUG(Service_Time, "called."); LOG_DEBUG(Service_Time, "called.");
IPC::RequestParser rp{ctx}; struct Parameters {
auto time_point{rp.PopRaw<SteadyClockTimePoint>()}; bool automatic_correction;
auto automatic_correction{rp.Pop<bool>()}; SteadyClockTimePoint time_point;
};
static_assert(sizeof(Parameters) == 0x20);
auto res = SetupStandardUserSystemClockCore(time_point, automatic_correction); IPC::RequestParser rp{ctx};
auto params{rp.PopRaw<Parameters>()};
auto res = SetupStandardUserSystemClockCore(params.time_point, params.automatic_correction);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(res); rb.Push(res);
@ -175,16 +186,21 @@ void ServiceManager::Handle_SetupStandardUserSystemClockCore(HLERequestContext&
void ServiceManager::Handle_SetupTimeZoneServiceCore(HLERequestContext& ctx) { void ServiceManager::Handle_SetupTimeZoneServiceCore(HLERequestContext& ctx) {
LOG_DEBUG(Service_Time, "called."); LOG_DEBUG(Service_Time, "called.");
struct Parameters {
u32 location_count;
LocationName name;
SteadyClockTimePoint time_point;
RuleVersion rule_version;
};
static_assert(sizeof(Parameters) == 0x50);
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
auto name{rp.PopRaw<LocationName>()}; auto params{rp.PopRaw<Parameters>()};
auto time_point{rp.PopRaw<SteadyClockTimePoint>()};
auto rule_version{rp.PopRaw<RuleVersion>()};
auto location_count{rp.Pop<u32>()};
auto rule_buffer{ctx.ReadBuffer()}; auto rule_buffer{ctx.ReadBuffer()};
auto res = auto res = SetupTimeZoneServiceCore(params.name, params.time_point, params.rule_version,
SetupTimeZoneServiceCore(name, time_point, rule_version, location_count, rule_buffer); params.location_count, rule_buffer);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(res); rb.Push(res);
@ -286,11 +302,22 @@ void ServiceManager::Handle_GetClosestAlarmInfo(HLERequestContext& ctx) {
s64 time{}; s64 time{};
auto res = GetClosestAlarmInfo(is_valid, alarm_info, time); auto res = GetClosestAlarmInfo(is_valid, alarm_info, time);
IPC::ResponseBuilder rb{ctx, 5 + sizeof(AlarmInfo) / sizeof(u32)}; struct OutParameters {
bool is_valid;
AlarmInfo alarm_info;
s64 time;
};
static_assert(sizeof(OutParameters) == 0x20);
OutParameters out_params{
.is_valid = is_valid,
.alarm_info = alarm_info,
.time = time,
};
IPC::ResponseBuilder rb{ctx, 2 + sizeof(OutParameters) / sizeof(u32)};
rb.Push(res); rb.Push(res);
rb.PushRaw<AlarmInfo>(alarm_info); rb.PushRaw<OutParameters>(out_params);
rb.Push<bool>(is_valid);
rb.Push<s64>(time);
} }
// =============================== Implementations =========================== // =============================== Implementations ===========================

View file

@ -15,12 +15,12 @@ SteadyClock::SteadyClock(Core::System& system_, std::shared_ptr<TimeManager> man
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &SteadyClock::Handle_GetCurrentTimePoint, "GetCurrentTimePoint"}, {0, &SteadyClock::Handle_GetCurrentTimePoint, "GetCurrentTimePoint"},
{1, &SteadyClock::Handle_GetTestOffset, "GetTestOffset"}, {2, &SteadyClock::Handle_GetTestOffset, "GetTestOffset"},
{2, &SteadyClock::Handle_SetTestOffset, "SetTestOffset"}, {3, &SteadyClock::Handle_SetTestOffset, "SetTestOffset"},
{3, &SteadyClock::Handle_GetRtcValue, "GetRtcValue"}, {100, &SteadyClock::Handle_GetRtcValue, "GetRtcValue"},
{4, &SteadyClock::Handle_IsRtcResetDetected, "IsRtcResetDetected"}, {101, &SteadyClock::Handle_IsRtcResetDetected, "IsRtcResetDetected"},
{5, &SteadyClock::Handle_GetSetupResultValue, "GetSetupResultValue"}, {102, &SteadyClock::Handle_GetSetupResultValue, "GetSetupResultValue"},
{6, &SteadyClock::Handle_GetInternalOffset, "GetInternalOffset"}, {200, &SteadyClock::Handle_GetInternalOffset, "GetInternalOffset"},
}; };
// clang-format on // clang-format on
RegisterHandlers(functions); RegisterHandlers(functions);