Compare commits
44 Commits
android-18
...
android-19
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20b744ee68 | ||
|
|
d62868644b | ||
|
|
bd30c1e2d9 | ||
|
|
0dc00454e5 | ||
|
|
fd9e7d6cb1 | ||
|
|
f7a3c135e2 | ||
|
|
fcb0dff67c | ||
|
|
b5dac5f525 | ||
|
|
a4d90a9a64 | ||
|
|
84787a2ada | ||
|
|
d3ba6b334b | ||
|
|
dac8c4ce4d | ||
|
|
9e974d4c7e | ||
|
|
6bfc3c530c | ||
|
|
93239f191a | ||
|
|
b17db2b462 | ||
|
|
9130366a58 | ||
|
|
ad0066a6b6 | ||
|
|
78c323c4eb | ||
|
|
51ad2d10de | ||
|
|
6533dfd7ce | ||
|
|
e11a3414ae | ||
|
|
4fdc900581 | ||
|
|
d99830b59c | ||
|
|
23c11e50f9 | ||
|
|
5fde5e62a8 | ||
|
|
f124461674 | ||
|
|
30743eff56 | ||
|
|
4f83b00f6f | ||
|
|
ea710e6523 | ||
|
|
ae88ea79b2 | ||
|
|
82b58668ed | ||
|
|
bd80929ac1 | ||
|
|
2a4ac7cfac | ||
|
|
ab513c378a | ||
|
|
a959fb011f | ||
|
|
53085a45e0 | ||
|
|
bc2d1262d7 | ||
|
|
5105b90017 | ||
|
|
3516a2d0bf | ||
|
|
f224ef6185 | ||
|
|
8e27a485d8 | ||
|
|
a36f4d0a9f | ||
|
|
37b0870ee3 |
@@ -3,38 +3,32 @@
|
||||
# SPDX-FileCopyrightText: 2019 yuzu Emulator Project
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .ci* dist/*.desktop \
|
||||
dist/*.svg dist/*.xml; then
|
||||
shopt -s nullglob globstar
|
||||
|
||||
if git grep -nrI '\s$' src **/*.yml **/*.txt **/*.md Doxyfile .gitignore .gitmodules .ci* dist/*.desktop dist/*.svg dist/*.xml; then
|
||||
echo Trailing whitespace found, aborting
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Default clang-format points to default 3.5 version one
|
||||
CLANG_FORMAT=${CLANG_FORMAT:-clang-format-15}
|
||||
$CLANG_FORMAT --version
|
||||
|
||||
if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then
|
||||
# Get list of every file modified in this pull request
|
||||
files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^src/[^.]*[.]\(cpp\|h\)$' || true)"
|
||||
else
|
||||
# Check everything for branch pushes
|
||||
files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')"
|
||||
fi
|
||||
CLANG_FORMAT="${CLANG_FORMAT:-clang-format-15}"
|
||||
"$CLANG_FORMAT" --version
|
||||
|
||||
# Turn off tracing for this because it's too verbose
|
||||
set +x
|
||||
|
||||
for f in $files_to_lint; do
|
||||
d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true)
|
||||
if ! [ -z "$d" ]; then
|
||||
echo "!!! $f not compliant to coding style, here is the fix:"
|
||||
echo "$d"
|
||||
fail=1
|
||||
fi
|
||||
# Check everything for branch pushes
|
||||
FILES_TO_LINT="$(find src/ -name '*.cpp' -or -name '*.h')"
|
||||
|
||||
for f in $FILES_TO_LINT; do
|
||||
echo "$f"
|
||||
"$CLANG_FORMAT" -i "$f"
|
||||
done
|
||||
|
||||
set -x
|
||||
DIFF=$(git -c core.fileMode=false diff)
|
||||
|
||||
if [ "$fail" = 1 ]; then
|
||||
if [ ! -z "$DIFF" ]; then
|
||||
echo "!!! Not compliant to coding style, here is the fix:"
|
||||
echo "$DIFF"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -9,7 +9,7 @@ chmod a+x ./.ci/scripts/linux/docker.sh
|
||||
sudo chown -R 1027 ./
|
||||
|
||||
# The environment variables listed below:
|
||||
# AZURECIREPO TITLEBARFORMATIDLE TITLEBARFORMATRUNNING DISPLAYVERSION
|
||||
# AZURECIREPO TITLEBARFORMATIDLE TITLEBARFORMATRUNNING DISPLAYVERSION
|
||||
# are requested in src/common/CMakeLists.txt and appear to be provided somewhere in Azure DevOps
|
||||
|
||||
docker run -e AZURECIREPO -e TITLEBARFORMATIDLE -e TITLEBARFORMATRUNNING -e DISPLAYVERSION -e ENABLE_COMPATIBILITY_REPORTING -e CCACHE_DIR=/yuzu/ccache -v "$(pwd):/yuzu" -w /yuzu yuzuemu/build-environments:linux-fresh /bin/bash /yuzu/.ci/scripts/linux/docker.sh "$1"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) <year> <owner>
|
||||
Copyright (c) <year> <owner>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) <year> <owner>.
|
||||
Copyright (c) <year> <owner>.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ Mozilla Public License Version 2.0
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
| Pull Request | Commit | Title | Author | Merged? |
|
||||
|----|----|----|----|----|
|
||||
| [12579](https://github.com/yuzu-emu/yuzu-android//pull/12579) | [`b5b47aa25`](https://github.com/yuzu-emu/yuzu-android//pull/12579/files) | Core: Implement Device Mapping & GPU SMMU | [FernandoS27](https://github.com/FernandoS27/) | Yes |
|
||||
| [12579](https://github.com/yuzu-emu/yuzu-android//pull/12579) | [`66ae60a9e`](https://github.com/yuzu-emu/yuzu-android//pull/12579/files) | Core: Implement Device Mapping & GPU SMMU | [FernandoS27](https://github.com/FernandoS27/) | Yes |
|
||||
| [12610](https://github.com/yuzu-emu/yuzu-android//pull/12610) | [`200b371d1`](https://github.com/yuzu-emu/yuzu-android//pull/12610/files) | server_manager: respond to session close correctly | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
| [12612](https://github.com/yuzu-emu/yuzu-android//pull/12612) | [`aae9eea53`](https://github.com/yuzu-emu/yuzu-android//pull/12612/files) | fsp-srv: use program registry for SetCurrentProcess | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
| [12652](https://github.com/yuzu-emu/yuzu-android//pull/12652) | [`2a0d707ce`](https://github.com/yuzu-emu/yuzu-android//pull/12652/files) | shader_recompiler: emulate 8-bit and 16-bit storage writes with cas loop | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
|
||||
|
||||
End of merge log. You can find the original README.md below the break.
|
||||
|
||||
2
externals/ffmpeg/CMakeLists.txt
vendored
2
externals/ffmpeg/CMakeLists.txt
vendored
@@ -138,7 +138,7 @@ if (NOT WIN32 AND NOT ANDROID)
|
||||
--cross-prefix=${TOOLCHAIN}/bin/aarch64-linux-android-
|
||||
--sysroot=${SYSROOT}
|
||||
--target-os=android
|
||||
--extra-ldflags="--ld-path=${TOOLCHAIN}/bin/ld.lld"
|
||||
--extra-ldflags="--ld-path=${TOOLCHAIN}/bin/ld.lld"
|
||||
--extra-ldflags="-nostdlib"
|
||||
)
|
||||
endif()
|
||||
|
||||
2
externals/nx_tzdb/tzdb_to_nx
vendored
2
externals/nx_tzdb/tzdb_to_nx
vendored
Submodule externals/nx_tzdb/tzdb_to_nx updated: f6680093bc...404d390045
@@ -0,0 +1,33 @@
|
||||
// SPDX-FileCopyrightText: 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.yuzu.yuzu_emu.adapters
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
/**
|
||||
* Generic adapter that implements an [AsyncDifferConfig] and covers some of the basic boilerplate
|
||||
* code used in every [RecyclerView].
|
||||
* Type assigned to [Model] must inherit from [Object] in order to be compared properly.
|
||||
*/
|
||||
abstract class AbstractDiffAdapter<Model : Any, Holder : AbstractViewHolder<Model>> :
|
||||
ListAdapter<Model, Holder>(AsyncDifferConfig.Builder(DiffCallback<Model>()).build()) {
|
||||
override fun onBindViewHolder(holder: Holder, position: Int) =
|
||||
holder.bind(currentList[position])
|
||||
|
||||
private class DiffCallback<Model> : DiffUtil.ItemCallback<Model>() {
|
||||
override fun areItemsTheSame(oldItem: Model & Any, newItem: Model & Any): Boolean {
|
||||
return oldItem === newItem
|
||||
}
|
||||
|
||||
@SuppressLint("DiffUtilEquals")
|
||||
override fun areContentsTheSame(oldItem: Model & Any, newItem: Model & Any): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
// SPDX-FileCopyrightText: 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.yuzu.yuzu_emu.adapters
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
|
||||
/**
|
||||
* Generic list class meant to take care of basic lists
|
||||
* @param currentList The list to show initially
|
||||
*/
|
||||
abstract class AbstractListAdapter<Model : Any, Holder : AbstractViewHolder<Model>>(
|
||||
open var currentList: List<Model>
|
||||
) : RecyclerView.Adapter<Holder>() {
|
||||
override fun onBindViewHolder(holder: Holder, position: Int) =
|
||||
holder.bind(currentList[position])
|
||||
|
||||
override fun getItemCount(): Int = currentList.size
|
||||
|
||||
/**
|
||||
* Adds an item to [currentList] and notifies the underlying adapter of the change. If no parameter
|
||||
* is passed in for position, [item] is added to the end of the list. Invokes [callback] last.
|
||||
* @param item The item to add to the list
|
||||
* @param position Index where [item] will be added
|
||||
* @param callback Lambda that's called at the end of the list changes and has the added list
|
||||
* position passed in as a parameter
|
||||
*/
|
||||
open fun addItem(item: Model, position: Int = -1, callback: ((position: Int) -> Unit)? = null) {
|
||||
val newList = currentList.toMutableList()
|
||||
val positionToUpdate: Int
|
||||
if (position == -1) {
|
||||
newList.add(item)
|
||||
currentList = newList
|
||||
positionToUpdate = currentList.size - 1
|
||||
} else {
|
||||
newList.add(position, item)
|
||||
currentList = newList
|
||||
positionToUpdate = position
|
||||
}
|
||||
onItemAdded(positionToUpdate, callback)
|
||||
}
|
||||
|
||||
protected fun onItemAdded(position: Int, callback: ((Int) -> Unit)? = null) {
|
||||
notifyItemInserted(position)
|
||||
callback?.invoke(position)
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the [item] at [position] in the [currentList] and notifies the underlying adapter
|
||||
* of the change. Invokes [callback] last.
|
||||
* @param item New list item
|
||||
* @param position Index where [item] will replace the existing list item
|
||||
* @param callback Lambda that's called at the end of the list changes and has the changed list
|
||||
* position passed in as a parameter
|
||||
*/
|
||||
fun changeItem(item: Model, position: Int, callback: ((position: Int) -> Unit)? = null) {
|
||||
val newList = currentList.toMutableList()
|
||||
newList[position] = item
|
||||
currentList = newList
|
||||
onItemChanged(position, callback)
|
||||
}
|
||||
|
||||
protected fun onItemChanged(position: Int, callback: ((Int) -> Unit)? = null) {
|
||||
notifyItemChanged(position)
|
||||
callback?.invoke(position)
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the list item at [position] in [currentList] and notifies the underlying adapter
|
||||
* of the change. Invokes [callback] last.
|
||||
* @param position Index where the list item will be removed
|
||||
* @param callback Lambda that's called at the end of the list changes and has the removed list
|
||||
* position passed in as a parameter
|
||||
*/
|
||||
fun removeItem(position: Int, callback: ((position: Int) -> Unit)? = null) {
|
||||
val newList = currentList.toMutableList()
|
||||
newList.removeAt(position)
|
||||
currentList = newList
|
||||
onItemRemoved(position, callback)
|
||||
}
|
||||
|
||||
protected fun onItemRemoved(position: Int, callback: ((Int) -> Unit)? = null) {
|
||||
notifyItemRemoved(position)
|
||||
callback?.invoke(position)
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces [currentList] with [newList] and notifies the underlying adapter of the change.
|
||||
* @param newList The new list to replace [currentList]
|
||||
*/
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
open fun replaceList(newList: List<Model>) {
|
||||
currentList = newList
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
// SPDX-FileCopyrightText: 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.yuzu.yuzu_emu.adapters
|
||||
|
||||
import org.yuzu.yuzu_emu.model.SelectableItem
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
|
||||
/**
|
||||
* Generic list class meant to take care of single selection UI updates
|
||||
* @param currentList The list to show initially
|
||||
* @param defaultSelection The default selection to use if no list items are selected by
|
||||
* [SelectableItem.selected] or if the currently selected item is removed from the list
|
||||
*/
|
||||
abstract class AbstractSingleSelectionList<
|
||||
Model : SelectableItem,
|
||||
Holder : AbstractViewHolder<Model>
|
||||
>(
|
||||
final override var currentList: List<Model>,
|
||||
private val defaultSelection: DefaultSelection = DefaultSelection.Start
|
||||
) : AbstractListAdapter<Model, Holder>(currentList) {
|
||||
var selectedItem = getDefaultSelection()
|
||||
|
||||
init {
|
||||
findSelectedItem()
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the selection state of the [SelectableItem] that was selected and the previously selected
|
||||
* item and notifies the underlying adapter of the change for those items. Invokes [callback] last.
|
||||
* Does nothing if [position] is the same as the currently selected item.
|
||||
* @param position Index of the item that was selected
|
||||
* @param callback Lambda that's called at the end of the list changes and has the selected list
|
||||
* position passed in as a parameter
|
||||
*/
|
||||
fun selectItem(position: Int, callback: ((position: Int) -> Unit)? = null) {
|
||||
if (position == selectedItem) {
|
||||
return
|
||||
}
|
||||
|
||||
val previouslySelectedItem = selectedItem
|
||||
selectedItem = position
|
||||
if (currentList.indices.contains(selectedItem)) {
|
||||
currentList[selectedItem].onSelectionStateChanged(true)
|
||||
}
|
||||
if (currentList.indices.contains(previouslySelectedItem)) {
|
||||
currentList[previouslySelectedItem].onSelectionStateChanged(false)
|
||||
}
|
||||
onItemChanged(previouslySelectedItem)
|
||||
onItemChanged(selectedItem)
|
||||
callback?.invoke(position)
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a given item from the list and notifies the underlying adapter of the change. If the
|
||||
* currently selected item was the item that was removed, the item at the position provided
|
||||
* by [defaultSelection] will be made the new selection. Invokes [callback] last.
|
||||
* @param position Index of the item that was removed
|
||||
* @param callback Lambda that's called at the end of the list changes and has the removed and
|
||||
* selected list positions passed in as parameters
|
||||
*/
|
||||
fun removeSelectableItem(
|
||||
position: Int,
|
||||
callback: ((removedPosition: Int, selectedPosition: Int) -> Unit)?
|
||||
) {
|
||||
removeItem(position)
|
||||
if (position == selectedItem) {
|
||||
selectedItem = getDefaultSelection()
|
||||
currentList[selectedItem].onSelectionStateChanged(true)
|
||||
onItemChanged(selectedItem)
|
||||
} else if (position < selectedItem) {
|
||||
selectedItem--
|
||||
}
|
||||
callback?.invoke(position, selectedItem)
|
||||
}
|
||||
|
||||
override fun addItem(item: Model, position: Int, callback: ((Int) -> Unit)?) {
|
||||
super.addItem(item, position, callback)
|
||||
if (position <= selectedItem && position != -1) {
|
||||
selectedItem++
|
||||
}
|
||||
}
|
||||
|
||||
override fun replaceList(newList: List<Model>) {
|
||||
super.replaceList(newList)
|
||||
findSelectedItem()
|
||||
}
|
||||
|
||||
private fun findSelectedItem() {
|
||||
for (i in currentList.indices) {
|
||||
if (currentList[i].selected) {
|
||||
selectedItem = i
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDefaultSelection(): Int =
|
||||
when (defaultSelection) {
|
||||
DefaultSelection.Start -> currentList.indices.first
|
||||
DefaultSelection.End -> currentList.indices.last
|
||||
}
|
||||
|
||||
enum class DefaultSelection { Start, End }
|
||||
}
|
||||
@@ -5,48 +5,28 @@ package org.yuzu.yuzu_emu.adapters
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.yuzu.yuzu_emu.databinding.ListItemAddonBinding
|
||||
import org.yuzu.yuzu_emu.model.Addon
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
|
||||
class AddonAdapter : ListAdapter<Addon, AddonAdapter.AddonViewHolder>(
|
||||
AsyncDifferConfig.Builder(DiffCallback()).build()
|
||||
) {
|
||||
class AddonAdapter : AbstractDiffAdapter<Addon, AddonAdapter.AddonViewHolder>() {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AddonViewHolder {
|
||||
ListItemAddonBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
.also { return AddonViewHolder(it) }
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = currentList.size
|
||||
|
||||
override fun onBindViewHolder(holder: AddonViewHolder, position: Int) =
|
||||
holder.bind(currentList[position])
|
||||
|
||||
inner class AddonViewHolder(val binding: ListItemAddonBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(addon: Addon) {
|
||||
AbstractViewHolder<Addon>(binding) {
|
||||
override fun bind(model: Addon) {
|
||||
binding.root.setOnClickListener {
|
||||
binding.addonSwitch.isChecked = !binding.addonSwitch.isChecked
|
||||
}
|
||||
binding.title.text = addon.title
|
||||
binding.version.text = addon.version
|
||||
binding.title.text = model.title
|
||||
binding.version.text = model.version
|
||||
binding.addonSwitch.setOnCheckedChangeListener { _, checked ->
|
||||
addon.enabled = checked
|
||||
model.enabled = checked
|
||||
}
|
||||
binding.addonSwitch.isChecked = addon.enabled
|
||||
}
|
||||
}
|
||||
|
||||
private class DiffCallback : DiffUtil.ItemCallback<Addon>() {
|
||||
override fun areItemsTheSame(oldItem: Addon, newItem: Addon): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: Addon, newItem: Addon): Boolean {
|
||||
return oldItem == newItem
|
||||
binding.addonSwitch.isChecked = model.enabled
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,11 @@
|
||||
package org.yuzu.yuzu_emu.adapters
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.yuzu.yuzu_emu.HomeNavigationDirections
|
||||
import org.yuzu.yuzu_emu.NativeLibrary
|
||||
import org.yuzu.yuzu_emu.R
|
||||
@@ -19,72 +17,58 @@ import org.yuzu.yuzu_emu.databinding.CardSimpleOutlinedBinding
|
||||
import org.yuzu.yuzu_emu.model.Applet
|
||||
import org.yuzu.yuzu_emu.model.AppletInfo
|
||||
import org.yuzu.yuzu_emu.model.Game
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
|
||||
class AppletAdapter(val activity: FragmentActivity, var applets: List<Applet>) :
|
||||
RecyclerView.Adapter<AppletAdapter.AppletViewHolder>(),
|
||||
View.OnClickListener {
|
||||
|
||||
class AppletAdapter(val activity: FragmentActivity, applets: List<Applet>) :
|
||||
AbstractListAdapter<Applet, AppletAdapter.AppletViewHolder>(applets) {
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
): AppletAdapter.AppletViewHolder {
|
||||
CardSimpleOutlinedBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
.apply { root.setOnClickListener(this@AppletAdapter) }
|
||||
.also { return AppletViewHolder(it) }
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: AppletViewHolder, position: Int) =
|
||||
holder.bind(applets[position])
|
||||
|
||||
override fun getItemCount(): Int = applets.size
|
||||
|
||||
override fun onClick(view: View) {
|
||||
val applet = (view.tag as AppletViewHolder).applet
|
||||
val appletPath = NativeLibrary.getAppletLaunchPath(applet.appletInfo.entryId)
|
||||
if (appletPath.isEmpty()) {
|
||||
Toast.makeText(
|
||||
YuzuApplication.appContext,
|
||||
R.string.applets_error_applet,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
return
|
||||
}
|
||||
|
||||
if (applet.appletInfo == AppletInfo.Cabinet) {
|
||||
view.findNavController()
|
||||
.navigate(R.id.action_appletLauncherFragment_to_cabinetLauncherDialogFragment)
|
||||
return
|
||||
}
|
||||
|
||||
NativeLibrary.setCurrentAppletId(applet.appletInfo.appletId)
|
||||
val appletGame = Game(
|
||||
title = YuzuApplication.appContext.getString(applet.titleId),
|
||||
path = appletPath
|
||||
)
|
||||
val action = HomeNavigationDirections.actionGlobalEmulationActivity(appletGame)
|
||||
view.findNavController().navigate(action)
|
||||
}
|
||||
|
||||
inner class AppletViewHolder(val binding: CardSimpleOutlinedBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
lateinit var applet: Applet
|
||||
|
||||
init {
|
||||
itemView.tag = this
|
||||
}
|
||||
|
||||
fun bind(applet: Applet) {
|
||||
this.applet = applet
|
||||
|
||||
binding.title.setText(applet.titleId)
|
||||
binding.description.setText(applet.descriptionId)
|
||||
AbstractViewHolder<Applet>(binding) {
|
||||
override fun bind(model: Applet) {
|
||||
binding.title.setText(model.titleId)
|
||||
binding.description.setText(model.descriptionId)
|
||||
binding.icon.setImageDrawable(
|
||||
ResourcesCompat.getDrawable(
|
||||
binding.icon.context.resources,
|
||||
applet.iconId,
|
||||
model.iconId,
|
||||
binding.icon.context.theme
|
||||
)
|
||||
)
|
||||
|
||||
binding.root.setOnClickListener { onClick(model) }
|
||||
}
|
||||
|
||||
fun onClick(applet: Applet) {
|
||||
val appletPath = NativeLibrary.getAppletLaunchPath(applet.appletInfo.entryId)
|
||||
if (appletPath.isEmpty()) {
|
||||
Toast.makeText(
|
||||
binding.root.context,
|
||||
R.string.applets_error_applet,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
return
|
||||
}
|
||||
|
||||
if (applet.appletInfo == AppletInfo.Cabinet) {
|
||||
binding.root.findNavController()
|
||||
.navigate(R.id.action_appletLauncherFragment_to_cabinetLauncherDialogFragment)
|
||||
return
|
||||
}
|
||||
|
||||
NativeLibrary.setCurrentAppletId(applet.appletInfo.appletId)
|
||||
val appletGame = Game(
|
||||
title = YuzuApplication.appContext.getString(applet.titleId),
|
||||
path = appletPath
|
||||
)
|
||||
val action = HomeNavigationDirections.actionGlobalEmulationActivity(appletGame)
|
||||
binding.root.findNavController().navigate(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,10 @@
|
||||
package org.yuzu.yuzu_emu.adapters
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.yuzu.yuzu_emu.HomeNavigationDirections
|
||||
import org.yuzu.yuzu_emu.NativeLibrary
|
||||
import org.yuzu.yuzu_emu.R
|
||||
@@ -19,54 +17,43 @@ import org.yuzu.yuzu_emu.model.CabinetMode
|
||||
import org.yuzu.yuzu_emu.adapters.CabinetLauncherDialogAdapter.CabinetModeViewHolder
|
||||
import org.yuzu.yuzu_emu.model.AppletInfo
|
||||
import org.yuzu.yuzu_emu.model.Game
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
|
||||
class CabinetLauncherDialogAdapter(val fragment: Fragment) :
|
||||
RecyclerView.Adapter<CabinetModeViewHolder>(),
|
||||
View.OnClickListener {
|
||||
private val cabinetModes = CabinetMode.values().copyOfRange(1, CabinetMode.values().size)
|
||||
AbstractListAdapter<CabinetMode, CabinetModeViewHolder>(
|
||||
CabinetMode.values().copyOfRange(1, CabinetMode.entries.size).toList()
|
||||
) {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CabinetModeViewHolder {
|
||||
DialogListItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
.apply { root.setOnClickListener(this@CabinetLauncherDialogAdapter) }
|
||||
.also { return CabinetModeViewHolder(it) }
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = cabinetModes.size
|
||||
|
||||
override fun onBindViewHolder(holder: CabinetModeViewHolder, position: Int) =
|
||||
holder.bind(cabinetModes[position])
|
||||
|
||||
override fun onClick(view: View) {
|
||||
val mode = (view.tag as CabinetModeViewHolder).cabinetMode
|
||||
val appletPath = NativeLibrary.getAppletLaunchPath(AppletInfo.Cabinet.entryId)
|
||||
NativeLibrary.setCurrentAppletId(AppletInfo.Cabinet.appletId)
|
||||
NativeLibrary.setCabinetMode(mode.id)
|
||||
val appletGame = Game(
|
||||
title = YuzuApplication.appContext.getString(R.string.cabinet_applet),
|
||||
path = appletPath
|
||||
)
|
||||
val action = HomeNavigationDirections.actionGlobalEmulationActivity(appletGame)
|
||||
fragment.findNavController().navigate(action)
|
||||
}
|
||||
|
||||
inner class CabinetModeViewHolder(val binding: DialogListItemBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
lateinit var cabinetMode: CabinetMode
|
||||
|
||||
init {
|
||||
itemView.tag = this
|
||||
}
|
||||
|
||||
fun bind(cabinetMode: CabinetMode) {
|
||||
this.cabinetMode = cabinetMode
|
||||
AbstractViewHolder<CabinetMode>(binding) {
|
||||
override fun bind(model: CabinetMode) {
|
||||
binding.icon.setImageDrawable(
|
||||
ResourcesCompat.getDrawable(
|
||||
binding.icon.context.resources,
|
||||
cabinetMode.iconId,
|
||||
model.iconId,
|
||||
binding.icon.context.theme
|
||||
)
|
||||
)
|
||||
binding.title.setText(cabinetMode.titleId)
|
||||
binding.title.setText(model.titleId)
|
||||
|
||||
binding.root.setOnClickListener { onClick(model) }
|
||||
}
|
||||
|
||||
private fun onClick(mode: CabinetMode) {
|
||||
val appletPath = NativeLibrary.getAppletLaunchPath(AppletInfo.Cabinet.entryId)
|
||||
NativeLibrary.setCurrentAppletId(AppletInfo.Cabinet.appletId)
|
||||
NativeLibrary.setCabinetMode(mode.id)
|
||||
val appletGame = Game(
|
||||
title = YuzuApplication.appContext.getString(R.string.cabinet_applet),
|
||||
path = appletPath
|
||||
)
|
||||
val action = HomeNavigationDirections.actionGlobalEmulationActivity(appletGame)
|
||||
fragment.findNavController().navigate(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,65 +7,39 @@ import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.databinding.CardDriverOptionBinding
|
||||
import org.yuzu.yuzu_emu.features.settings.model.StringSetting
|
||||
import org.yuzu.yuzu_emu.model.Driver
|
||||
import org.yuzu.yuzu_emu.model.DriverViewModel
|
||||
import org.yuzu.yuzu_emu.utils.GpuDriverHelper
|
||||
import org.yuzu.yuzu_emu.utils.GpuDriverMetadata
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
|
||||
class DriverAdapter(private val driverViewModel: DriverViewModel) :
|
||||
ListAdapter<Pair<String, GpuDriverMetadata>, DriverAdapter.DriverViewHolder>(
|
||||
AsyncDifferConfig.Builder(DiffCallback()).build()
|
||||
AbstractSingleSelectionList<Driver, DriverAdapter.DriverViewHolder>(
|
||||
driverViewModel.driverList.value
|
||||
) {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DriverViewHolder {
|
||||
val binding =
|
||||
CardDriverOptionBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return DriverViewHolder(binding)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = currentList.size
|
||||
|
||||
override fun onBindViewHolder(holder: DriverViewHolder, position: Int) =
|
||||
holder.bind(currentList[position])
|
||||
|
||||
private fun onSelectDriver(position: Int) {
|
||||
driverViewModel.setSelectedDriverIndex(position)
|
||||
notifyItemChanged(driverViewModel.previouslySelectedDriver)
|
||||
notifyItemChanged(driverViewModel.selectedDriver)
|
||||
}
|
||||
|
||||
private fun onDeleteDriver(driverData: Pair<String, GpuDriverMetadata>, position: Int) {
|
||||
if (driverViewModel.selectedDriver > position) {
|
||||
driverViewModel.setSelectedDriverIndex(driverViewModel.selectedDriver - 1)
|
||||
}
|
||||
if (GpuDriverHelper.customDriverSettingData == driverData.second) {
|
||||
driverViewModel.setSelectedDriverIndex(0)
|
||||
}
|
||||
driverViewModel.driversToDelete.add(driverData.first)
|
||||
driverViewModel.removeDriver(driverData)
|
||||
notifyItemRemoved(position)
|
||||
notifyItemChanged(driverViewModel.selectedDriver)
|
||||
CardDriverOptionBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
.also { return DriverViewHolder(it) }
|
||||
}
|
||||
|
||||
inner class DriverViewHolder(val binding: CardDriverOptionBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
private lateinit var driverData: Pair<String, GpuDriverMetadata>
|
||||
|
||||
fun bind(driverData: Pair<String, GpuDriverMetadata>) {
|
||||
this.driverData = driverData
|
||||
val driver = driverData.second
|
||||
|
||||
AbstractViewHolder<Driver>(binding) {
|
||||
override fun bind(model: Driver) {
|
||||
binding.apply {
|
||||
radioButton.isChecked = driverViewModel.selectedDriver == bindingAdapterPosition
|
||||
radioButton.isChecked = model.selected
|
||||
root.setOnClickListener {
|
||||
onSelectDriver(bindingAdapterPosition)
|
||||
selectItem(bindingAdapterPosition) {
|
||||
driverViewModel.onDriverSelected(it)
|
||||
driverViewModel.showClearButton(!StringSetting.DRIVER_PATH.global)
|
||||
}
|
||||
}
|
||||
buttonDelete.setOnClickListener {
|
||||
onDeleteDriver(driverData, bindingAdapterPosition)
|
||||
removeSelectableItem(
|
||||
bindingAdapterPosition
|
||||
) { removedPosition: Int, selectedPosition: Int ->
|
||||
driverViewModel.onDriverRemoved(removedPosition, selectedPosition)
|
||||
driverViewModel.showClearButton(!StringSetting.DRIVER_PATH.global)
|
||||
}
|
||||
}
|
||||
|
||||
// Delay marquee by 3s
|
||||
@@ -80,38 +54,19 @@ class DriverAdapter(private val driverViewModel: DriverViewModel) :
|
||||
},
|
||||
3000
|
||||
)
|
||||
if (driver.name == null) {
|
||||
title.setText(R.string.system_gpu_driver)
|
||||
description.text = ""
|
||||
version.text = ""
|
||||
version.visibility = View.GONE
|
||||
description.visibility = View.GONE
|
||||
buttonDelete.visibility = View.GONE
|
||||
} else {
|
||||
title.text = driver.name
|
||||
version.text = driver.version
|
||||
description.text = driver.description
|
||||
title.text = model.title
|
||||
version.text = model.version
|
||||
description.text = model.description
|
||||
if (model.description.isNotEmpty()) {
|
||||
version.visibility = View.VISIBLE
|
||||
description.visibility = View.VISIBLE
|
||||
buttonDelete.visibility = View.VISIBLE
|
||||
} else {
|
||||
version.visibility = View.GONE
|
||||
description.visibility = View.GONE
|
||||
buttonDelete.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DiffCallback : DiffUtil.ItemCallback<Pair<String, GpuDriverMetadata>>() {
|
||||
override fun areItemsTheSame(
|
||||
oldItem: Pair<String, GpuDriverMetadata>,
|
||||
newItem: Pair<String, GpuDriverMetadata>
|
||||
): Boolean {
|
||||
return oldItem.first == newItem.first
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(
|
||||
oldItem: Pair<String, GpuDriverMetadata>,
|
||||
newItem: Pair<String, GpuDriverMetadata>
|
||||
): Boolean {
|
||||
return oldItem.second == newItem.second
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,19 +8,14 @@ import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.yuzu.yuzu_emu.databinding.CardFolderBinding
|
||||
import org.yuzu.yuzu_emu.fragments.GameFolderPropertiesDialogFragment
|
||||
import org.yuzu.yuzu_emu.model.GameDir
|
||||
import org.yuzu.yuzu_emu.model.GamesViewModel
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
|
||||
class FolderAdapter(val activity: FragmentActivity, val gamesViewModel: GamesViewModel) :
|
||||
ListAdapter<GameDir, FolderAdapter.FolderViewHolder>(
|
||||
AsyncDifferConfig.Builder(DiffCallback()).build()
|
||||
) {
|
||||
AbstractDiffAdapter<GameDir, FolderAdapter.FolderViewHolder>() {
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
@@ -29,18 +24,11 @@ class FolderAdapter(val activity: FragmentActivity, val gamesViewModel: GamesVie
|
||||
.also { return FolderViewHolder(it) }
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: FolderAdapter.FolderViewHolder, position: Int) =
|
||||
holder.bind(currentList[position])
|
||||
|
||||
inner class FolderViewHolder(val binding: CardFolderBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
private lateinit var gameDir: GameDir
|
||||
|
||||
fun bind(gameDir: GameDir) {
|
||||
this.gameDir = gameDir
|
||||
|
||||
AbstractViewHolder<GameDir>(binding) {
|
||||
override fun bind(model: GameDir) {
|
||||
binding.apply {
|
||||
path.text = Uri.parse(gameDir.uriString).path
|
||||
path.text = Uri.parse(model.uriString).path
|
||||
path.postDelayed(
|
||||
{
|
||||
path.isSelected = true
|
||||
@@ -50,7 +38,7 @@ class FolderAdapter(val activity: FragmentActivity, val gamesViewModel: GamesVie
|
||||
)
|
||||
|
||||
buttonEdit.setOnClickListener {
|
||||
GameFolderPropertiesDialogFragment.newInstance(this@FolderViewHolder.gameDir)
|
||||
GameFolderPropertiesDialogFragment.newInstance(model)
|
||||
.show(
|
||||
activity.supportFragmentManager,
|
||||
GameFolderPropertiesDialogFragment.TAG
|
||||
@@ -58,19 +46,9 @@ class FolderAdapter(val activity: FragmentActivity, val gamesViewModel: GamesVie
|
||||
}
|
||||
|
||||
buttonDelete.setOnClickListener {
|
||||
gamesViewModel.removeFolder(this@FolderViewHolder.gameDir)
|
||||
gamesViewModel.removeFolder(model)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DiffCallback : DiffUtil.ItemCallback<GameDir>() {
|
||||
override fun areItemsTheSame(oldItem: GameDir, newItem: GameDir): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: GameDir, newItem: GameDir): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.graphics.drawable.LayerDrawable
|
||||
import android.net.Uri
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
@@ -25,10 +24,6 @@ import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -36,122 +31,26 @@ import org.yuzu.yuzu_emu.HomeNavigationDirections
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.YuzuApplication
|
||||
import org.yuzu.yuzu_emu.activities.EmulationActivity
|
||||
import org.yuzu.yuzu_emu.adapters.GameAdapter.GameViewHolder
|
||||
import org.yuzu.yuzu_emu.databinding.CardGameBinding
|
||||
import org.yuzu.yuzu_emu.model.Game
|
||||
import org.yuzu.yuzu_emu.model.GamesViewModel
|
||||
import org.yuzu.yuzu_emu.utils.GameIconUtils
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
|
||||
class GameAdapter(private val activity: AppCompatActivity) :
|
||||
ListAdapter<Game, GameViewHolder>(AsyncDifferConfig.Builder(DiffCallback()).build()),
|
||||
View.OnClickListener,
|
||||
View.OnLongClickListener {
|
||||
AbstractDiffAdapter<Game, GameAdapter.GameViewHolder>() {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GameViewHolder {
|
||||
// Create a new view.
|
||||
val binding = CardGameBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
binding.cardGame.setOnClickListener(this)
|
||||
binding.cardGame.setOnLongClickListener(this)
|
||||
|
||||
// Use that view to create a ViewHolder.
|
||||
return GameViewHolder(binding)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: GameViewHolder, position: Int) =
|
||||
holder.bind(currentList[position])
|
||||
|
||||
override fun getItemCount(): Int = currentList.size
|
||||
|
||||
/**
|
||||
* Launches the game that was clicked on.
|
||||
*
|
||||
* @param view The card representing the game the user wants to play.
|
||||
*/
|
||||
override fun onClick(view: View) {
|
||||
val holder = view.tag as GameViewHolder
|
||||
|
||||
val gameExists = DocumentFile.fromSingleUri(
|
||||
YuzuApplication.appContext,
|
||||
Uri.parse(holder.game.path)
|
||||
)?.exists() == true
|
||||
if (!gameExists) {
|
||||
Toast.makeText(
|
||||
YuzuApplication.appContext,
|
||||
R.string.loader_error_file_not_found,
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
|
||||
ViewModelProvider(activity)[GamesViewModel::class.java].reloadGames(true)
|
||||
return
|
||||
}
|
||||
|
||||
val preferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
||||
preferences.edit()
|
||||
.putLong(
|
||||
holder.game.keyLastPlayedTime,
|
||||
System.currentTimeMillis()
|
||||
)
|
||||
.apply()
|
||||
|
||||
val openIntent = Intent(YuzuApplication.appContext, EmulationActivity::class.java).apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
data = Uri.parse(holder.game.path)
|
||||
}
|
||||
|
||||
activity.lifecycleScope.launch {
|
||||
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, holder.game)
|
||||
.toDrawable(YuzuApplication.appContext.resources)
|
||||
)
|
||||
val inset = YuzuApplication.appContext.resources
|
||||
.getDimensionPixelSize(R.dimen.icon_inset)
|
||||
layerDrawable.setLayerInset(1, inset, inset, inset, inset)
|
||||
val shortcut =
|
||||
ShortcutInfoCompat.Builder(YuzuApplication.appContext, holder.game.path)
|
||||
.setShortLabel(holder.game.title)
|
||||
.setIcon(
|
||||
IconCompat.createWithAdaptiveBitmap(
|
||||
layerDrawable.toBitmap(config = Bitmap.Config.ARGB_8888)
|
||||
)
|
||||
)
|
||||
.setIntent(openIntent)
|
||||
.build()
|
||||
ShortcutManagerCompat.pushDynamicShortcut(YuzuApplication.appContext, shortcut)
|
||||
}
|
||||
}
|
||||
|
||||
val action = HomeNavigationDirections.actionGlobalEmulationActivity(holder.game, true)
|
||||
view.findNavController().navigate(action)
|
||||
}
|
||||
|
||||
override fun onLongClick(view: View): Boolean {
|
||||
val holder = view.tag as GameViewHolder
|
||||
val action = HomeNavigationDirections.actionGlobalPerGamePropertiesFragment(holder.game)
|
||||
view.findNavController().navigate(action)
|
||||
return true
|
||||
CardGameBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
.also { return GameViewHolder(it) }
|
||||
}
|
||||
|
||||
inner class GameViewHolder(val binding: CardGameBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
lateinit var game: Game
|
||||
|
||||
init {
|
||||
binding.cardGame.tag = this
|
||||
}
|
||||
|
||||
fun bind(game: Game) {
|
||||
this.game = game
|
||||
|
||||
AbstractViewHolder<Game>(binding) {
|
||||
override fun bind(model: Game) {
|
||||
binding.imageGameScreen.scaleType = ImageView.ScaleType.CENTER_CROP
|
||||
GameIconUtils.loadGameIcon(game, binding.imageGameScreen)
|
||||
GameIconUtils.loadGameIcon(model, binding.imageGameScreen)
|
||||
|
||||
binding.textGameTitle.text = game.title.replace("[\\t\\n\\r]+".toRegex(), " ")
|
||||
binding.textGameTitle.text = model.title.replace("[\\t\\n\\r]+".toRegex(), " ")
|
||||
|
||||
binding.textGameTitle.postDelayed(
|
||||
{
|
||||
@@ -160,16 +59,79 @@ class GameAdapter(private val activity: AppCompatActivity) :
|
||||
},
|
||||
3000
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private class DiffCallback : DiffUtil.ItemCallback<Game>() {
|
||||
override fun areItemsTheSame(oldItem: Game, newItem: Game): Boolean {
|
||||
return oldItem == newItem
|
||||
binding.cardGame.setOnClickListener { onClick(model) }
|
||||
binding.cardGame.setOnLongClickListener { onLongClick(model) }
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: Game, newItem: Game): Boolean {
|
||||
return oldItem == newItem
|
||||
fun onClick(game: Game) {
|
||||
val gameExists = DocumentFile.fromSingleUri(
|
||||
YuzuApplication.appContext,
|
||||
Uri.parse(game.path)
|
||||
)?.exists() == true
|
||||
if (!gameExists) {
|
||||
Toast.makeText(
|
||||
YuzuApplication.appContext,
|
||||
R.string.loader_error_file_not_found,
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
|
||||
ViewModelProvider(activity)[GamesViewModel::class.java].reloadGames(true)
|
||||
return
|
||||
}
|
||||
|
||||
val preferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
||||
preferences.edit()
|
||||
.putLong(
|
||||
game.keyLastPlayedTime,
|
||||
System.currentTimeMillis()
|
||||
)
|
||||
.apply()
|
||||
|
||||
val openIntent =
|
||||
Intent(YuzuApplication.appContext, EmulationActivity::class.java).apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
data = Uri.parse(game.path)
|
||||
}
|
||||
|
||||
activity.lifecycleScope.launch {
|
||||
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 =
|
||||
ShortcutInfoCompat.Builder(YuzuApplication.appContext, game.path)
|
||||
.setShortLabel(game.title)
|
||||
.setIcon(
|
||||
IconCompat.createWithAdaptiveBitmap(
|
||||
layerDrawable.toBitmap(config = Bitmap.Config.ARGB_8888)
|
||||
)
|
||||
)
|
||||
.setIntent(openIntent)
|
||||
.build()
|
||||
ShortcutManagerCompat.pushDynamicShortcut(YuzuApplication.appContext, shortcut)
|
||||
}
|
||||
}
|
||||
|
||||
val action = HomeNavigationDirections.actionGlobalEmulationActivity(game, true)
|
||||
binding.root.findNavController().navigate(action)
|
||||
}
|
||||
|
||||
fun onLongClick(game: Game): Boolean {
|
||||
val action = HomeNavigationDirections.actionGlobalPerGamePropertiesFragment(game)
|
||||
binding.root.findNavController().navigate(action)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,23 +12,22 @@ import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.coroutines.launch
|
||||
import org.yuzu.yuzu_emu.databinding.CardInstallableIconBinding
|
||||
import org.yuzu.yuzu_emu.databinding.CardSimpleOutlinedBinding
|
||||
import org.yuzu.yuzu_emu.model.GameProperty
|
||||
import org.yuzu.yuzu_emu.model.InstallableProperty
|
||||
import org.yuzu.yuzu_emu.model.SubmenuProperty
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
|
||||
class GamePropertiesAdapter(
|
||||
private val viewLifecycle: LifecycleOwner,
|
||||
private var properties: List<GameProperty>
|
||||
) :
|
||||
RecyclerView.Adapter<GamePropertiesAdapter.GamePropertyViewHolder>() {
|
||||
) : AbstractListAdapter<GameProperty, AbstractViewHolder<GameProperty>>(properties) {
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
): GamePropertyViewHolder {
|
||||
): AbstractViewHolder<GameProperty> {
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
return when (viewType) {
|
||||
PropertyType.Submenu.ordinal -> {
|
||||
@@ -51,11 +50,6 @@ class GamePropertiesAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = properties.size
|
||||
|
||||
override fun onBindViewHolder(holder: GamePropertyViewHolder, position: Int) =
|
||||
holder.bind(properties[position])
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return when (properties[position]) {
|
||||
is SubmenuProperty -> PropertyType.Submenu.ordinal
|
||||
@@ -63,14 +57,10 @@ class GamePropertiesAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
sealed class GamePropertyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
abstract fun bind(property: GameProperty)
|
||||
}
|
||||
|
||||
inner class SubmenuPropertyViewHolder(val binding: CardSimpleOutlinedBinding) :
|
||||
GamePropertyViewHolder(binding.root) {
|
||||
override fun bind(property: GameProperty) {
|
||||
val submenuProperty = property as SubmenuProperty
|
||||
AbstractViewHolder<GameProperty>(binding) {
|
||||
override fun bind(model: GameProperty) {
|
||||
val submenuProperty = model as SubmenuProperty
|
||||
|
||||
binding.root.setOnClickListener {
|
||||
submenuProperty.action.invoke()
|
||||
@@ -108,9 +98,9 @@ class GamePropertiesAdapter(
|
||||
}
|
||||
|
||||
inner class InstallablePropertyViewHolder(val binding: CardInstallableIconBinding) :
|
||||
GamePropertyViewHolder(binding.root) {
|
||||
override fun bind(property: GameProperty) {
|
||||
val installableProperty = property as InstallableProperty
|
||||
AbstractViewHolder<GameProperty>(binding) {
|
||||
override fun bind(model: GameProperty) {
|
||||
val installableProperty = model as InstallableProperty
|
||||
|
||||
binding.title.setText(installableProperty.titleId)
|
||||
binding.description.setText(installableProperty.descriptionId)
|
||||
|
||||
@@ -14,69 +14,37 @@ import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.coroutines.launch
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.databinding.CardHomeOptionBinding
|
||||
import org.yuzu.yuzu_emu.fragments.MessageDialogFragment
|
||||
import org.yuzu.yuzu_emu.model.HomeSetting
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
|
||||
class HomeSettingAdapter(
|
||||
private val activity: AppCompatActivity,
|
||||
private val viewLifecycle: LifecycleOwner,
|
||||
var options: List<HomeSetting>
|
||||
) :
|
||||
RecyclerView.Adapter<HomeSettingAdapter.HomeOptionViewHolder>(),
|
||||
View.OnClickListener {
|
||||
options: List<HomeSetting>
|
||||
) : AbstractListAdapter<HomeSetting, HomeSettingAdapter.HomeOptionViewHolder>(options) {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeOptionViewHolder {
|
||||
val binding =
|
||||
CardHomeOptionBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
binding.root.setOnClickListener(this)
|
||||
return HomeOptionViewHolder(binding)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return options.size
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: HomeOptionViewHolder, position: Int) {
|
||||
holder.bind(options[position])
|
||||
}
|
||||
|
||||
override fun onClick(view: View) {
|
||||
val holder = view.tag as HomeOptionViewHolder
|
||||
if (holder.option.isEnabled.invoke()) {
|
||||
holder.option.onClick.invoke()
|
||||
} else {
|
||||
MessageDialogFragment.newInstance(
|
||||
activity,
|
||||
titleId = holder.option.disabledTitleId,
|
||||
descriptionId = holder.option.disabledMessageId
|
||||
).show(activity.supportFragmentManager, MessageDialogFragment.TAG)
|
||||
}
|
||||
CardHomeOptionBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
.also { return HomeOptionViewHolder(it) }
|
||||
}
|
||||
|
||||
inner class HomeOptionViewHolder(val binding: CardHomeOptionBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
lateinit var option: HomeSetting
|
||||
|
||||
init {
|
||||
itemView.tag = this
|
||||
}
|
||||
|
||||
fun bind(option: HomeSetting) {
|
||||
this.option = option
|
||||
binding.optionTitle.text = activity.resources.getString(option.titleId)
|
||||
binding.optionDescription.text = activity.resources.getString(option.descriptionId)
|
||||
AbstractViewHolder<HomeSetting>(binding) {
|
||||
override fun bind(model: HomeSetting) {
|
||||
binding.optionTitle.text = activity.resources.getString(model.titleId)
|
||||
binding.optionDescription.text = activity.resources.getString(model.descriptionId)
|
||||
binding.optionIcon.setImageDrawable(
|
||||
ResourcesCompat.getDrawable(
|
||||
activity.resources,
|
||||
option.iconId,
|
||||
model.iconId,
|
||||
activity.theme
|
||||
)
|
||||
)
|
||||
|
||||
when (option.titleId) {
|
||||
when (model.titleId) {
|
||||
R.string.get_early_access ->
|
||||
binding.optionLayout.background =
|
||||
ContextCompat.getDrawable(
|
||||
@@ -85,7 +53,7 @@ class HomeSettingAdapter(
|
||||
)
|
||||
}
|
||||
|
||||
if (!option.isEnabled.invoke()) {
|
||||
if (!model.isEnabled.invoke()) {
|
||||
binding.optionTitle.alpha = 0.5f
|
||||
binding.optionDescription.alpha = 0.5f
|
||||
binding.optionIcon.alpha = 0.5f
|
||||
@@ -93,7 +61,7 @@ class HomeSettingAdapter(
|
||||
|
||||
viewLifecycle.lifecycleScope.launch {
|
||||
viewLifecycle.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||
option.details.collect { updateOptionDetails(it) }
|
||||
model.details.collect { updateOptionDetails(it) }
|
||||
}
|
||||
}
|
||||
binding.optionDetail.postDelayed(
|
||||
@@ -103,6 +71,20 @@ class HomeSettingAdapter(
|
||||
},
|
||||
3000
|
||||
)
|
||||
|
||||
binding.root.setOnClickListener { onClick(model) }
|
||||
}
|
||||
|
||||
private fun onClick(model: HomeSetting) {
|
||||
if (model.isEnabled.invoke()) {
|
||||
model.onClick.invoke()
|
||||
} else {
|
||||
MessageDialogFragment.newInstance(
|
||||
activity,
|
||||
titleId = model.disabledTitleId,
|
||||
descriptionId = model.disabledMessageId
|
||||
).show(activity.supportFragmentManager, MessageDialogFragment.TAG)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateOptionDetails(detailString: String) {
|
||||
|
||||
@@ -6,43 +6,33 @@ package org.yuzu.yuzu_emu.adapters
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.yuzu.yuzu_emu.databinding.CardInstallableBinding
|
||||
import org.yuzu.yuzu_emu.model.Installable
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
|
||||
class InstallableAdapter(private val installables: List<Installable>) :
|
||||
RecyclerView.Adapter<InstallableAdapter.InstallableViewHolder>() {
|
||||
class InstallableAdapter(installables: List<Installable>) :
|
||||
AbstractListAdapter<Installable, InstallableAdapter.InstallableViewHolder>(installables) {
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
): InstallableAdapter.InstallableViewHolder {
|
||||
val binding =
|
||||
CardInstallableBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return InstallableViewHolder(binding)
|
||||
CardInstallableBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
.also { return InstallableViewHolder(it) }
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = installables.size
|
||||
|
||||
override fun onBindViewHolder(holder: InstallableAdapter.InstallableViewHolder, position: Int) =
|
||||
holder.bind(installables[position])
|
||||
|
||||
inner class InstallableViewHolder(val binding: CardInstallableBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
lateinit var installable: Installable
|
||||
AbstractViewHolder<Installable>(binding) {
|
||||
override fun bind(model: Installable) {
|
||||
binding.title.setText(model.titleId)
|
||||
binding.description.setText(model.descriptionId)
|
||||
|
||||
fun bind(installable: Installable) {
|
||||
this.installable = installable
|
||||
|
||||
binding.title.setText(installable.titleId)
|
||||
binding.description.setText(installable.descriptionId)
|
||||
|
||||
if (installable.install != null) {
|
||||
if (model.install != null) {
|
||||
binding.buttonInstall.visibility = View.VISIBLE
|
||||
binding.buttonInstall.setOnClickListener { installable.install.invoke() }
|
||||
binding.buttonInstall.setOnClickListener { model.install.invoke() }
|
||||
}
|
||||
if (installable.export != null) {
|
||||
if (model.export != null) {
|
||||
binding.buttonExport.visibility = View.VISIBLE
|
||||
binding.buttonExport.setOnClickListener { installable.export.invoke() }
|
||||
binding.buttonExport.setOnClickListener { model.export.invoke() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,49 +7,33 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||
import org.yuzu.yuzu_emu.YuzuApplication
|
||||
import org.yuzu.yuzu_emu.databinding.ListItemSettingBinding
|
||||
import org.yuzu.yuzu_emu.fragments.LicenseBottomSheetDialogFragment
|
||||
import org.yuzu.yuzu_emu.model.License
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
|
||||
class LicenseAdapter(private val activity: AppCompatActivity, var licenses: List<License>) :
|
||||
RecyclerView.Adapter<LicenseAdapter.LicenseViewHolder>(),
|
||||
View.OnClickListener {
|
||||
class LicenseAdapter(private val activity: AppCompatActivity, licenses: List<License>) :
|
||||
AbstractListAdapter<License, LicenseAdapter.LicenseViewHolder>(licenses) {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LicenseViewHolder {
|
||||
val binding =
|
||||
ListItemSettingBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
binding.root.setOnClickListener(this)
|
||||
return LicenseViewHolder(binding)
|
||||
ListItemSettingBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
.also { return LicenseViewHolder(it) }
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = licenses.size
|
||||
inner class LicenseViewHolder(val binding: ListItemSettingBinding) :
|
||||
AbstractViewHolder<License>(binding) {
|
||||
override fun bind(model: License) {
|
||||
binding.apply {
|
||||
textSettingName.text = root.context.getString(model.titleId)
|
||||
textSettingDescription.text = root.context.getString(model.descriptionId)
|
||||
textSettingValue.visibility = View.GONE
|
||||
|
||||
override fun onBindViewHolder(holder: LicenseViewHolder, position: Int) {
|
||||
holder.bind(licenses[position])
|
||||
}
|
||||
|
||||
override fun onClick(view: View) {
|
||||
val license = (view.tag as LicenseViewHolder).license
|
||||
LicenseBottomSheetDialogFragment.newInstance(license)
|
||||
.show(activity.supportFragmentManager, LicenseBottomSheetDialogFragment.TAG)
|
||||
}
|
||||
|
||||
inner class LicenseViewHolder(val binding: ListItemSettingBinding) : ViewHolder(binding.root) {
|
||||
lateinit var license: License
|
||||
|
||||
init {
|
||||
itemView.tag = this
|
||||
root.setOnClickListener { onClick(model) }
|
||||
}
|
||||
}
|
||||
|
||||
fun bind(license: License) {
|
||||
this.license = license
|
||||
|
||||
val context = YuzuApplication.appContext
|
||||
binding.textSettingName.text = context.getString(license.titleId)
|
||||
binding.textSettingDescription.text = context.getString(license.descriptionId)
|
||||
binding.textSettingValue.visibility = View.GONE
|
||||
private fun onClick(license: License) {
|
||||
LicenseBottomSheetDialogFragment.newInstance(license)
|
||||
.show(activity.supportFragmentManager, LicenseBottomSheetDialogFragment.TAG)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import org.yuzu.yuzu_emu.databinding.PageSetupBinding
|
||||
import org.yuzu.yuzu_emu.model.HomeViewModel
|
||||
@@ -18,31 +17,19 @@ import org.yuzu.yuzu_emu.model.SetupCallback
|
||||
import org.yuzu.yuzu_emu.model.SetupPage
|
||||
import org.yuzu.yuzu_emu.model.StepState
|
||||
import org.yuzu.yuzu_emu.utils.ViewUtils
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
|
||||
class SetupAdapter(val activity: AppCompatActivity, val pages: List<SetupPage>) :
|
||||
RecyclerView.Adapter<SetupAdapter.SetupPageViewHolder>() {
|
||||
class SetupAdapter(val activity: AppCompatActivity, pages: List<SetupPage>) :
|
||||
AbstractListAdapter<SetupPage, SetupAdapter.SetupPageViewHolder>(pages) {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SetupPageViewHolder {
|
||||
val binding = PageSetupBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return SetupPageViewHolder(binding)
|
||||
PageSetupBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
.also { return SetupPageViewHolder(it) }
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = pages.size
|
||||
|
||||
override fun onBindViewHolder(holder: SetupPageViewHolder, position: Int) =
|
||||
holder.bind(pages[position])
|
||||
|
||||
inner class SetupPageViewHolder(val binding: PageSetupBinding) :
|
||||
RecyclerView.ViewHolder(binding.root), SetupCallback {
|
||||
lateinit var page: SetupPage
|
||||
|
||||
init {
|
||||
itemView.tag = this
|
||||
}
|
||||
|
||||
fun bind(page: SetupPage) {
|
||||
this.page = page
|
||||
|
||||
if (page.stepCompleted.invoke() == StepState.COMPLETE) {
|
||||
AbstractViewHolder<SetupPage>(binding), SetupCallback {
|
||||
override fun bind(model: SetupPage) {
|
||||
if (model.stepCompleted.invoke() == StepState.COMPLETE) {
|
||||
binding.buttonAction.visibility = View.INVISIBLE
|
||||
binding.textConfirmation.visibility = View.VISIBLE
|
||||
}
|
||||
@@ -50,31 +37,31 @@ class SetupAdapter(val activity: AppCompatActivity, val pages: List<SetupPage>)
|
||||
binding.icon.setImageDrawable(
|
||||
ResourcesCompat.getDrawable(
|
||||
activity.resources,
|
||||
page.iconId,
|
||||
model.iconId,
|
||||
activity.theme
|
||||
)
|
||||
)
|
||||
binding.textTitle.text = activity.resources.getString(page.titleId)
|
||||
binding.textTitle.text = activity.resources.getString(model.titleId)
|
||||
binding.textDescription.text =
|
||||
Html.fromHtml(activity.resources.getString(page.descriptionId), 0)
|
||||
Html.fromHtml(activity.resources.getString(model.descriptionId), 0)
|
||||
|
||||
binding.buttonAction.apply {
|
||||
text = activity.resources.getString(page.buttonTextId)
|
||||
if (page.buttonIconId != 0) {
|
||||
text = activity.resources.getString(model.buttonTextId)
|
||||
if (model.buttonIconId != 0) {
|
||||
icon = ResourcesCompat.getDrawable(
|
||||
activity.resources,
|
||||
page.buttonIconId,
|
||||
model.buttonIconId,
|
||||
activity.theme
|
||||
)
|
||||
}
|
||||
iconGravity =
|
||||
if (page.leftAlignedIcon) {
|
||||
if (model.leftAlignedIcon) {
|
||||
MaterialButton.ICON_GRAVITY_START
|
||||
} else {
|
||||
MaterialButton.ICON_GRAVITY_END
|
||||
}
|
||||
setOnClickListener {
|
||||
page.buttonAction.invoke(this@SetupPageViewHolder)
|
||||
model.buttonAction.invoke(this@SetupPageViewHolder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
package org.yuzu.yuzu_emu.fragments
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@@ -13,20 +14,26 @@ import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.updatePadding
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.adapters.DriverAdapter
|
||||
import org.yuzu.yuzu_emu.databinding.FragmentDriverManagerBinding
|
||||
import org.yuzu.yuzu_emu.features.settings.model.StringSetting
|
||||
import org.yuzu.yuzu_emu.model.Driver.Companion.toDriver
|
||||
import org.yuzu.yuzu_emu.model.DriverViewModel
|
||||
import org.yuzu.yuzu_emu.model.HomeViewModel
|
||||
import org.yuzu.yuzu_emu.utils.FileUtil
|
||||
import org.yuzu.yuzu_emu.utils.GpuDriverHelper
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
@@ -55,12 +62,43 @@ class DriverManagerFragment : Fragment() {
|
||||
return binding.root
|
||||
}
|
||||
|
||||
// This is using the correct scope, lint is just acting up
|
||||
@SuppressLint("UnsafeRepeatOnLifecycleDetector")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
homeViewModel.setNavigationVisibility(visible = false, animated = true)
|
||||
homeViewModel.setStatusBarShadeVisibility(visible = false)
|
||||
|
||||
driverViewModel.onOpenDriverManager(args.game)
|
||||
if (NativeConfig.isPerGameConfigLoaded()) {
|
||||
binding.toolbarDrivers.inflateMenu(R.menu.menu_driver_manager)
|
||||
driverViewModel.showClearButton(!StringSetting.DRIVER_PATH.global)
|
||||
binding.toolbarDrivers.setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.menu_driver_clear -> {
|
||||
StringSetting.DRIVER_PATH.global = true
|
||||
driverViewModel.updateDriverList()
|
||||
(binding.listDrivers.adapter as DriverAdapter)
|
||||
.replaceList(driverViewModel.driverList.value)
|
||||
driverViewModel.showClearButton(false)
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
viewLifecycleOwner.lifecycleScope.apply {
|
||||
launch {
|
||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
driverViewModel.showClearButton.collect {
|
||||
binding.toolbarDrivers.menu
|
||||
.findItem(R.id.menu_driver_clear).isVisible = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!driverViewModel.isInteractionAllowed.value) {
|
||||
DriversLoadingDialogFragment().show(
|
||||
@@ -85,25 +123,6 @@ class DriverManagerFragment : Fragment() {
|
||||
adapter = DriverAdapter(driverViewModel)
|
||||
}
|
||||
|
||||
viewLifecycleOwner.lifecycleScope.apply {
|
||||
launch {
|
||||
driverViewModel.driverList.collectLatest {
|
||||
(binding.listDrivers.adapter as DriverAdapter).submitList(it)
|
||||
}
|
||||
}
|
||||
launch {
|
||||
driverViewModel.newDriverInstalled.collect {
|
||||
if (_binding != null && it) {
|
||||
(binding.listDrivers.adapter as DriverAdapter).apply {
|
||||
notifyItemChanged(driverViewModel.previouslySelectedDriver)
|
||||
notifyItemChanged(driverViewModel.selectedDriver)
|
||||
driverViewModel.setNewDriverInstalled(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setInsets()
|
||||
}
|
||||
|
||||
@@ -160,7 +179,7 @@ class DriverManagerFragment : Fragment() {
|
||||
false
|
||||
) {
|
||||
val driverPath =
|
||||
"${GpuDriverHelper.driverStoragePath}/${FileUtil.getFilename(result)}"
|
||||
"${GpuDriverHelper.driverStoragePath}${FileUtil.getFilename(result)}"
|
||||
val driverFile = File(driverPath)
|
||||
|
||||
// Ignore file exceptions when a user selects an invalid zip
|
||||
@@ -177,12 +196,21 @@ class DriverManagerFragment : Fragment() {
|
||||
|
||||
val driverData = GpuDriverHelper.getMetadataFromZip(driverFile)
|
||||
val driverInList =
|
||||
driverViewModel.driverList.value.firstOrNull { it.second == driverData }
|
||||
driverViewModel.driverData.firstOrNull { it.second == driverData }
|
||||
if (driverInList != null) {
|
||||
return@newInstance getString(R.string.driver_already_installed)
|
||||
} else {
|
||||
driverViewModel.addDriver(Pair(driverPath, driverData))
|
||||
driverViewModel.setNewDriverInstalled(true)
|
||||
driverViewModel.onDriverAdded(Pair(driverPath, driverData))
|
||||
withContext(Dispatchers.Main) {
|
||||
if (_binding != null) {
|
||||
val adapter = binding.listDrivers.adapter as DriverAdapter
|
||||
adapter.addItem(driverData.toDriver())
|
||||
adapter.selectItem(adapter.currentList.indices.last)
|
||||
driverViewModel.showClearButton(!StringSetting.DRIVER_PATH.global)
|
||||
binding.listDrivers
|
||||
.smoothScrollToPosition(adapter.currentList.indices.last)
|
||||
}
|
||||
}
|
||||
}
|
||||
return@newInstance Any()
|
||||
}.show(childFragmentManager, IndeterminateProgressDialogFragment.TAG)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// SPDX-FileCopyrightText: 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.yuzu.yuzu_emu.model
|
||||
|
||||
import org.yuzu.yuzu_emu.utils.GpuDriverMetadata
|
||||
|
||||
data class Driver(
|
||||
override var selected: Boolean,
|
||||
val title: String,
|
||||
val version: String = "",
|
||||
val description: String = ""
|
||||
) : SelectableItem {
|
||||
override fun onSelectionStateChanged(selected: Boolean) {
|
||||
this.selected = selected
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun GpuDriverMetadata.toDriver(selected: Boolean = false): Driver =
|
||||
Driver(
|
||||
selected,
|
||||
this.name ?: "",
|
||||
this.version ?: "",
|
||||
this.description ?: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -17,11 +18,10 @@ import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.YuzuApplication
|
||||
import org.yuzu.yuzu_emu.features.settings.model.StringSetting
|
||||
import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile
|
||||
import org.yuzu.yuzu_emu.utils.FileUtil
|
||||
import org.yuzu.yuzu_emu.model.Driver.Companion.toDriver
|
||||
import org.yuzu.yuzu_emu.utils.GpuDriverHelper
|
||||
import org.yuzu.yuzu_emu.utils.GpuDriverMetadata
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
import java.io.BufferedOutputStream
|
||||
import java.io.File
|
||||
|
||||
class DriverViewModel : ViewModel() {
|
||||
@@ -38,97 +38,81 @@ class DriverViewModel : ViewModel() {
|
||||
!loading && ready && !deleting
|
||||
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), initialValue = false)
|
||||
|
||||
private val _driverList = MutableStateFlow(GpuDriverHelper.getDrivers())
|
||||
val driverList: StateFlow<MutableList<Pair<String, GpuDriverMetadata>>> get() = _driverList
|
||||
var driverData = GpuDriverHelper.getDrivers()
|
||||
|
||||
var previouslySelectedDriver = 0
|
||||
var selectedDriver = -1
|
||||
private val _driverList = MutableStateFlow(emptyList<Driver>())
|
||||
val driverList: StateFlow<List<Driver>> get() = _driverList
|
||||
|
||||
// Used for showing which driver is currently installed within the driver manager card
|
||||
private val _selectedDriverTitle = MutableStateFlow("")
|
||||
val selectedDriverTitle: StateFlow<String> get() = _selectedDriverTitle
|
||||
|
||||
private val _newDriverInstalled = MutableStateFlow(false)
|
||||
val newDriverInstalled: StateFlow<Boolean> get() = _newDriverInstalled
|
||||
private val _showClearButton = MutableStateFlow(false)
|
||||
val showClearButton = _showClearButton.asStateFlow()
|
||||
|
||||
val driversToDelete = mutableListOf<String>()
|
||||
private val driversToDelete = mutableListOf<String>()
|
||||
|
||||
init {
|
||||
val currentDriverMetadata = GpuDriverHelper.installedCustomDriverData
|
||||
findSelectedDriver(currentDriverMetadata)
|
||||
|
||||
// If a user had installed a driver before the manager was implemented, this zips
|
||||
// the installed driver to UserData/gpu_drivers/CustomDriver.zip so that it can
|
||||
// be indexed and exported as expected.
|
||||
if (selectedDriver == -1) {
|
||||
val driverToSave =
|
||||
File(GpuDriverHelper.driverStoragePath, "CustomDriver.zip")
|
||||
driverToSave.createNewFile()
|
||||
FileUtil.zipFromInternalStorage(
|
||||
File(GpuDriverHelper.driverInstallationPath!!),
|
||||
GpuDriverHelper.driverInstallationPath!!,
|
||||
BufferedOutputStream(driverToSave.outputStream())
|
||||
)
|
||||
_driverList.value.add(Pair(driverToSave.path, currentDriverMetadata))
|
||||
setSelectedDriverIndex(_driverList.value.size - 1)
|
||||
}
|
||||
|
||||
// If a user had installed a driver before the config was reworked to be multiplatform,
|
||||
// we have save the path of the previously selected driver to the new setting.
|
||||
if (StringSetting.DRIVER_PATH.getString(true).isEmpty() && selectedDriver > 0 &&
|
||||
StringSetting.DRIVER_PATH.global
|
||||
) {
|
||||
StringSetting.DRIVER_PATH.setString(_driverList.value[selectedDriver].first)
|
||||
NativeConfig.saveGlobalConfig()
|
||||
} else {
|
||||
findSelectedDriver(GpuDriverHelper.customDriverSettingData)
|
||||
}
|
||||
updateDriverList()
|
||||
updateDriverNameForGame(null)
|
||||
}
|
||||
|
||||
fun setSelectedDriverIndex(value: Int) {
|
||||
if (selectedDriver != -1) {
|
||||
previouslySelectedDriver = selectedDriver
|
||||
fun reloadDriverData() {
|
||||
_areDriversLoading.value = true
|
||||
driverData = GpuDriverHelper.getDrivers()
|
||||
updateDriverList()
|
||||
_areDriversLoading.value = false
|
||||
}
|
||||
|
||||
fun updateDriverList() {
|
||||
val selectedDriver = GpuDriverHelper.customDriverSettingData
|
||||
val newDriverList = mutableListOf(
|
||||
Driver(
|
||||
selectedDriver == GpuDriverMetadata(),
|
||||
YuzuApplication.appContext.getString(R.string.system_gpu_driver)
|
||||
)
|
||||
)
|
||||
driverData.forEach {
|
||||
newDriverList.add(it.second.toDriver(it.second == selectedDriver))
|
||||
}
|
||||
selectedDriver = value
|
||||
}
|
||||
|
||||
fun setNewDriverInstalled(value: Boolean) {
|
||||
_newDriverInstalled.value = value
|
||||
}
|
||||
|
||||
fun addDriver(driverData: Pair<String, GpuDriverMetadata>) {
|
||||
val driverIndex = _driverList.value.indexOfFirst { it == driverData }
|
||||
if (driverIndex == -1) {
|
||||
_driverList.value.add(driverData)
|
||||
setSelectedDriverIndex(_driverList.value.size - 1)
|
||||
_selectedDriverTitle.value = driverData.second.name
|
||||
?: YuzuApplication.appContext.getString(R.string.system_gpu_driver)
|
||||
} else {
|
||||
setSelectedDriverIndex(driverIndex)
|
||||
}
|
||||
}
|
||||
|
||||
fun removeDriver(driverData: Pair<String, GpuDriverMetadata>) {
|
||||
_driverList.value.remove(driverData)
|
||||
_driverList.value = newDriverList
|
||||
}
|
||||
|
||||
fun onOpenDriverManager(game: Game?) {
|
||||
if (game != null) {
|
||||
SettingsFile.loadCustomConfig(game)
|
||||
}
|
||||
updateDriverList()
|
||||
}
|
||||
|
||||
val driverPath = StringSetting.DRIVER_PATH.getString()
|
||||
if (driverPath.isEmpty()) {
|
||||
setSelectedDriverIndex(0)
|
||||
fun showClearButton(value: Boolean) {
|
||||
_showClearButton.value = value
|
||||
}
|
||||
|
||||
fun onDriverSelected(position: Int) {
|
||||
if (position == 0) {
|
||||
StringSetting.DRIVER_PATH.setString("")
|
||||
} else {
|
||||
findSelectedDriver(GpuDriverHelper.getMetadataFromZip(File(driverPath)))
|
||||
StringSetting.DRIVER_PATH.setString(driverData[position - 1].first)
|
||||
}
|
||||
}
|
||||
|
||||
fun onDriverRemoved(removedPosition: Int, selectedPosition: Int) {
|
||||
driversToDelete.add(driverData[removedPosition - 1].first)
|
||||
driverData.removeAt(removedPosition - 1)
|
||||
onDriverSelected(selectedPosition)
|
||||
}
|
||||
|
||||
fun onDriverAdded(driver: Pair<String, GpuDriverMetadata>) {
|
||||
if (driversToDelete.contains(driver.first)) {
|
||||
driversToDelete.remove(driver.first)
|
||||
}
|
||||
driverData.add(driver)
|
||||
onDriverSelected(driverData.size)
|
||||
}
|
||||
|
||||
fun onCloseDriverManager(game: Game?) {
|
||||
_isDeletingDrivers.value = true
|
||||
StringSetting.DRIVER_PATH.setString(driverList.value[selectedDriver].first)
|
||||
updateDriverNameForGame(game)
|
||||
if (game == null) {
|
||||
NativeConfig.saveGlobalConfig()
|
||||
@@ -181,20 +165,6 @@ class DriverViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun findSelectedDriver(currentDriverMetadata: GpuDriverMetadata) {
|
||||
if (driverList.value.size == 1) {
|
||||
setSelectedDriverIndex(0)
|
||||
return
|
||||
}
|
||||
|
||||
driverList.value.forEachIndexed { i: Int, driver: Pair<String, GpuDriverMetadata> ->
|
||||
if (driver.second == currentDriverMetadata) {
|
||||
setSelectedDriverIndex(i)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun updateDriverNameForGame(game: Game?) {
|
||||
if (!GpuDriverHelper.supportsCustomDriverLoading()) {
|
||||
return
|
||||
@@ -217,7 +187,6 @@ class DriverViewModel : ViewModel() {
|
||||
|
||||
private fun setDriverReady() {
|
||||
_isDriverReady.value = true
|
||||
_selectedDriverTitle.value = GpuDriverHelper.customDriverSettingData.name
|
||||
?: YuzuApplication.appContext.getString(R.string.system_gpu_driver)
|
||||
updateName()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// SPDX-FileCopyrightText: 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.yuzu.yuzu_emu.model
|
||||
|
||||
interface SelectableItem {
|
||||
var selected: Boolean
|
||||
fun onSelectionStateChanged(selected: Boolean)
|
||||
}
|
||||
@@ -41,6 +41,7 @@ import org.yuzu.yuzu_emu.fragments.AddGameFolderDialogFragment
|
||||
import org.yuzu.yuzu_emu.fragments.IndeterminateProgressDialogFragment
|
||||
import org.yuzu.yuzu_emu.fragments.MessageDialogFragment
|
||||
import org.yuzu.yuzu_emu.model.AddonViewModel
|
||||
import org.yuzu.yuzu_emu.model.DriverViewModel
|
||||
import org.yuzu.yuzu_emu.model.GamesViewModel
|
||||
import org.yuzu.yuzu_emu.model.HomeViewModel
|
||||
import org.yuzu.yuzu_emu.model.TaskState
|
||||
@@ -58,6 +59,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
||||
private val gamesViewModel: GamesViewModel by viewModels()
|
||||
private val taskViewModel: TaskViewModel by viewModels()
|
||||
private val addonViewModel: AddonViewModel by viewModels()
|
||||
private val driverViewModel: DriverViewModel by viewModels()
|
||||
|
||||
override var themeId: Int = 0
|
||||
|
||||
@@ -689,6 +691,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
||||
NativeLibrary.initializeSystem(true)
|
||||
NativeConfig.initializeGlobalConfig()
|
||||
gamesViewModel.reloadGames(false)
|
||||
driverViewModel.reloadDriverData()
|
||||
|
||||
return@newInstance getString(R.string.user_data_import_success)
|
||||
}.show(supportFragmentManager, IndeterminateProgressDialogFragment.TAG)
|
||||
|
||||
@@ -62,9 +62,6 @@ object GpuDriverHelper {
|
||||
?.sortedByDescending { it: Pair<String, GpuDriverMetadata> -> it.second.name }
|
||||
?.distinct()
|
||||
?.toMutableList() ?: mutableListOf()
|
||||
|
||||
// TODO: Get system driver information
|
||||
drivers.add(0, Pair("", GpuDriverMetadata()))
|
||||
return drivers
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// SPDX-FileCopyrightText: 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.yuzu.yuzu_emu.viewholder
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import org.yuzu.yuzu_emu.adapters.AbstractDiffAdapter
|
||||
import org.yuzu.yuzu_emu.adapters.AbstractListAdapter
|
||||
|
||||
/**
|
||||
* [RecyclerView.ViewHolder] meant to work together with a [AbstractDiffAdapter] or a
|
||||
* [AbstractListAdapter] so we can run [bind] on each list item without needing a manual hookup.
|
||||
*/
|
||||
abstract class AbstractViewHolder<Model>(binding: ViewBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
abstract fun bind(model: Model)
|
||||
}
|
||||
@@ -410,8 +410,8 @@ void EmulationSession::OnGamepadConnectEvent([[maybe_unused]] int index) {
|
||||
jauto handheld = m_system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||
|
||||
if (controller->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::Handheld) {
|
||||
handheld->SetNpadStyleIndex(Core::HID::NpadStyleIndex::ProController);
|
||||
controller->SetNpadStyleIndex(Core::HID::NpadStyleIndex::ProController);
|
||||
handheld->SetNpadStyleIndex(Core::HID::NpadStyleIndex::Fullkey);
|
||||
controller->SetNpadStyleIndex(Core::HID::NpadStyleIndex::Fullkey);
|
||||
handheld->Disconnect();
|
||||
}
|
||||
}
|
||||
@@ -770,8 +770,8 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeEmptyUserDirectory(JNIEnv*
|
||||
ASSERT(user_id);
|
||||
|
||||
const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath(
|
||||
EmulationSession::GetInstance().System(), vfs_nand_dir, FileSys::SaveDataSpaceId::NandUser,
|
||||
FileSys::SaveDataType::SaveData, 1, user_id->AsU128(), 0);
|
||||
{}, vfs_nand_dir, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, 1,
|
||||
user_id->AsU128(), 0);
|
||||
|
||||
const auto full_path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path);
|
||||
if (!Common::FS::CreateParentDirs(full_path)) {
|
||||
@@ -878,7 +878,7 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getSavePath(JNIEnv* env, jobject j
|
||||
FileSys::Mode::Read);
|
||||
|
||||
const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath(
|
||||
system, vfsNandDir, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData,
|
||||
{}, vfsNandDir, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData,
|
||||
program_id, user_id->AsU128(), 0);
|
||||
return ToJString(env, user_save_data_path);
|
||||
}
|
||||
|
||||
11
src/android/app/src/main/res/menu/menu_driver_manager.xml
Normal file
11
src/android/app/src/main/res/menu/menu_driver_manager.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_driver_clear"
|
||||
android:icon="@drawable/ic_clear"
|
||||
android:title="@string/clear"
|
||||
app:showAsAction="always" />
|
||||
|
||||
</menu>
|
||||
@@ -492,6 +492,10 @@ add_library(core STATIC
|
||||
hle/service/filesystem/fsp_pr.h
|
||||
hle/service/filesystem/fsp_srv.cpp
|
||||
hle/service/filesystem/fsp_srv.h
|
||||
hle/service/filesystem/romfs_controller.cpp
|
||||
hle/service/filesystem/romfs_controller.h
|
||||
hle/service/filesystem/save_data_controller.cpp
|
||||
hle/service/filesystem/save_data_controller.h
|
||||
hle/service/fgm/fgm.cpp
|
||||
hle/service/fgm/fgm.h
|
||||
hle/service/friend/friend.cpp
|
||||
@@ -712,24 +716,24 @@ add_library(core STATIC
|
||||
hle/service/server_manager.h
|
||||
hle/service/service.cpp
|
||||
hle/service/service.h
|
||||
hle/service/set/set.cpp
|
||||
hle/service/set/set.h
|
||||
hle/service/set/appln_settings.cpp
|
||||
hle/service/set/appln_settings.h
|
||||
hle/service/set/device_settings.cpp
|
||||
hle/service/set/device_settings.h
|
||||
hle/service/set/factory_settings_server.cpp
|
||||
hle/service/set/factory_settings_server.h
|
||||
hle/service/set/firmware_debug_settings_server.cpp
|
||||
hle/service/set/firmware_debug_settings_server.h
|
||||
hle/service/set/private_settings.cpp
|
||||
hle/service/set/private_settings.h
|
||||
hle/service/set/set_cal.cpp
|
||||
hle/service/set/set_cal.h
|
||||
hle/service/set/set_fd.cpp
|
||||
hle/service/set/set_fd.h
|
||||
hle/service/set/set_sys.cpp
|
||||
hle/service/set/set_sys.h
|
||||
hle/service/set/settings.cpp
|
||||
hle/service/set/settings.h
|
||||
hle/service/set/settings_server.cpp
|
||||
hle/service/set/settings_server.h
|
||||
hle/service/set/system_settings.cpp
|
||||
hle/service/set/system_settings.h
|
||||
hle/service/set/system_settings_server.cpp
|
||||
hle/service/set/system_settings_server.h
|
||||
hle/service/sm/sm.cpp
|
||||
hle/service/sm/sm.h
|
||||
hle/service/sm/sm_controller.cpp
|
||||
|
||||
@@ -414,6 +414,7 @@ struct System::Impl {
|
||||
kernel.ShutdownCores();
|
||||
services.reset();
|
||||
service_manager.reset();
|
||||
fs_controller.Reset();
|
||||
cheat_engine.reset();
|
||||
telemetry_session.reset();
|
||||
time_manager.Shutdown();
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
return [this] { ShutdownThreadFunction(); };
|
||||
}
|
||||
|
||||
void PreemptSingleCore(bool from_running_enviroment = true);
|
||||
void PreemptSingleCore(bool from_running_environment = true);
|
||||
|
||||
std::size_t CurrentCore() const {
|
||||
return current_core.load();
|
||||
|
||||
@@ -559,28 +559,28 @@ void GDBStub::HandleVCont(std::string_view command, std::vector<DebuggerAction>&
|
||||
}
|
||||
|
||||
constexpr std::array<std::pair<const char*, Kernel::Svc::MemoryState>, 22> MemoryStateNames{{
|
||||
{"----- Free -----", Kernel::Svc::MemoryState::Free},
|
||||
{"Io ", Kernel::Svc::MemoryState::Io},
|
||||
{"Static ", Kernel::Svc::MemoryState::Static},
|
||||
{"Code ", Kernel::Svc::MemoryState::Code},
|
||||
{"CodeData ", Kernel::Svc::MemoryState::CodeData},
|
||||
{"Normal ", Kernel::Svc::MemoryState::Normal},
|
||||
{"Shared ", Kernel::Svc::MemoryState::Shared},
|
||||
{"AliasCode ", Kernel::Svc::MemoryState::AliasCode},
|
||||
{"AliasCodeData ", Kernel::Svc::MemoryState::AliasCodeData},
|
||||
{"Ipc ", Kernel::Svc::MemoryState::Ipc},
|
||||
{"Stack ", Kernel::Svc::MemoryState::Stack},
|
||||
{"ThreadLocal ", Kernel::Svc::MemoryState::ThreadLocal},
|
||||
{"Transfered ", Kernel::Svc::MemoryState::Transfered},
|
||||
{"SharedTransfered", Kernel::Svc::MemoryState::SharedTransfered},
|
||||
{"SharedCode ", Kernel::Svc::MemoryState::SharedCode},
|
||||
{"Inaccessible ", Kernel::Svc::MemoryState::Inaccessible},
|
||||
{"NonSecureIpc ", Kernel::Svc::MemoryState::NonSecureIpc},
|
||||
{"NonDeviceIpc ", Kernel::Svc::MemoryState::NonDeviceIpc},
|
||||
{"Kernel ", Kernel::Svc::MemoryState::Kernel},
|
||||
{"GeneratedCode ", Kernel::Svc::MemoryState::GeneratedCode},
|
||||
{"CodeOut ", Kernel::Svc::MemoryState::CodeOut},
|
||||
{"Coverage ", Kernel::Svc::MemoryState::Coverage},
|
||||
{"----- Free ------", Kernel::Svc::MemoryState::Free},
|
||||
{"Io ", Kernel::Svc::MemoryState::Io},
|
||||
{"Static ", Kernel::Svc::MemoryState::Static},
|
||||
{"Code ", Kernel::Svc::MemoryState::Code},
|
||||
{"CodeData ", Kernel::Svc::MemoryState::CodeData},
|
||||
{"Normal ", Kernel::Svc::MemoryState::Normal},
|
||||
{"Shared ", Kernel::Svc::MemoryState::Shared},
|
||||
{"AliasCode ", Kernel::Svc::MemoryState::AliasCode},
|
||||
{"AliasCodeData ", Kernel::Svc::MemoryState::AliasCodeData},
|
||||
{"Ipc ", Kernel::Svc::MemoryState::Ipc},
|
||||
{"Stack ", Kernel::Svc::MemoryState::Stack},
|
||||
{"ThreadLocal ", Kernel::Svc::MemoryState::ThreadLocal},
|
||||
{"Transferred ", Kernel::Svc::MemoryState::Transferred},
|
||||
{"SharedTransferred", Kernel::Svc::MemoryState::SharedTransferred},
|
||||
{"SharedCode ", Kernel::Svc::MemoryState::SharedCode},
|
||||
{"Inaccessible ", Kernel::Svc::MemoryState::Inaccessible},
|
||||
{"NonSecureIpc ", Kernel::Svc::MemoryState::NonSecureIpc},
|
||||
{"NonDeviceIpc ", Kernel::Svc::MemoryState::NonDeviceIpc},
|
||||
{"Kernel ", Kernel::Svc::MemoryState::Kernel},
|
||||
{"GeneratedCode ", Kernel::Svc::MemoryState::GeneratedCode},
|
||||
{"CodeOut ", Kernel::Svc::MemoryState::CodeOut},
|
||||
{"Coverage ", Kernel::Svc::MemoryState::Coverage},
|
||||
}};
|
||||
|
||||
static constexpr const char* GetMemoryStateName(Kernel::Svc::MemoryState state) {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "core/file_sys/vfs_vector.h"
|
||||
#include "core/hle/service/filesystem/filesystem.h"
|
||||
#include "core/hle/service/ns/language.h"
|
||||
#include "core/hle/service/set/set.h"
|
||||
#include "core/hle/service/set/settings_server.h"
|
||||
#include "core/loader/loader.h"
|
||||
#include "core/loader/nso.h"
|
||||
#include "core/memory/cheat_engine.h"
|
||||
|
||||
@@ -97,8 +97,9 @@ std::string SaveDataAttribute::DebugInfo() const {
|
||||
static_cast<u8>(rank), index);
|
||||
}
|
||||
|
||||
SaveDataFactory::SaveDataFactory(Core::System& system_, VirtualDir save_directory_)
|
||||
: dir{std::move(save_directory_)}, system{system_} {
|
||||
SaveDataFactory::SaveDataFactory(Core::System& system_, ProgramId program_id_,
|
||||
VirtualDir save_directory_)
|
||||
: system{system_}, program_id{program_id_}, dir{std::move(save_directory_)} {
|
||||
// Delete all temporary storages
|
||||
// On hardware, it is expected that temporary storage be empty at first use.
|
||||
dir->DeleteSubdirectoryRecursive("temp");
|
||||
@@ -110,7 +111,7 @@ VirtualDir SaveDataFactory::Create(SaveDataSpaceId space, const SaveDataAttribut
|
||||
PrintSaveDataAttributeWarnings(meta);
|
||||
|
||||
const auto save_directory =
|
||||
GetFullPath(system, dir, space, meta.type, meta.title_id, meta.user_id, meta.save_id);
|
||||
GetFullPath(program_id, dir, space, meta.type, meta.title_id, meta.user_id, meta.save_id);
|
||||
|
||||
return dir->CreateDirectoryRelative(save_directory);
|
||||
}
|
||||
@@ -118,7 +119,7 @@ VirtualDir SaveDataFactory::Create(SaveDataSpaceId space, const SaveDataAttribut
|
||||
VirtualDir SaveDataFactory::Open(SaveDataSpaceId space, const SaveDataAttribute& meta) const {
|
||||
|
||||
const auto save_directory =
|
||||
GetFullPath(system, dir, space, meta.type, meta.title_id, meta.user_id, meta.save_id);
|
||||
GetFullPath(program_id, dir, space, meta.type, meta.title_id, meta.user_id, meta.save_id);
|
||||
|
||||
auto out = dir->GetDirectoryRelative(save_directory);
|
||||
|
||||
@@ -147,14 +148,14 @@ std::string SaveDataFactory::GetSaveDataSpaceIdPath(SaveDataSpaceId space) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string SaveDataFactory::GetFullPath(Core::System& system, VirtualDir dir,
|
||||
std::string SaveDataFactory::GetFullPath(ProgramId program_id, VirtualDir dir,
|
||||
SaveDataSpaceId space, SaveDataType type, u64 title_id,
|
||||
u128 user_id, u64 save_id) {
|
||||
// According to switchbrew, if a save is of type SaveData and the title id field is 0, it should
|
||||
// be interpreted as the title id of the current process.
|
||||
if (type == SaveDataType::SaveData || type == SaveDataType::DeviceSaveData) {
|
||||
if (title_id == 0) {
|
||||
title_id = system.GetApplicationProcessProgramID();
|
||||
title_id = program_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +202,7 @@ std::string SaveDataFactory::GetUserGameSaveDataRoot(u128 user_id, bool future)
|
||||
SaveDataSize SaveDataFactory::ReadSaveDataSize(SaveDataType type, u64 title_id,
|
||||
u128 user_id) const {
|
||||
const auto path =
|
||||
GetFullPath(system, dir, SaveDataSpaceId::NandUser, type, title_id, user_id, 0);
|
||||
GetFullPath(program_id, dir, SaveDataSpaceId::NandUser, type, title_id, user_id, 0);
|
||||
const auto relative_dir = GetOrCreateDirectoryRelative(dir, path);
|
||||
|
||||
const auto size_file = relative_dir->GetFile(GetSaveDataSizeFileName());
|
||||
@@ -220,7 +221,7 @@ SaveDataSize SaveDataFactory::ReadSaveDataSize(SaveDataType type, u64 title_id,
|
||||
void SaveDataFactory::WriteSaveDataSize(SaveDataType type, u64 title_id, u128 user_id,
|
||||
SaveDataSize new_value) const {
|
||||
const auto path =
|
||||
GetFullPath(system, dir, SaveDataSpaceId::NandUser, type, title_id, user_id, 0);
|
||||
GetFullPath(program_id, dir, SaveDataSpaceId::NandUser, type, title_id, user_id, 0);
|
||||
const auto relative_dir = GetOrCreateDirectoryRelative(dir, path);
|
||||
|
||||
const auto size_file = relative_dir->CreateFile(GetSaveDataSizeFileName());
|
||||
|
||||
@@ -87,10 +87,13 @@ constexpr const char* GetSaveDataSizeFileName() {
|
||||
return ".yuzu_save_size";
|
||||
}
|
||||
|
||||
using ProgramId = u64;
|
||||
|
||||
/// File system interface to the SaveData archive
|
||||
class SaveDataFactory {
|
||||
public:
|
||||
explicit SaveDataFactory(Core::System& system_, VirtualDir save_directory_);
|
||||
explicit SaveDataFactory(Core::System& system_, ProgramId program_id_,
|
||||
VirtualDir save_directory_);
|
||||
~SaveDataFactory();
|
||||
|
||||
VirtualDir Create(SaveDataSpaceId space, const SaveDataAttribute& meta) const;
|
||||
@@ -99,7 +102,7 @@ public:
|
||||
VirtualDir GetSaveDataSpaceDirectory(SaveDataSpaceId space) const;
|
||||
|
||||
static std::string GetSaveDataSpaceIdPath(SaveDataSpaceId space);
|
||||
static std::string GetFullPath(Core::System& system, VirtualDir dir, SaveDataSpaceId space,
|
||||
static std::string GetFullPath(ProgramId program_id, VirtualDir dir, SaveDataSpaceId space,
|
||||
SaveDataType type, u64 title_id, u128 user_id, u64 save_id);
|
||||
static std::string GetUserGameSaveDataRoot(u128 user_id, bool future);
|
||||
|
||||
@@ -110,8 +113,9 @@ public:
|
||||
void SetAutoCreate(bool state);
|
||||
|
||||
private:
|
||||
VirtualDir dir;
|
||||
Core::System& system;
|
||||
ProgramId program_id;
|
||||
VirtualDir dir;
|
||||
bool auto_create{true};
|
||||
};
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ void DefaultControllerApplet::ReconfigureControllers(ReconfigureCallback callbac
|
||||
// Connect controllers based on the following priority list from highest to lowest priority:
|
||||
// Pro Controller -> Dual Joycons -> Left Joycon/Right Joycon -> Handheld
|
||||
if (parameters.allow_pro_controller) {
|
||||
controller->SetNpadStyleIndex(Core::HID::NpadStyleIndex::ProController);
|
||||
controller->SetNpadStyleIndex(Core::HID::NpadStyleIndex::Fullkey);
|
||||
controller->Connect(true);
|
||||
} else if (parameters.allow_dual_joycons) {
|
||||
controller->SetNpadStyleIndex(Core::HID::NpadStyleIndex::JoyconDual);
|
||||
|
||||
@@ -81,12 +81,12 @@ enum class KMemoryState : u32 {
|
||||
|
||||
ThreadLocal = static_cast<u32>(Svc::MemoryState::ThreadLocal) | FlagLinearMapped,
|
||||
|
||||
Transfered = static_cast<u32>(Svc::MemoryState::Transfered) | FlagsMisc |
|
||||
FlagCanAlignedDeviceMap | FlagCanChangeAttribute | FlagCanUseIpc |
|
||||
FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
||||
Transferred = static_cast<u32>(Svc::MemoryState::Transferred) | FlagsMisc |
|
||||
FlagCanAlignedDeviceMap | FlagCanChangeAttribute | FlagCanUseIpc |
|
||||
FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
||||
|
||||
SharedTransfered = static_cast<u32>(Svc::MemoryState::SharedTransfered) | FlagsMisc |
|
||||
FlagCanAlignedDeviceMap | FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
||||
SharedTransferred = static_cast<u32>(Svc::MemoryState::SharedTransferred) | FlagsMisc |
|
||||
FlagCanAlignedDeviceMap | FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
||||
|
||||
SharedCode = static_cast<u32>(Svc::MemoryState::SharedCode) | FlagMapped |
|
||||
FlagReferenceCounted | FlagLinearMapped | FlagCanUseNonSecureIpc |
|
||||
@@ -130,8 +130,8 @@ static_assert(static_cast<u32>(KMemoryState::AliasCodeData) == 0x0FFFBD09);
|
||||
static_assert(static_cast<u32>(KMemoryState::Ipc) == 0x045C3C0A);
|
||||
static_assert(static_cast<u32>(KMemoryState::Stack) == 0x045C3C0B);
|
||||
static_assert(static_cast<u32>(KMemoryState::ThreadLocal) == 0x0400000C);
|
||||
static_assert(static_cast<u32>(KMemoryState::Transfered) == 0x055C3C0D);
|
||||
static_assert(static_cast<u32>(KMemoryState::SharedTransfered) == 0x045C380E);
|
||||
static_assert(static_cast<u32>(KMemoryState::Transferred) == 0x055C3C0D);
|
||||
static_assert(static_cast<u32>(KMemoryState::SharedTransferred) == 0x045C380E);
|
||||
static_assert(static_cast<u32>(KMemoryState::SharedCode) == 0x0440380F);
|
||||
static_assert(static_cast<u32>(KMemoryState::Inaccessible) == 0x00000010);
|
||||
static_assert(static_cast<u32>(KMemoryState::NonSecureIpc) == 0x045C3811);
|
||||
|
||||
@@ -486,8 +486,8 @@ KProcessAddress KPageTableBase::GetRegionAddress(Svc::MemoryState state) const {
|
||||
case Svc::MemoryState::Shared:
|
||||
case Svc::MemoryState::AliasCode:
|
||||
case Svc::MemoryState::AliasCodeData:
|
||||
case Svc::MemoryState::Transfered:
|
||||
case Svc::MemoryState::SharedTransfered:
|
||||
case Svc::MemoryState::Transferred:
|
||||
case Svc::MemoryState::SharedTransferred:
|
||||
case Svc::MemoryState::SharedCode:
|
||||
case Svc::MemoryState::GeneratedCode:
|
||||
case Svc::MemoryState::CodeOut:
|
||||
@@ -522,8 +522,8 @@ size_t KPageTableBase::GetRegionSize(Svc::MemoryState state) const {
|
||||
case Svc::MemoryState::Shared:
|
||||
case Svc::MemoryState::AliasCode:
|
||||
case Svc::MemoryState::AliasCodeData:
|
||||
case Svc::MemoryState::Transfered:
|
||||
case Svc::MemoryState::SharedTransfered:
|
||||
case Svc::MemoryState::Transferred:
|
||||
case Svc::MemoryState::SharedTransferred:
|
||||
case Svc::MemoryState::SharedCode:
|
||||
case Svc::MemoryState::GeneratedCode:
|
||||
case Svc::MemoryState::CodeOut:
|
||||
@@ -564,8 +564,8 @@ bool KPageTableBase::CanContain(KProcessAddress addr, size_t size, Svc::MemorySt
|
||||
case Svc::MemoryState::AliasCodeData:
|
||||
case Svc::MemoryState::Stack:
|
||||
case Svc::MemoryState::ThreadLocal:
|
||||
case Svc::MemoryState::Transfered:
|
||||
case Svc::MemoryState::SharedTransfered:
|
||||
case Svc::MemoryState::Transferred:
|
||||
case Svc::MemoryState::SharedTransferred:
|
||||
case Svc::MemoryState::SharedCode:
|
||||
case Svc::MemoryState::GeneratedCode:
|
||||
case Svc::MemoryState::CodeOut:
|
||||
|
||||
@@ -76,8 +76,8 @@ Result KTransferMemory::Map(KProcessAddress address, size_t size, Svc::MemoryPer
|
||||
|
||||
// Map the memory.
|
||||
const KMemoryState state = (m_owner_perm == Svc::MemoryPermission::None)
|
||||
? KMemoryState::Transfered
|
||||
: KMemoryState::SharedTransfered;
|
||||
? KMemoryState::Transferred
|
||||
: KMemoryState::SharedTransferred;
|
||||
R_TRY(GetCurrentProcess(m_kernel).GetPageTable().MapPageGroup(
|
||||
address, *m_page_group, state, KMemoryPermission::UserReadWrite));
|
||||
|
||||
@@ -96,8 +96,8 @@ Result KTransferMemory::Unmap(KProcessAddress address, size_t size) {
|
||||
|
||||
// Unmap the memory.
|
||||
const KMemoryState state = (m_owner_perm == Svc::MemoryPermission::None)
|
||||
? KMemoryState::Transfered
|
||||
: KMemoryState::SharedTransfered;
|
||||
? KMemoryState::Transferred
|
||||
: KMemoryState::SharedTransferred;
|
||||
R_TRY(GetCurrentProcess(m_kernel).GetPageTable().UnmapPageGroup(address, *m_page_group, state));
|
||||
|
||||
// Mark ourselves as unmapped.
|
||||
|
||||
@@ -90,7 +90,7 @@ Result MapTransferMemory(Core::System& system, Handle trmem_handle, uint64_t add
|
||||
// Verify that the mapping is in range.
|
||||
R_UNLESS(GetCurrentProcess(system.Kernel())
|
||||
.GetPageTable()
|
||||
.CanContain(address, size, KMemoryState::Transfered),
|
||||
.CanContain(address, size, KMemoryState::Transferred),
|
||||
ResultInvalidMemoryRegion);
|
||||
|
||||
// Map the transfer memory.
|
||||
@@ -117,7 +117,7 @@ Result UnmapTransferMemory(Core::System& system, Handle trmem_handle, uint64_t a
|
||||
// Verify that the mapping is in range.
|
||||
R_UNLESS(GetCurrentProcess(system.Kernel())
|
||||
.GetPageTable()
|
||||
.CanContain(address, size, KMemoryState::Transfered),
|
||||
.CanContain(address, size, KMemoryState::Transferred),
|
||||
ResultInvalidMemoryRegion);
|
||||
|
||||
// Unmap the transfer memory.
|
||||
|
||||
@@ -27,8 +27,8 @@ enum class MemoryState : u32 {
|
||||
Ipc = 0x0A,
|
||||
Stack = 0x0B,
|
||||
ThreadLocal = 0x0C,
|
||||
Transfered = 0x0D,
|
||||
SharedTransfered = 0x0E,
|
||||
Transferred = 0x0D,
|
||||
SharedTransferred = 0x0E,
|
||||
SharedCode = 0x0F,
|
||||
Inaccessible = 0x10,
|
||||
NonSecureIpc = 0x11,
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "core/hle/service/caps/caps_su.h"
|
||||
#include "core/hle/service/caps/caps_types.h"
|
||||
#include "core/hle/service/filesystem/filesystem.h"
|
||||
#include "core/hle/service/filesystem/save_data_controller.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/ns/ns.h"
|
||||
#include "core/hle/service/nvnflinger/fb_share_buffer_manager.h"
|
||||
@@ -2178,7 +2179,7 @@ void IApplicationFunctions::EnsureSaveData(HLERequestContext& ctx) {
|
||||
attribute.type = FileSys::SaveDataType::SaveData;
|
||||
|
||||
FileSys::VirtualDir save_data{};
|
||||
const auto res = system.GetFileSystemController().CreateSaveData(
|
||||
const auto res = system.GetFileSystemController().OpenSaveDataController()->CreateSaveData(
|
||||
&save_data, FileSys::SaveDataSpaceId::NandUser, attribute);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
@@ -2353,7 +2354,7 @@ void IApplicationFunctions::ExtendSaveData(HLERequestContext& ctx) {
|
||||
"new_journal={:016X}",
|
||||
static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size);
|
||||
|
||||
system.GetFileSystemController().WriteSaveDataSize(
|
||||
system.GetFileSystemController().OpenSaveDataController()->WriteSaveDataSize(
|
||||
type, system.GetApplicationProcessProgramID(), user_id,
|
||||
{new_normal_size, new_journal_size});
|
||||
|
||||
@@ -2378,7 +2379,7 @@ void IApplicationFunctions::GetSaveDataSize(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_AM, "called with type={:02X}, user_id={:016X}{:016X}", type, user_id[1],
|
||||
user_id[0]);
|
||||
|
||||
const auto size = system.GetFileSystemController().ReadSaveDataSize(
|
||||
const auto size = system.GetFileSystemController().OpenSaveDataController()->ReadSaveDataSize(
|
||||
type, system.GetApplicationProcessProgramID(), user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 6};
|
||||
|
||||
@@ -76,7 +76,7 @@ struct UiSettingsDisplayOptions {
|
||||
bool is_system_or_launcher;
|
||||
bool is_registration_permitted;
|
||||
bool show_skip_button;
|
||||
bool aditional_select;
|
||||
bool additional_select;
|
||||
bool show_user_selector;
|
||||
bool is_unqualified_user_selectable;
|
||||
};
|
||||
|
||||
@@ -85,7 +85,7 @@ Result AlbumManager::GetAlbumFileList(std::vector<AlbumEntry>& out_entries, Albu
|
||||
}
|
||||
|
||||
Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& out_entries,
|
||||
ContentType contex_type, s64 start_posix_time,
|
||||
ContentType content_type, s64 start_posix_time,
|
||||
s64 end_posix_time, u64 aruid) const {
|
||||
if (!is_mounted) {
|
||||
return ResultIsNotMounted;
|
||||
@@ -94,7 +94,7 @@ Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& ou
|
||||
std::vector<ApplicationAlbumEntry> album_entries;
|
||||
const auto start_date = ConvertToAlbumDateTime(start_posix_time);
|
||||
const auto end_date = ConvertToAlbumDateTime(end_posix_time);
|
||||
const auto result = GetAlbumFileList(album_entries, contex_type, start_date, end_date, aruid);
|
||||
const auto result = GetAlbumFileList(album_entries, content_type, start_date, end_date, aruid);
|
||||
|
||||
if (result.IsError()) {
|
||||
return result;
|
||||
@@ -113,14 +113,14 @@ Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& ou
|
||||
}
|
||||
|
||||
Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_entries,
|
||||
ContentType contex_type, AlbumFileDateTime start_date,
|
||||
ContentType content_type, AlbumFileDateTime start_date,
|
||||
AlbumFileDateTime end_date, u64 aruid) const {
|
||||
if (!is_mounted) {
|
||||
return ResultIsNotMounted;
|
||||
}
|
||||
|
||||
for (auto& [file_id, path] : album_files) {
|
||||
if (file_id.type != contex_type) {
|
||||
if (file_id.type != content_type) {
|
||||
continue;
|
||||
}
|
||||
if (file_id.date > start_date) {
|
||||
@@ -139,7 +139,7 @@ Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_en
|
||||
.hash{},
|
||||
.datetime = file_id.date,
|
||||
.storage = file_id.storage,
|
||||
.content = contex_type,
|
||||
.content = content_type,
|
||||
.unknown = 1,
|
||||
};
|
||||
out_entries.push_back(entry);
|
||||
|
||||
@@ -45,10 +45,10 @@ public:
|
||||
Result GetAlbumFileList(std::vector<AlbumEntry>& out_entries, AlbumStorage storage,
|
||||
u8 flags) const;
|
||||
Result GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& out_entries,
|
||||
ContentType contex_type, s64 start_posix_time, s64 end_posix_time,
|
||||
ContentType content_type, s64 start_posix_time, s64 end_posix_time,
|
||||
u64 aruid) const;
|
||||
Result GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_entries,
|
||||
ContentType contex_type, AlbumFileDateTime start_date,
|
||||
ContentType content_type, AlbumFileDateTime start_date,
|
||||
AlbumFileDateTime end_date, u64 aruid) const;
|
||||
Result GetAutoSavingStorage(bool& out_is_autosaving) const;
|
||||
Result LoadAlbumScreenShotImage(LoadAlbumScreenShotImageOutput& out_image_output,
|
||||
|
||||
@@ -12,7 +12,7 @@ constexpr Result ResultUnknown5(ErrorModule::Capture, 5);
|
||||
constexpr Result ResultUnknown6(ErrorModule::Capture, 6);
|
||||
constexpr Result ResultUnknown7(ErrorModule::Capture, 7);
|
||||
constexpr Result ResultOutOfRange(ErrorModule::Capture, 8);
|
||||
constexpr Result ResulInvalidTimestamp(ErrorModule::Capture, 12);
|
||||
constexpr Result ResultInvalidTimestamp(ErrorModule::Capture, 12);
|
||||
constexpr Result ResultInvalidStorage(ErrorModule::Capture, 13);
|
||||
constexpr Result ResultInvalidFileContents(ErrorModule::Capture, 14);
|
||||
constexpr Result ResultIsNotMounted(ErrorModule::Capture, 21);
|
||||
|
||||
@@ -24,15 +24,13 @@
|
||||
#include "core/hle/service/filesystem/fsp_ldr.h"
|
||||
#include "core/hle/service/filesystem/fsp_pr.h"
|
||||
#include "core/hle/service/filesystem/fsp_srv.h"
|
||||
#include "core/hle/service/filesystem/romfs_controller.h"
|
||||
#include "core/hle/service/filesystem/save_data_controller.h"
|
||||
#include "core/hle/service/server_manager.h"
|
||||
#include "core/loader/loader.h"
|
||||
|
||||
namespace Service::FileSystem {
|
||||
|
||||
// A default size for normal/journal save data size if application control metadata cannot be found.
|
||||
// This should be large enough to satisfy even the most extreme requirements (~4.2GB)
|
||||
constexpr u64 SUFFICIENT_SAVE_DATA_SIZE = 0xF0000000;
|
||||
|
||||
static FileSys::VirtualDir GetDirectoryRelativeWrapped(FileSys::VirtualDir base,
|
||||
std::string_view dir_name_) {
|
||||
std::string dir_name(Common::FS::SanitizePath(dir_name_));
|
||||
@@ -297,145 +295,65 @@ FileSystemController::FileSystemController(Core::System& system_) : system{syste
|
||||
|
||||
FileSystemController::~FileSystemController() = default;
|
||||
|
||||
Result FileSystemController::RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory) {
|
||||
romfs_factory = std::move(factory);
|
||||
LOG_DEBUG(Service_FS, "Registered RomFS");
|
||||
Result FileSystemController::RegisterProcess(
|
||||
ProcessId process_id, ProgramId program_id,
|
||||
std::shared_ptr<FileSys::RomFSFactory>&& romfs_factory) {
|
||||
std::scoped_lock lk{registration_lock};
|
||||
|
||||
registrations.emplace(process_id, Registration{
|
||||
.program_id = program_id,
|
||||
.romfs_factory = std::move(romfs_factory),
|
||||
.save_data_factory = CreateSaveDataFactory(program_id),
|
||||
});
|
||||
|
||||
LOG_DEBUG(Service_FS, "Registered for process {}", process_id);
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result FileSystemController::RegisterSaveData(std::unique_ptr<FileSys::SaveDataFactory>&& factory) {
|
||||
ASSERT_MSG(save_data_factory == nullptr, "Tried to register a second save data");
|
||||
save_data_factory = std::move(factory);
|
||||
LOG_DEBUG(Service_FS, "Registered save data");
|
||||
Result FileSystemController::OpenProcess(
|
||||
ProgramId* out_program_id, std::shared_ptr<SaveDataController>* out_save_data_controller,
|
||||
std::shared_ptr<RomFsController>* out_romfs_controller, ProcessId process_id) {
|
||||
std::scoped_lock lk{registration_lock};
|
||||
|
||||
const auto it = registrations.find(process_id);
|
||||
if (it == registrations.end()) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
}
|
||||
|
||||
*out_program_id = it->second.program_id;
|
||||
*out_save_data_controller =
|
||||
std::make_shared<SaveDataController>(system, it->second.save_data_factory);
|
||||
*out_romfs_controller =
|
||||
std::make_shared<RomFsController>(it->second.romfs_factory, it->second.program_id);
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result FileSystemController::RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory) {
|
||||
ASSERT_MSG(sdmc_factory == nullptr, "Tried to register a second SDMC");
|
||||
sdmc_factory = std::move(factory);
|
||||
LOG_DEBUG(Service_FS, "Registered SDMC");
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result FileSystemController::RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory) {
|
||||
ASSERT_MSG(bis_factory == nullptr, "Tried to register a second BIS");
|
||||
bis_factory = std::move(factory);
|
||||
LOG_DEBUG(Service_FS, "Registered BIS");
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
void FileSystemController::SetPackedUpdate(FileSys::VirtualFile update_raw) {
|
||||
void FileSystemController::SetPackedUpdate(ProcessId process_id, FileSys::VirtualFile update_raw) {
|
||||
LOG_TRACE(Service_FS, "Setting packed update for romfs");
|
||||
|
||||
if (romfs_factory == nullptr)
|
||||
std::scoped_lock lk{registration_lock};
|
||||
const auto it = registrations.find(process_id);
|
||||
if (it == registrations.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
romfs_factory->SetPackedUpdate(std::move(update_raw));
|
||||
it->second.romfs_factory->SetPackedUpdate(std::move(update_raw));
|
||||
}
|
||||
|
||||
FileSys::VirtualFile FileSystemController::OpenRomFSCurrentProcess() const {
|
||||
LOG_TRACE(Service_FS, "Opening RomFS for current process");
|
||||
|
||||
if (romfs_factory == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return romfs_factory->OpenCurrentProcess(system.GetApplicationProcessProgramID());
|
||||
std::shared_ptr<SaveDataController> FileSystemController::OpenSaveDataController() {
|
||||
return std::make_shared<SaveDataController>(system, CreateSaveDataFactory(ProgramId{}));
|
||||
}
|
||||
|
||||
FileSys::VirtualFile FileSystemController::OpenPatchedRomFS(u64 title_id,
|
||||
FileSys::ContentRecordType type) const {
|
||||
LOG_TRACE(Service_FS, "Opening patched RomFS for title_id={:016X}", title_id);
|
||||
std::shared_ptr<FileSys::SaveDataFactory> FileSystemController::CreateSaveDataFactory(
|
||||
ProgramId program_id) {
|
||||
using YuzuPath = Common::FS::YuzuPath;
|
||||
const auto rw_mode = FileSys::Mode::ReadWrite;
|
||||
|
||||
if (romfs_factory == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return romfs_factory->OpenPatchedRomFS(title_id, type);
|
||||
}
|
||||
|
||||
FileSys::VirtualFile FileSystemController::OpenPatchedRomFSWithProgramIndex(
|
||||
u64 title_id, u8 program_index, FileSys::ContentRecordType type) const {
|
||||
LOG_TRACE(Service_FS, "Opening patched RomFS for title_id={:016X}, program_index={}", title_id,
|
||||
program_index);
|
||||
|
||||
if (romfs_factory == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return romfs_factory->OpenPatchedRomFSWithProgramIndex(title_id, program_index, type);
|
||||
}
|
||||
|
||||
FileSys::VirtualFile FileSystemController::OpenRomFS(u64 title_id, FileSys::StorageId storage_id,
|
||||
FileSys::ContentRecordType type) const {
|
||||
LOG_TRACE(Service_FS, "Opening RomFS for title_id={:016X}, storage_id={:02X}, type={:02X}",
|
||||
title_id, storage_id, type);
|
||||
|
||||
if (romfs_factory == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return romfs_factory->Open(title_id, storage_id, type);
|
||||
}
|
||||
|
||||
std::shared_ptr<FileSys::NCA> FileSystemController::OpenBaseNca(
|
||||
u64 title_id, FileSys::StorageId storage_id, FileSys::ContentRecordType type) const {
|
||||
return romfs_factory->GetEntry(title_id, storage_id, type);
|
||||
}
|
||||
|
||||
Result FileSystemController::CreateSaveData(FileSys::VirtualDir* out_save_data,
|
||||
FileSys::SaveDataSpaceId space,
|
||||
const FileSys::SaveDataAttribute& save_struct) const {
|
||||
LOG_TRACE(Service_FS, "Creating Save Data for space_id={:01X}, save_struct={}", space,
|
||||
save_struct.DebugInfo());
|
||||
|
||||
if (save_data_factory == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
}
|
||||
|
||||
auto save_data = save_data_factory->Create(space, save_struct);
|
||||
if (save_data == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
}
|
||||
|
||||
*out_save_data = save_data;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result FileSystemController::OpenSaveData(FileSys::VirtualDir* out_save_data,
|
||||
FileSys::SaveDataSpaceId space,
|
||||
const FileSys::SaveDataAttribute& attribute) const {
|
||||
LOG_TRACE(Service_FS, "Opening Save Data for space_id={:01X}, save_struct={}", space,
|
||||
attribute.DebugInfo());
|
||||
|
||||
if (save_data_factory == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
}
|
||||
|
||||
auto save_data = save_data_factory->Open(space, attribute);
|
||||
if (save_data == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
}
|
||||
|
||||
*out_save_data = save_data;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result FileSystemController::OpenSaveDataSpace(FileSys::VirtualDir* out_save_data_space,
|
||||
FileSys::SaveDataSpaceId space) const {
|
||||
LOG_TRACE(Service_FS, "Opening Save Data Space for space_id={:01X}", space);
|
||||
|
||||
if (save_data_factory == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
}
|
||||
|
||||
auto save_data_space = save_data_factory->GetSaveDataSpaceDirectory(space);
|
||||
if (save_data_space == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
}
|
||||
|
||||
*out_save_data_space = save_data_space;
|
||||
return ResultSuccess;
|
||||
auto vfs = system.GetFilesystem();
|
||||
const auto nand_directory =
|
||||
vfs->OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::NANDDir), rw_mode);
|
||||
return std::make_shared<FileSys::SaveDataFactory>(system, program_id,
|
||||
std::move(nand_directory));
|
||||
}
|
||||
|
||||
Result FileSystemController::OpenSDMC(FileSys::VirtualDir* out_sdmc) const {
|
||||
@@ -540,48 +458,6 @@ u64 FileSystemController::GetTotalSpaceSize(FileSys::StorageId id) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
FileSys::SaveDataSize FileSystemController::ReadSaveDataSize(FileSys::SaveDataType type,
|
||||
u64 title_id, u128 user_id) const {
|
||||
if (save_data_factory == nullptr) {
|
||||
return {0, 0};
|
||||
}
|
||||
|
||||
const auto value = save_data_factory->ReadSaveDataSize(type, title_id, user_id);
|
||||
|
||||
if (value.normal == 0 && value.journal == 0) {
|
||||
FileSys::SaveDataSize new_size{SUFFICIENT_SAVE_DATA_SIZE, SUFFICIENT_SAVE_DATA_SIZE};
|
||||
|
||||
FileSys::NACP nacp;
|
||||
const auto res = system.GetAppLoader().ReadControlData(nacp);
|
||||
|
||||
if (res != Loader::ResultStatus::Success) {
|
||||
const FileSys::PatchManager pm{system.GetApplicationProcessProgramID(),
|
||||
system.GetFileSystemController(),
|
||||
system.GetContentProvider()};
|
||||
const auto metadata = pm.GetControlMetadata();
|
||||
const auto& nacp_unique = metadata.first;
|
||||
|
||||
if (nacp_unique != nullptr) {
|
||||
new_size = {nacp_unique->GetDefaultNormalSaveSize(),
|
||||
nacp_unique->GetDefaultJournalSaveSize()};
|
||||
}
|
||||
} else {
|
||||
new_size = {nacp.GetDefaultNormalSaveSize(), nacp.GetDefaultJournalSaveSize()};
|
||||
}
|
||||
|
||||
WriteSaveDataSize(type, title_id, user_id, new_size);
|
||||
return new_size;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void FileSystemController::WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id,
|
||||
FileSys::SaveDataSize new_value) const {
|
||||
if (save_data_factory != nullptr)
|
||||
save_data_factory->WriteSaveDataSize(type, title_id, user_id, new_value);
|
||||
}
|
||||
|
||||
void FileSystemController::SetGameCard(FileSys::VirtualFile file) {
|
||||
gamecard = std::make_unique<FileSys::XCI>(file);
|
||||
const auto dir = gamecard->ConcatenatedPseudoDirectory();
|
||||
@@ -801,14 +677,9 @@ FileSys::VirtualDir FileSystemController::GetBCATDirectory(u64 title_id) const {
|
||||
return bis_factory->GetBCATDirectory(title_id);
|
||||
}
|
||||
|
||||
void FileSystemController::SetAutoSaveDataCreation(bool enable) {
|
||||
save_data_factory->SetAutoCreate(enable);
|
||||
}
|
||||
|
||||
void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite) {
|
||||
if (overwrite) {
|
||||
bis_factory = nullptr;
|
||||
save_data_factory = nullptr;
|
||||
sdmc_factory = nullptr;
|
||||
}
|
||||
|
||||
@@ -836,11 +707,6 @@ void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool ove
|
||||
bis_factory->GetUserNANDContents());
|
||||
}
|
||||
|
||||
if (save_data_factory == nullptr) {
|
||||
save_data_factory =
|
||||
std::make_unique<FileSys::SaveDataFactory>(system, std::move(nand_directory));
|
||||
}
|
||||
|
||||
if (sdmc_factory == nullptr) {
|
||||
sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory),
|
||||
std::move(sd_load_directory));
|
||||
@@ -849,12 +715,19 @@ void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool ove
|
||||
}
|
||||
}
|
||||
|
||||
void FileSystemController::Reset() {
|
||||
std::scoped_lock lk{registration_lock};
|
||||
registrations.clear();
|
||||
}
|
||||
|
||||
void LoopProcess(Core::System& system) {
|
||||
auto server_manager = std::make_unique<ServerManager>(system);
|
||||
|
||||
const auto FileSystemProxyFactory = [&] { return std::make_shared<FSP_SRV>(system); };
|
||||
|
||||
server_manager->RegisterNamedService("fsp-ldr", std::make_shared<FSP_LDR>(system));
|
||||
server_manager->RegisterNamedService("fsp:pr", std::make_shared<FSP_PR>(system));
|
||||
server_manager->RegisterNamedService("fsp-srv", std::make_shared<FSP_SRV>(system));
|
||||
server_manager->RegisterNamedService("fsp-srv", std::move(FileSystemProxyFactory));
|
||||
ServerManager::RunServer(std::move(server_manager));
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ class ServiceManager;
|
||||
|
||||
namespace FileSystem {
|
||||
|
||||
class RomFsController;
|
||||
class SaveDataController;
|
||||
|
||||
enum class ContentStorageId : u32 {
|
||||
System,
|
||||
User,
|
||||
@@ -61,32 +64,24 @@ enum class OpenDirectoryMode : u64 {
|
||||
};
|
||||
DECLARE_ENUM_FLAG_OPERATORS(OpenDirectoryMode);
|
||||
|
||||
using ProcessId = u64;
|
||||
using ProgramId = u64;
|
||||
|
||||
class FileSystemController {
|
||||
public:
|
||||
explicit FileSystemController(Core::System& system_);
|
||||
~FileSystemController();
|
||||
|
||||
Result RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory);
|
||||
Result RegisterSaveData(std::unique_ptr<FileSys::SaveDataFactory>&& factory);
|
||||
Result RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory);
|
||||
Result RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory);
|
||||
Result RegisterProcess(ProcessId process_id, ProgramId program_id,
|
||||
std::shared_ptr<FileSys::RomFSFactory>&& factory);
|
||||
Result OpenProcess(ProgramId* out_program_id,
|
||||
std::shared_ptr<SaveDataController>* out_save_data_controller,
|
||||
std::shared_ptr<RomFsController>* out_romfs_controller,
|
||||
ProcessId process_id);
|
||||
void SetPackedUpdate(ProcessId process_id, FileSys::VirtualFile update_raw);
|
||||
|
||||
void SetPackedUpdate(FileSys::VirtualFile update_raw);
|
||||
FileSys::VirtualFile OpenRomFSCurrentProcess() const;
|
||||
FileSys::VirtualFile OpenPatchedRomFS(u64 title_id, FileSys::ContentRecordType type) const;
|
||||
FileSys::VirtualFile OpenPatchedRomFSWithProgramIndex(u64 title_id, u8 program_index,
|
||||
FileSys::ContentRecordType type) const;
|
||||
FileSys::VirtualFile OpenRomFS(u64 title_id, FileSys::StorageId storage_id,
|
||||
FileSys::ContentRecordType type) const;
|
||||
std::shared_ptr<FileSys::NCA> OpenBaseNca(u64 title_id, FileSys::StorageId storage_id,
|
||||
FileSys::ContentRecordType type) const;
|
||||
std::shared_ptr<SaveDataController> OpenSaveDataController();
|
||||
|
||||
Result CreateSaveData(FileSys::VirtualDir* out_save_data, FileSys::SaveDataSpaceId space,
|
||||
const FileSys::SaveDataAttribute& save_struct) const;
|
||||
Result OpenSaveData(FileSys::VirtualDir* out_save_data, FileSys::SaveDataSpaceId space,
|
||||
const FileSys::SaveDataAttribute& save_struct) const;
|
||||
Result OpenSaveDataSpace(FileSys::VirtualDir* out_save_data_space,
|
||||
FileSys::SaveDataSpaceId space) const;
|
||||
Result OpenSDMC(FileSys::VirtualDir* out_sdmc) const;
|
||||
Result OpenBISPartition(FileSys::VirtualDir* out_bis_partition,
|
||||
FileSys::BisPartitionId id) const;
|
||||
@@ -96,11 +91,6 @@ public:
|
||||
u64 GetFreeSpaceSize(FileSys::StorageId id) const;
|
||||
u64 GetTotalSpaceSize(FileSys::StorageId id) const;
|
||||
|
||||
FileSys::SaveDataSize ReadSaveDataSize(FileSys::SaveDataType type, u64 title_id,
|
||||
u128 user_id) const;
|
||||
void WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id,
|
||||
FileSys::SaveDataSize new_value) const;
|
||||
|
||||
void SetGameCard(FileSys::VirtualFile file);
|
||||
FileSys::XCI* GetGameCard() const;
|
||||
|
||||
@@ -133,15 +123,24 @@ public:
|
||||
|
||||
FileSys::VirtualDir GetBCATDirectory(u64 title_id) const;
|
||||
|
||||
void SetAutoSaveDataCreation(bool enable);
|
||||
|
||||
// Creates the SaveData, SDMC, and BIS Factories. Should be called once and before any function
|
||||
// above is called.
|
||||
void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite = true);
|
||||
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
std::unique_ptr<FileSys::RomFSFactory> romfs_factory;
|
||||
std::unique_ptr<FileSys::SaveDataFactory> save_data_factory;
|
||||
std::shared_ptr<FileSys::SaveDataFactory> CreateSaveDataFactory(ProgramId program_id);
|
||||
|
||||
struct Registration {
|
||||
ProgramId program_id;
|
||||
std::shared_ptr<FileSys::RomFSFactory> romfs_factory;
|
||||
std::shared_ptr<FileSys::SaveDataFactory> save_data_factory;
|
||||
};
|
||||
|
||||
std::mutex registration_lock;
|
||||
std::map<ProcessId, Registration> registrations;
|
||||
|
||||
std::unique_ptr<FileSys::SDMCFactory> sdmc_factory;
|
||||
std::unique_ptr<FileSys::BISFactory> bis_factory;
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/filesystem/filesystem.h"
|
||||
#include "core/hle/service/filesystem/fsp_srv.h"
|
||||
#include "core/hle/service/filesystem/romfs_controller.h"
|
||||
#include "core/hle/service/filesystem/save_data_controller.h"
|
||||
#include "core/hle/service/hle_ipc.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/reporter.h"
|
||||
@@ -577,9 +579,11 @@ private:
|
||||
|
||||
class ISaveDataInfoReader final : public ServiceFramework<ISaveDataInfoReader> {
|
||||
public:
|
||||
explicit ISaveDataInfoReader(Core::System& system_, FileSys::SaveDataSpaceId space,
|
||||
FileSystemController& fsc_)
|
||||
: ServiceFramework{system_, "ISaveDataInfoReader"}, fsc{fsc_} {
|
||||
explicit ISaveDataInfoReader(Core::System& system_,
|
||||
std::shared_ptr<SaveDataController> save_data_controller_,
|
||||
FileSys::SaveDataSpaceId space)
|
||||
: ServiceFramework{system_, "ISaveDataInfoReader"}, save_data_controller{
|
||||
save_data_controller_} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"},
|
||||
};
|
||||
@@ -626,7 +630,7 @@ private:
|
||||
|
||||
void FindAllSaves(FileSys::SaveDataSpaceId space) {
|
||||
FileSys::VirtualDir save_root{};
|
||||
const auto result = fsc.OpenSaveDataSpace(&save_root, space);
|
||||
const auto result = save_data_controller->OpenSaveDataSpace(&save_root, space);
|
||||
|
||||
if (result != ResultSuccess || save_root == nullptr) {
|
||||
LOG_ERROR(Service_FS, "The save root for the space_id={:02X} was invalid!", space);
|
||||
@@ -723,7 +727,8 @@ private:
|
||||
};
|
||||
static_assert(sizeof(SaveDataInfo) == 0x60, "SaveDataInfo has incorrect size.");
|
||||
|
||||
FileSystemController& fsc;
|
||||
ProcessId process_id = 0;
|
||||
std::shared_ptr<SaveDataController> save_data_controller;
|
||||
std::vector<SaveDataInfo> info;
|
||||
u64 next_entry_index = 0;
|
||||
};
|
||||
@@ -863,21 +868,20 @@ FSP_SRV::FSP_SRV(Core::System& system_)
|
||||
if (Settings::values.enable_fs_access_log) {
|
||||
access_log_mode = AccessLogMode::SdCard;
|
||||
}
|
||||
|
||||
// This should be true on creation
|
||||
fsc.SetAutoSaveDataCreation(true);
|
||||
}
|
||||
|
||||
FSP_SRV::~FSP_SRV() = default;
|
||||
|
||||
void FSP_SRV::SetCurrentProcess(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
current_process_id = rp.Pop<u64>();
|
||||
current_process_id = ctx.GetPID();
|
||||
|
||||
LOG_DEBUG(Service_FS, "called. current_process_id=0x{:016X}", current_process_id);
|
||||
|
||||
const auto res =
|
||||
fsc.OpenProcess(&program_id, &save_data_controller, &romfs_controller, current_process_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void FSP_SRV::OpenFileSystemWithPatch(HLERequestContext& ctx) {
|
||||
@@ -916,7 +920,8 @@ void FSP_SRV::CreateSaveDataFileSystem(HLERequestContext& ctx) {
|
||||
uid[1], uid[0]);
|
||||
|
||||
FileSys::VirtualDir save_data_dir{};
|
||||
fsc.CreateSaveData(&save_data_dir, FileSys::SaveDataSpaceId::NandUser, save_struct);
|
||||
save_data_controller->CreateSaveData(&save_data_dir, FileSys::SaveDataSpaceId::NandUser,
|
||||
save_struct);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -931,7 +936,8 @@ void FSP_SRV::CreateSaveDataFileSystemBySystemSaveDataId(HLERequestContext& ctx)
|
||||
LOG_DEBUG(Service_FS, "called save_struct = {}", save_struct.DebugInfo());
|
||||
|
||||
FileSys::VirtualDir save_data_dir{};
|
||||
fsc.CreateSaveData(&save_data_dir, FileSys::SaveDataSpaceId::NandSystem, save_struct);
|
||||
save_data_controller->CreateSaveData(&save_data_dir, FileSys::SaveDataSpaceId::NandSystem,
|
||||
save_struct);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -950,7 +956,8 @@ void FSP_SRV::OpenSaveDataFileSystem(HLERequestContext& ctx) {
|
||||
LOG_INFO(Service_FS, "called.");
|
||||
|
||||
FileSys::VirtualDir dir{};
|
||||
auto result = fsc.OpenSaveData(&dir, parameters.space_id, parameters.attribute);
|
||||
auto result =
|
||||
save_data_controller->OpenSaveData(&dir, parameters.space_id, parameters.attribute);
|
||||
if (result != ResultSuccess) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 0};
|
||||
rb.Push(FileSys::ERROR_ENTITY_NOT_FOUND);
|
||||
@@ -1001,7 +1008,7 @@ void FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId(HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<ISaveDataInfoReader>(
|
||||
std::make_shared<ISaveDataInfoReader>(system, space, fsc));
|
||||
std::make_shared<ISaveDataInfoReader>(system, save_data_controller, space));
|
||||
}
|
||||
|
||||
void FSP_SRV::OpenSaveDataInfoReaderOnlyCacheStorage(HLERequestContext& ctx) {
|
||||
@@ -1009,8 +1016,8 @@ void FSP_SRV::OpenSaveDataInfoReaderOnlyCacheStorage(HLERequestContext& ctx) {
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<ISaveDataInfoReader>(system, FileSys::SaveDataSpaceId::TemporaryStorage,
|
||||
fsc);
|
||||
rb.PushIpcInterface<ISaveDataInfoReader>(system, save_data_controller,
|
||||
FileSys::SaveDataSpaceId::TemporaryStorage);
|
||||
}
|
||||
|
||||
void FSP_SRV::WriteSaveDataFileSystemExtraDataBySaveDataAttribute(HLERequestContext& ctx) {
|
||||
@@ -1050,7 +1057,7 @@ void FSP_SRV::OpenDataStorageByCurrentProcess(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_FS, "called");
|
||||
|
||||
if (!romfs) {
|
||||
auto current_romfs = fsc.OpenRomFSCurrentProcess();
|
||||
auto current_romfs = romfs_controller->OpenRomFSCurrentProcess();
|
||||
if (!current_romfs) {
|
||||
// TODO (bunnei): Find the right error code to use here
|
||||
LOG_CRITICAL(Service_FS, "no file system interface available!");
|
||||
@@ -1078,7 +1085,7 @@ void FSP_SRV::OpenDataStorageByDataId(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_FS, "called with storage_id={:02X}, unknown={:08X}, title_id={:016X}",
|
||||
storage_id, unknown, title_id);
|
||||
|
||||
auto data = fsc.OpenRomFS(title_id, storage_id, FileSys::ContentRecordType::Data);
|
||||
auto data = romfs_controller->OpenRomFS(title_id, storage_id, FileSys::ContentRecordType::Data);
|
||||
|
||||
if (!data) {
|
||||
const auto archive = FileSys::SystemArchive::SynthesizeSystemArchive(title_id);
|
||||
@@ -1101,7 +1108,8 @@ void FSP_SRV::OpenDataStorageByDataId(HLERequestContext& ctx) {
|
||||
|
||||
const FileSys::PatchManager pm{title_id, fsc, content_provider};
|
||||
|
||||
auto base = fsc.OpenBaseNca(title_id, storage_id, FileSys::ContentRecordType::Data);
|
||||
auto base =
|
||||
romfs_controller->OpenBaseNca(title_id, storage_id, FileSys::ContentRecordType::Data);
|
||||
auto storage = std::make_shared<IStorage>(
|
||||
system, pm.PatchRomFS(base.get(), std::move(data), FileSys::ContentRecordType::Data));
|
||||
|
||||
@@ -1129,9 +1137,8 @@ void FSP_SRV::OpenDataStorageWithProgramIndex(HLERequestContext& ctx) {
|
||||
|
||||
LOG_DEBUG(Service_FS, "called, program_index={}", program_index);
|
||||
|
||||
auto patched_romfs =
|
||||
fsc.OpenPatchedRomFSWithProgramIndex(system.GetApplicationProcessProgramID(), program_index,
|
||||
FileSys::ContentRecordType::Program);
|
||||
auto patched_romfs = romfs_controller->OpenPatchedRomFSWithProgramIndex(
|
||||
program_id, program_index, FileSys::ContentRecordType::Program);
|
||||
|
||||
if (!patched_romfs) {
|
||||
// TODO: Find the right error code to use here
|
||||
@@ -1152,7 +1159,7 @@ void FSP_SRV::OpenDataStorageWithProgramIndex(HLERequestContext& ctx) {
|
||||
void FSP_SRV::DisableAutoSaveDataCreation(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_FS, "called");
|
||||
|
||||
fsc.SetAutoSaveDataCreation(false);
|
||||
save_data_controller->SetAutoCreate(false);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
|
||||
@@ -17,6 +17,9 @@ class FileSystemBackend;
|
||||
|
||||
namespace Service::FileSystem {
|
||||
|
||||
class RomFsController;
|
||||
class SaveDataController;
|
||||
|
||||
enum class AccessLogVersion : u32 {
|
||||
V7_0_0 = 2,
|
||||
|
||||
@@ -67,6 +70,9 @@ private:
|
||||
u64 current_process_id = 0;
|
||||
u32 access_log_program_index = 0;
|
||||
AccessLogMode access_log_mode = AccessLogMode::None;
|
||||
u64 program_id = 0;
|
||||
std::shared_ptr<SaveDataController> save_data_controller;
|
||||
std::shared_ptr<RomFsController> romfs_controller;
|
||||
};
|
||||
|
||||
} // namespace Service::FileSystem
|
||||
|
||||
37
src/core/hle/service/filesystem/romfs_controller.cpp
Normal file
37
src/core/hle/service/filesystem/romfs_controller.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/filesystem/romfs_controller.h"
|
||||
|
||||
namespace Service::FileSystem {
|
||||
|
||||
RomFsController::RomFsController(std::shared_ptr<FileSys::RomFSFactory> factory_, u64 program_id_)
|
||||
: factory{std::move(factory_)}, program_id{program_id_} {}
|
||||
RomFsController::~RomFsController() = default;
|
||||
|
||||
FileSys::VirtualFile RomFsController::OpenRomFSCurrentProcess() {
|
||||
return factory->OpenCurrentProcess(program_id);
|
||||
}
|
||||
|
||||
FileSys::VirtualFile RomFsController::OpenPatchedRomFS(u64 title_id,
|
||||
FileSys::ContentRecordType type) {
|
||||
return factory->OpenPatchedRomFS(title_id, type);
|
||||
}
|
||||
|
||||
FileSys::VirtualFile RomFsController::OpenPatchedRomFSWithProgramIndex(
|
||||
u64 title_id, u8 program_index, FileSys::ContentRecordType type) {
|
||||
return factory->OpenPatchedRomFSWithProgramIndex(title_id, program_index, type);
|
||||
}
|
||||
|
||||
FileSys::VirtualFile RomFsController::OpenRomFS(u64 title_id, FileSys::StorageId storage_id,
|
||||
FileSys::ContentRecordType type) {
|
||||
return factory->Open(title_id, storage_id, type);
|
||||
}
|
||||
|
||||
std::shared_ptr<FileSys::NCA> RomFsController::OpenBaseNca(u64 title_id,
|
||||
FileSys::StorageId storage_id,
|
||||
FileSys::ContentRecordType type) {
|
||||
return factory->GetEntry(title_id, storage_id, type);
|
||||
}
|
||||
|
||||
} // namespace Service::FileSystem
|
||||
31
src/core/hle/service/filesystem/romfs_controller.h
Normal file
31
src/core/hle/service/filesystem/romfs_controller.h
Normal file
@@ -0,0 +1,31 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/file_sys/nca_metadata.h"
|
||||
#include "core/file_sys/romfs_factory.h"
|
||||
#include "core/file_sys/vfs_types.h"
|
||||
|
||||
namespace Service::FileSystem {
|
||||
|
||||
class RomFsController {
|
||||
public:
|
||||
explicit RomFsController(std::shared_ptr<FileSys::RomFSFactory> factory_, u64 program_id_);
|
||||
~RomFsController();
|
||||
|
||||
FileSys::VirtualFile OpenRomFSCurrentProcess();
|
||||
FileSys::VirtualFile OpenPatchedRomFS(u64 title_id, FileSys::ContentRecordType type);
|
||||
FileSys::VirtualFile OpenPatchedRomFSWithProgramIndex(u64 title_id, u8 program_index,
|
||||
FileSys::ContentRecordType type);
|
||||
FileSys::VirtualFile OpenRomFS(u64 title_id, FileSys::StorageId storage_id,
|
||||
FileSys::ContentRecordType type);
|
||||
std::shared_ptr<FileSys::NCA> OpenBaseNca(u64 title_id, FileSys::StorageId storage_id,
|
||||
FileSys::ContentRecordType type);
|
||||
|
||||
private:
|
||||
const std::shared_ptr<FileSys::RomFSFactory> factory;
|
||||
const u64 program_id;
|
||||
};
|
||||
|
||||
} // namespace Service::FileSystem
|
||||
99
src/core/hle/service/filesystem/save_data_controller.cpp
Normal file
99
src/core/hle/service/filesystem/save_data_controller.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/core.h"
|
||||
#include "core/file_sys/control_metadata.h"
|
||||
#include "core/file_sys/errors.h"
|
||||
#include "core/file_sys/patch_manager.h"
|
||||
#include "core/hle/service/filesystem/save_data_controller.h"
|
||||
#include "core/loader/loader.h"
|
||||
|
||||
namespace Service::FileSystem {
|
||||
|
||||
namespace {
|
||||
|
||||
// A default size for normal/journal save data size if application control metadata cannot be found.
|
||||
// This should be large enough to satisfy even the most extreme requirements (~4.2GB)
|
||||
constexpr u64 SufficientSaveDataSize = 0xF0000000;
|
||||
|
||||
FileSys::SaveDataSize GetDefaultSaveDataSize(Core::System& system, u64 program_id) {
|
||||
const FileSys::PatchManager pm{program_id, system.GetFileSystemController(),
|
||||
system.GetContentProvider()};
|
||||
const auto metadata = pm.GetControlMetadata();
|
||||
const auto& nacp = metadata.first;
|
||||
|
||||
if (nacp != nullptr) {
|
||||
return {nacp->GetDefaultNormalSaveSize(), nacp->GetDefaultJournalSaveSize()};
|
||||
}
|
||||
|
||||
return {SufficientSaveDataSize, SufficientSaveDataSize};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
SaveDataController::SaveDataController(Core::System& system_,
|
||||
std::shared_ptr<FileSys::SaveDataFactory> factory_)
|
||||
: system{system_}, factory{std::move(factory_)} {}
|
||||
SaveDataController::~SaveDataController() = default;
|
||||
|
||||
Result SaveDataController::CreateSaveData(FileSys::VirtualDir* out_save_data,
|
||||
FileSys::SaveDataSpaceId space,
|
||||
const FileSys::SaveDataAttribute& attribute) {
|
||||
LOG_TRACE(Service_FS, "Creating Save Data for space_id={:01X}, save_struct={}", space,
|
||||
attribute.DebugInfo());
|
||||
|
||||
auto save_data = factory->Create(space, attribute);
|
||||
if (save_data == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
}
|
||||
|
||||
*out_save_data = save_data;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result SaveDataController::OpenSaveData(FileSys::VirtualDir* out_save_data,
|
||||
FileSys::SaveDataSpaceId space,
|
||||
const FileSys::SaveDataAttribute& attribute) {
|
||||
auto save_data = factory->Open(space, attribute);
|
||||
if (save_data == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
}
|
||||
|
||||
*out_save_data = save_data;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result SaveDataController::OpenSaveDataSpace(FileSys::VirtualDir* out_save_data_space,
|
||||
FileSys::SaveDataSpaceId space) {
|
||||
auto save_data_space = factory->GetSaveDataSpaceDirectory(space);
|
||||
if (save_data_space == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
}
|
||||
|
||||
*out_save_data_space = save_data_space;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
FileSys::SaveDataSize SaveDataController::ReadSaveDataSize(FileSys::SaveDataType type, u64 title_id,
|
||||
u128 user_id) {
|
||||
const auto value = factory->ReadSaveDataSize(type, title_id, user_id);
|
||||
|
||||
if (value.normal == 0 && value.journal == 0) {
|
||||
const auto size = GetDefaultSaveDataSize(system, title_id);
|
||||
factory->WriteSaveDataSize(type, title_id, user_id, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void SaveDataController::WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id,
|
||||
FileSys::SaveDataSize new_value) {
|
||||
factory->WriteSaveDataSize(type, title_id, user_id, new_value);
|
||||
}
|
||||
|
||||
void SaveDataController::SetAutoCreate(bool state) {
|
||||
factory->SetAutoCreate(state);
|
||||
}
|
||||
|
||||
} // namespace Service::FileSystem
|
||||
35
src/core/hle/service/filesystem/save_data_controller.h
Normal file
35
src/core/hle/service/filesystem/save_data_controller.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/file_sys/nca_metadata.h"
|
||||
#include "core/file_sys/savedata_factory.h"
|
||||
#include "core/file_sys/vfs_types.h"
|
||||
|
||||
namespace Service::FileSystem {
|
||||
|
||||
class SaveDataController {
|
||||
public:
|
||||
explicit SaveDataController(Core::System& system,
|
||||
std::shared_ptr<FileSys::SaveDataFactory> factory_);
|
||||
~SaveDataController();
|
||||
|
||||
Result CreateSaveData(FileSys::VirtualDir* out_save_data, FileSys::SaveDataSpaceId space,
|
||||
const FileSys::SaveDataAttribute& attribute);
|
||||
Result OpenSaveData(FileSys::VirtualDir* out_save_data, FileSys::SaveDataSpaceId space,
|
||||
const FileSys::SaveDataAttribute& attribute);
|
||||
Result OpenSaveDataSpace(FileSys::VirtualDir* out_save_data_space,
|
||||
FileSys::SaveDataSpaceId space);
|
||||
|
||||
FileSys::SaveDataSize ReadSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id);
|
||||
void WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id,
|
||||
FileSys::SaveDataSize new_value);
|
||||
void SetAutoCreate(bool state);
|
||||
|
||||
private:
|
||||
Core::System& system;
|
||||
const std::shared_ptr<FileSys::SaveDataFactory> factory;
|
||||
};
|
||||
|
||||
} // namespace Service::FileSystem
|
||||
@@ -131,7 +131,7 @@ private:
|
||||
u8 is_favorite;
|
||||
u8 same_app;
|
||||
u8 same_app_played;
|
||||
u8 arbitary_app_played;
|
||||
u8 arbitrary_app_played;
|
||||
u64 group_id;
|
||||
};
|
||||
static_assert(sizeof(SizedFriendFilter) == 0x10, "SizedFriendFilter is an invalid size");
|
||||
|
||||
@@ -18,23 +18,23 @@ namespace Service::HID {
|
||||
|
||||
void LoopProcess(Core::System& system) {
|
||||
auto server_manager = std::make_unique<ServerManager>(system);
|
||||
std::shared_ptr<ResourceManager> resouce_manager = std::make_shared<ResourceManager>(system);
|
||||
std::shared_ptr<ResourceManager> resource_manager = std::make_shared<ResourceManager>(system);
|
||||
std::shared_ptr<HidFirmwareSettings> firmware_settings =
|
||||
std::make_shared<HidFirmwareSettings>();
|
||||
|
||||
// TODO: Remove this hack until this service is emulated properly.
|
||||
const auto process_list = system.Kernel().GetProcessList();
|
||||
if (!process_list.empty()) {
|
||||
resouce_manager->Initialize();
|
||||
resouce_manager->RegisterAppletResourceUserId(process_list[0]->GetId(), true);
|
||||
resource_manager->Initialize();
|
||||
resource_manager->RegisterAppletResourceUserId(process_list[0]->GetId(), true);
|
||||
}
|
||||
|
||||
server_manager->RegisterNamedService(
|
||||
"hid", std::make_shared<IHidServer>(system, resouce_manager, firmware_settings));
|
||||
"hid", std::make_shared<IHidServer>(system, resource_manager, firmware_settings));
|
||||
server_manager->RegisterNamedService(
|
||||
"hid:dbg", std::make_shared<IHidDebugServer>(system, resouce_manager));
|
||||
"hid:dbg", std::make_shared<IHidDebugServer>(system, resource_manager));
|
||||
server_manager->RegisterNamedService(
|
||||
"hid:sys", std::make_shared<IHidSystemServer>(system, resouce_manager));
|
||||
"hid:sys", std::make_shared<IHidSystemServer>(system, resource_manager));
|
||||
|
||||
server_manager->RegisterNamedService("hidbus", std::make_shared<HidBus>(system));
|
||||
|
||||
|
||||
@@ -1444,8 +1444,8 @@ void IHidServer::SetNpadAnalogStickUseCenterClamp(HLERequestContext& ctx) {
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called, use_center_clamp={}, applet_resource_user_id={}",
|
||||
parameters.use_center_clamp, parameters.applet_resource_user_id);
|
||||
LOG_INFO(Service_HID, "called, use_center_clamp={}, applet_resource_user_id={}",
|
||||
parameters.use_center_clamp, parameters.applet_resource_user_id);
|
||||
|
||||
GetResourceManager()->GetNpad()->SetNpadAnalogStickUseCenterClamp(
|
||||
parameters.applet_resource_user_id, parameters.use_center_clamp);
|
||||
@@ -1466,23 +1466,27 @@ void IHidServer::SetNpadCaptureButtonAssignment(HLERequestContext& ctx) {
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
LOG_WARNING(Service_HID,
|
||||
"(STUBBED) called, npad_styleset={}, applet_resource_user_id={}, button={}",
|
||||
parameters.npad_styleset, parameters.applet_resource_user_id, parameters.button);
|
||||
LOG_INFO(Service_HID, "called, npad_styleset={}, applet_resource_user_id={}, button={}",
|
||||
parameters.npad_styleset, parameters.applet_resource_user_id, parameters.button);
|
||||
|
||||
const auto result = GetResourceManager()->GetNpad()->SetNpadCaptureButtonAssignment(
|
||||
parameters.applet_resource_user_id, parameters.npad_styleset, parameters.button);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void IHidServer::ClearNpadCaptureButtonAssignment(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}",
|
||||
applet_resource_user_id);
|
||||
LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
|
||||
|
||||
const auto result =
|
||||
GetResourceManager()->GetNpad()->ClearNpadCaptureButtonAssignment(applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void IHidServer::GetVibrationDeviceInfo(HLERequestContext& ctx) {
|
||||
@@ -1494,7 +1498,7 @@ void IHidServer::GetVibrationDeviceInfo(HLERequestContext& ctx) {
|
||||
bool check_device_index = false;
|
||||
|
||||
switch (vibration_device_handle.npad_type) {
|
||||
case Core::HID::NpadStyleIndex::ProController:
|
||||
case Core::HID::NpadStyleIndex::Fullkey:
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
|
||||
@@ -46,7 +46,7 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
|
||||
{310, &IHidSystemServer::GetMaskedSupportedNpadStyleSet, "GetMaskedSupportedNpadStyleSet"},
|
||||
{311, nullptr, "SetNpadPlayerLedBlinkingDevice"},
|
||||
{312, &IHidSystemServer::SetSupportedNpadStyleSetAll, "SetSupportedNpadStyleSetAll"},
|
||||
{313, nullptr, "GetNpadCaptureButtonAssignment"},
|
||||
{313, &IHidSystemServer::GetNpadCaptureButtonAssignment, "GetNpadCaptureButtonAssignment"},
|
||||
{314, nullptr, "GetAppletFooterUiType"},
|
||||
{315, &IHidSystemServer::GetAppletDetailedUiType, "GetAppletDetailedUiType"},
|
||||
{316, &IHidSystemServer::GetNpadInterfaceType, "GetNpadInterfaceType"},
|
||||
@@ -54,8 +54,8 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
|
||||
{318, &IHidSystemServer::HasBattery, "HasBattery"},
|
||||
{319, &IHidSystemServer::HasLeftRightBattery, "HasLeftRightBattery"},
|
||||
{321, &IHidSystemServer::GetUniquePadsFromNpad, "GetUniquePadsFromNpad"},
|
||||
{322, &IHidSystemServer::GetIrSensorState, "GetIrSensorState"},
|
||||
{323, nullptr, "GetXcdHandleForNpadWithIrSensor"},
|
||||
{322, &IHidSystemServer::SetNpadSystemExtStateEnabled, "SetNpadSystemExtStateEnabled"},
|
||||
{323, nullptr, "GetLastActiveUniquePad"},
|
||||
{324, nullptr, "GetUniquePadButtonSet"},
|
||||
{325, nullptr, "GetUniquePadColor"},
|
||||
{326, nullptr, "GetUniquePadAppletDetailedUiType"},
|
||||
@@ -251,25 +251,38 @@ void IHidSystemServer::ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) {
|
||||
}
|
||||
|
||||
void IHidSystemServer::EnableAssigningSingleOnSlSrPress(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
|
||||
|
||||
GetResourceManager()->GetNpad()->AssigningSingleOnSlSrPress(applet_resource_user_id, true);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::DisableAssigningSingleOnSlSrPress(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
|
||||
|
||||
GetResourceManager()->GetNpad()->AssigningSingleOnSlSrPress(applet_resource_user_id, false);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetLastActiveNpad(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_HID, "(STUBBED) called"); // Spams a lot when controller applet is running
|
||||
Core::HID::NpadIdType npad_id{};
|
||||
const Result result = GetResourceManager()->GetNpad()->GetLastActiveNpad(npad_id);
|
||||
|
||||
LOG_DEBUG(Service_HID, "called, npad_id={}", npad_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(0); // Dont forget to fix this
|
||||
rb.Push(result);
|
||||
rb.PushEnum(npad_id);
|
||||
}
|
||||
|
||||
void IHidSystemServer::ApplyNpadSystemCommonPolicyFull(HLERequestContext& ctx) {
|
||||
@@ -331,6 +344,27 @@ void IHidSystemServer::SetSupportedNpadStyleSetAll(HLERequestContext& ctx) {
|
||||
rb.Push(result);
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetNpadCaptureButtonAssignment(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
const auto capture_button_list_size{ctx.GetWriteBufferNumElements<Core::HID::NpadButton>()};
|
||||
|
||||
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
|
||||
|
||||
std::vector<Core::HID::NpadButton> capture_button_list(capture_button_list_size);
|
||||
const auto& npad = GetResourceManager()->GetNpad();
|
||||
const u64 list_size =
|
||||
npad->GetNpadCaptureButtonAssignment(capture_button_list, applet_resource_user_id);
|
||||
|
||||
if (list_size != 0) {
|
||||
ctx.WriteBuffer(capture_button_list);
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(list_size);
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetAppletDetailedUiType(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
|
||||
@@ -423,13 +457,25 @@ void IHidSystemServer::GetUniquePadsFromNpad(HLERequestContext& ctx) {
|
||||
rb.Push(static_cast<u32>(unique_pads.size()));
|
||||
}
|
||||
|
||||
void IHidSystemServer::GetIrSensorState(HLERequestContext& ctx) {
|
||||
void IHidSystemServer::SetNpadSystemExtStateEnabled(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
bool is_enabled;
|
||||
INSERT_PADDING_BYTES_NOINIT(7);
|
||||
u64 applet_resource_user_id;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
|
||||
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
LOG_INFO(Service_HID, "called, is_enabled={}, applet_resource_user_id={}",
|
||||
parameters.is_enabled, parameters.applet_resource_user_id);
|
||||
|
||||
const auto result = GetResourceManager()->GetNpad()->SetNpadSystemExtStateEnabled(
|
||||
parameters.applet_resource_user_id, parameters.is_enabled);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(result);
|
||||
}
|
||||
void IHidSystemServer::RegisterAppletResourceUserId(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
|
||||
@@ -31,13 +31,14 @@ private:
|
||||
void GetNpadFullKeyGripColor(HLERequestContext& ctx);
|
||||
void GetMaskedSupportedNpadStyleSet(HLERequestContext& ctx);
|
||||
void SetSupportedNpadStyleSetAll(HLERequestContext& ctx);
|
||||
void GetNpadCaptureButtonAssignment(HLERequestContext& ctx);
|
||||
void GetAppletDetailedUiType(HLERequestContext& ctx);
|
||||
void GetNpadInterfaceType(HLERequestContext& ctx);
|
||||
void GetNpadLeftRightInterfaceType(HLERequestContext& ctx);
|
||||
void HasBattery(HLERequestContext& ctx);
|
||||
void HasLeftRightBattery(HLERequestContext& ctx);
|
||||
void GetUniquePadsFromNpad(HLERequestContext& ctx);
|
||||
void GetIrSensorState(HLERequestContext& ctx);
|
||||
void SetNpadSystemExtStateEnabled(HLERequestContext& ctx);
|
||||
void RegisterAppletResourceUserId(HLERequestContext& ctx);
|
||||
void UnregisterAppletResourceUserId(HLERequestContext& ctx);
|
||||
void EnableAppletToGetInput(HLERequestContext& ctx);
|
||||
|
||||
@@ -67,7 +67,7 @@ HidBus::~HidBus() {
|
||||
void HidBus::UpdateHidbus(std::chrono::nanoseconds ns_late) {
|
||||
if (is_hidbus_enabled) {
|
||||
for (std::size_t i = 0; i < devices.size(); ++i) {
|
||||
if (!devices[i].is_device_initializated) {
|
||||
if (!devices[i].is_device_initialized) {
|
||||
continue;
|
||||
}
|
||||
auto& device = devices[i].device;
|
||||
@@ -213,7 +213,7 @@ void HidBus::Initialize(HLERequestContext& ctx) {
|
||||
|
||||
if (bus_handle_.internal_index == 0 && Settings::values.enable_ring_controller) {
|
||||
MakeDevice<RingController>(bus_handle_);
|
||||
devices[device_index.value()].is_device_initializated = true;
|
||||
devices[device_index.value()].is_device_initialized = true;
|
||||
devices[device_index.value()].device->ActivateDevice();
|
||||
cur_entry.is_in_focus = true;
|
||||
cur_entry.is_connected = true;
|
||||
@@ -222,7 +222,7 @@ void HidBus::Initialize(HLERequestContext& ctx) {
|
||||
cur_entry.is_polling_mode = false;
|
||||
} else {
|
||||
MakeDevice<HidbusStubbed>(bus_handle_);
|
||||
devices[device_index.value()].is_device_initializated = true;
|
||||
devices[device_index.value()].is_device_initialized = true;
|
||||
cur_entry.is_in_focus = true;
|
||||
cur_entry.is_connected = false;
|
||||
cur_entry.is_connected_result = ResultSuccess;
|
||||
@@ -261,7 +261,7 @@ void HidBus::Finalize(HLERequestContext& ctx) {
|
||||
const auto entry_index = devices[device_index.value()].handle.internal_index;
|
||||
auto& cur_entry = hidbus_status.entries[entry_index];
|
||||
auto& device = devices[device_index.value()].device;
|
||||
devices[device_index.value()].is_device_initializated = false;
|
||||
devices[device_index.value()].is_device_initialized = false;
|
||||
device->DeactivateDevice();
|
||||
|
||||
cur_entry.is_in_focus = true;
|
||||
|
||||
@@ -89,7 +89,7 @@ private:
|
||||
static_assert(sizeof(HidbusStatusManager) <= 0x1000, "HidbusStatusManager is an invalid size");
|
||||
|
||||
struct HidbusDevice {
|
||||
bool is_device_initializated{};
|
||||
bool is_device_initialized{};
|
||||
BusHandle handle{};
|
||||
std::unique_ptr<HidbusBase> device{nullptr};
|
||||
};
|
||||
|
||||
@@ -182,22 +182,22 @@ void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming) {
|
||||
}
|
||||
}
|
||||
|
||||
buffer_x_desciptors.reserve(command_header->num_buf_x_descriptors);
|
||||
buffer_a_desciptors.reserve(command_header->num_buf_a_descriptors);
|
||||
buffer_b_desciptors.reserve(command_header->num_buf_b_descriptors);
|
||||
buffer_w_desciptors.reserve(command_header->num_buf_w_descriptors);
|
||||
buffer_x_descriptors.reserve(command_header->num_buf_x_descriptors);
|
||||
buffer_a_descriptors.reserve(command_header->num_buf_a_descriptors);
|
||||
buffer_b_descriptors.reserve(command_header->num_buf_b_descriptors);
|
||||
buffer_w_descriptors.reserve(command_header->num_buf_w_descriptors);
|
||||
|
||||
for (u32 i = 0; i < command_header->num_buf_x_descriptors; ++i) {
|
||||
buffer_x_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorX>());
|
||||
buffer_x_descriptors.push_back(rp.PopRaw<IPC::BufferDescriptorX>());
|
||||
}
|
||||
for (u32 i = 0; i < command_header->num_buf_a_descriptors; ++i) {
|
||||
buffer_a_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorABW>());
|
||||
buffer_a_descriptors.push_back(rp.PopRaw<IPC::BufferDescriptorABW>());
|
||||
}
|
||||
for (u32 i = 0; i < command_header->num_buf_b_descriptors; ++i) {
|
||||
buffer_b_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorABW>());
|
||||
buffer_b_descriptors.push_back(rp.PopRaw<IPC::BufferDescriptorABW>());
|
||||
}
|
||||
for (u32 i = 0; i < command_header->num_buf_w_descriptors; ++i) {
|
||||
buffer_w_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorABW>());
|
||||
buffer_w_descriptors.push_back(rp.PopRaw<IPC::BufferDescriptorABW>());
|
||||
}
|
||||
|
||||
const auto buffer_c_offset = rp.GetCurrentOffset() + command_header->data_size;
|
||||
@@ -247,7 +247,7 @@ void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming) {
|
||||
IPC::CommandHeader::BufferDescriptorCFlag::InlineDescriptor) {
|
||||
if (command_header->buf_c_descriptor_flags ==
|
||||
IPC::CommandHeader::BufferDescriptorCFlag::OneDescriptor) {
|
||||
buffer_c_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorC>());
|
||||
buffer_c_descriptors.push_back(rp.PopRaw<IPC::BufferDescriptorC>());
|
||||
} else {
|
||||
u32 num_buf_c_descriptors =
|
||||
static_cast<u32>(command_header->buf_c_descriptor_flags.Value()) - 2;
|
||||
@@ -257,7 +257,7 @@ void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming) {
|
||||
ASSERT(num_buf_c_descriptors < 14);
|
||||
|
||||
for (u32 i = 0; i < num_buf_c_descriptors; ++i) {
|
||||
buffer_c_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorC>());
|
||||
buffer_c_descriptors.push_back(rp.PopRaw<IPC::BufferDescriptorC>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,19 +234,19 @@ public:
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::vector<IPC::BufferDescriptorX>& BufferDescriptorX() const {
|
||||
return buffer_x_desciptors;
|
||||
return buffer_x_descriptors;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::vector<IPC::BufferDescriptorABW>& BufferDescriptorA() const {
|
||||
return buffer_a_desciptors;
|
||||
return buffer_a_descriptors;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::vector<IPC::BufferDescriptorABW>& BufferDescriptorB() const {
|
||||
return buffer_b_desciptors;
|
||||
return buffer_b_descriptors;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::vector<IPC::BufferDescriptorC>& BufferDescriptorC() const {
|
||||
return buffer_c_desciptors;
|
||||
return buffer_c_descriptors;
|
||||
}
|
||||
|
||||
[[nodiscard]] const IPC::DomainMessageHeader& GetDomainMessageHeader() const {
|
||||
@@ -408,11 +408,11 @@ private:
|
||||
std::optional<IPC::HandleDescriptorHeader> handle_descriptor_header;
|
||||
std::optional<IPC::DataPayloadHeader> data_payload_header;
|
||||
std::optional<IPC::DomainMessageHeader> domain_message_header;
|
||||
std::vector<IPC::BufferDescriptorX> buffer_x_desciptors;
|
||||
std::vector<IPC::BufferDescriptorABW> buffer_a_desciptors;
|
||||
std::vector<IPC::BufferDescriptorABW> buffer_b_desciptors;
|
||||
std::vector<IPC::BufferDescriptorABW> buffer_w_desciptors;
|
||||
std::vector<IPC::BufferDescriptorC> buffer_c_desciptors;
|
||||
std::vector<IPC::BufferDescriptorX> buffer_x_descriptors;
|
||||
std::vector<IPC::BufferDescriptorABW> buffer_a_descriptors;
|
||||
std::vector<IPC::BufferDescriptorABW> buffer_b_descriptors;
|
||||
std::vector<IPC::BufferDescriptorABW> buffer_w_descriptors;
|
||||
std::vector<IPC::BufferDescriptorC> buffer_c_descriptors;
|
||||
|
||||
u32_le command{};
|
||||
u64 pid{};
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Service::NFP::AmiiboCrypto {
|
||||
bool IsAmiiboValid(const EncryptedNTAG215File& ntag_file) {
|
||||
const auto& amiibo_data = ntag_file.user_memory;
|
||||
LOG_DEBUG(Service_NFP, "uuid_lock=0x{0:x}", ntag_file.static_lock);
|
||||
LOG_DEBUG(Service_NFP, "compability_container=0x{0:x}", ntag_file.compability_container);
|
||||
LOG_DEBUG(Service_NFP, "compatibility_container=0x{0:x}", ntag_file.compatibility_container);
|
||||
LOG_DEBUG(Service_NFP, "write_count={}", static_cast<u16>(amiibo_data.write_counter));
|
||||
|
||||
LOG_DEBUG(Service_NFP, "character_id=0x{0:x}", amiibo_data.model_info.character_id);
|
||||
@@ -49,7 +49,7 @@ bool IsAmiiboValid(const EncryptedNTAG215File& ntag_file) {
|
||||
if (ntag_file.static_lock != 0xE00F) {
|
||||
return false;
|
||||
}
|
||||
if (ntag_file.compability_container != 0xEEFF10F1U) {
|
||||
if (ntag_file.compatibility_container != 0xEEFF10F1U) {
|
||||
return false;
|
||||
}
|
||||
if (amiibo_data.model_info.tag_type != NFC::PackedTagType::Type2) {
|
||||
@@ -78,7 +78,7 @@ NTAG215File NfcDataToEncodedData(const EncryptedNTAG215File& nfc_data) {
|
||||
encoded_data.uid_crc_check2 = nfc_data.uuid_crc_check2;
|
||||
encoded_data.internal_number = nfc_data.internal_number;
|
||||
encoded_data.static_lock = nfc_data.static_lock;
|
||||
encoded_data.compability_container = nfc_data.compability_container;
|
||||
encoded_data.compatibility_container = nfc_data.compatibility_container;
|
||||
encoded_data.hmac_data = nfc_data.user_memory.hmac_data;
|
||||
encoded_data.constant_value = nfc_data.user_memory.constant_value;
|
||||
encoded_data.write_counter = nfc_data.user_memory.write_counter;
|
||||
@@ -112,7 +112,7 @@ EncryptedNTAG215File EncodedDataToNfcData(const NTAG215File& encoded_data) {
|
||||
nfc_data.uuid_crc_check2 = encoded_data.uid_crc_check2;
|
||||
nfc_data.internal_number = encoded_data.internal_number;
|
||||
nfc_data.static_lock = encoded_data.static_lock;
|
||||
nfc_data.compability_container = encoded_data.compability_container;
|
||||
nfc_data.compatibility_container = encoded_data.compatibility_container;
|
||||
nfc_data.user_memory.hmac_data = encoded_data.hmac_data;
|
||||
nfc_data.user_memory.constant_value = encoded_data.constant_value;
|
||||
nfc_data.user_memory.write_counter = encoded_data.write_counter;
|
||||
@@ -257,7 +257,7 @@ void Cipher(const DerivedKeys& keys, const NTAG215File& in_data, NTAG215File& ou
|
||||
out_data.uid_crc_check2 = in_data.uid_crc_check2;
|
||||
out_data.internal_number = in_data.internal_number;
|
||||
out_data.static_lock = in_data.static_lock;
|
||||
out_data.compability_container = in_data.compability_container;
|
||||
out_data.compatibility_container = in_data.compatibility_container;
|
||||
|
||||
out_data.constant_value = in_data.constant_value;
|
||||
out_data.write_counter = in_data.write_counter;
|
||||
|
||||
@@ -75,7 +75,7 @@ void NfcDevice::NpadUpdate(Core::HID::ControllerTriggerType type) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_initalized) {
|
||||
if (!is_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ void NfcDevice::Initialize() {
|
||||
return;
|
||||
}
|
||||
|
||||
is_initalized = npad_device->AddNfcHandle();
|
||||
is_initialized = npad_device->AddNfcHandle();
|
||||
}
|
||||
|
||||
void NfcDevice::Finalize() {
|
||||
@@ -226,7 +226,7 @@ void NfcDevice::Finalize() {
|
||||
}
|
||||
|
||||
device_state = DeviceState::Unavailable;
|
||||
is_initalized = false;
|
||||
is_initialized = false;
|
||||
}
|
||||
|
||||
Result NfcDevice::StartDetection(NfcProtocol allowed_protocol) {
|
||||
|
||||
@@ -126,7 +126,7 @@ private:
|
||||
Kernel::KEvent* deactivate_event = nullptr;
|
||||
Kernel::KEvent* availability_change_event = nullptr;
|
||||
|
||||
bool is_initalized{};
|
||||
bool is_initialized{};
|
||||
NfcProtocol allowed_protocols{};
|
||||
DeviceState device_state{DeviceState::Unavailable};
|
||||
|
||||
|
||||
@@ -243,12 +243,12 @@ static_assert(sizeof(EncryptedAmiiboFile) == 0x1F8, "AmiiboFile is an invalid si
|
||||
struct NTAG215File {
|
||||
u8 uid_crc_check2;
|
||||
u8 internal_number;
|
||||
u16 static_lock; // Set defined pages as read only
|
||||
u32 compability_container; // Defines available memory
|
||||
HashData hmac_data; // Hash
|
||||
u8 constant_value; // Must be A5
|
||||
u16_be write_counter; // Number of times the amiibo has been written?
|
||||
u8 amiibo_version; // Amiibo file version
|
||||
u16 static_lock; // Set defined pages as read only
|
||||
u32 compatibility_container; // Defines available memory
|
||||
HashData hmac_data; // Hash
|
||||
u8 constant_value; // Must be A5
|
||||
u16_be write_counter; // Number of times the amiibo has been written?
|
||||
u8 amiibo_version; // Amiibo file version
|
||||
AmiiboSettings settings;
|
||||
Service::Mii::Ver3StoreData owner_mii; // Mii data
|
||||
u64_be application_id; // Game id
|
||||
@@ -278,7 +278,7 @@ struct EncryptedNTAG215File {
|
||||
u8 uuid_crc_check2;
|
||||
u8 internal_number;
|
||||
u16 static_lock; // Set defined pages as read only
|
||||
u32 compability_container; // Defines available memory
|
||||
u32 compatibility_container; // Defines available memory
|
||||
EncryptedAmiiboFile user_memory; // Writable data
|
||||
u32 dynamic_lock; // Dynamic lock
|
||||
u32 CFG0; // Defines memory protected by password
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/ns/language.h"
|
||||
#include "core/hle/service/set/set.h"
|
||||
#include "core/hle/service/set/settings_server.h"
|
||||
|
||||
namespace Service::NS {
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "core/hle/service/ns/ns.h"
|
||||
#include "core/hle/service/ns/pdm_qry.h"
|
||||
#include "core/hle/service/server_manager.h"
|
||||
#include "core/hle/service/set/set.h"
|
||||
#include "core/hle/service/set/settings_server.h"
|
||||
|
||||
namespace Service::NS {
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ private:
|
||||
u64_le align;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(IoctlAllocSpace) == 24, "IoctlInitalizeEx is incorrect size");
|
||||
static_assert(sizeof(IoctlAllocSpace) == 24, "IoctlInitializeEx is incorrect size");
|
||||
|
||||
struct IoctlFreeSpace {
|
||||
u64_le offset{};
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Service::Nvidia::Devices {
|
||||
nvhost_ctrl_gpu::nvhost_ctrl_gpu(Core::System& system_, EventInterface& events_interface_)
|
||||
: nvdevice{system_}, events_interface{events_interface_} {
|
||||
error_notifier_event = events_interface.CreateEvent("CtrlGpuErrorNotifier");
|
||||
unknown_event = events_interface.CreateEvent("CtrlGpuUknownEvent");
|
||||
unknown_event = events_interface.CreateEvent("CtrlGpuUnknownEvent");
|
||||
}
|
||||
nvhost_ctrl_gpu::~nvhost_ctrl_gpu() {
|
||||
events_interface.FreeEvent(error_notifier_event);
|
||||
|
||||
@@ -51,7 +51,7 @@ enum class NvResult : u32 {
|
||||
DispNoDisplaysAttached = 0x20003,
|
||||
DispModeNotSupported = 0x20004,
|
||||
DispNotFound = 0x20005,
|
||||
DispAttachDissallowed = 0x20006,
|
||||
DispAttachDisallowed = 0x20006,
|
||||
DispTypeNotSupported = 0x20007,
|
||||
DispAuthenticationFailed = 0x20008,
|
||||
DispNotAttached = 0x20009,
|
||||
|
||||
@@ -223,7 +223,8 @@ Result Nvnflinger::FindVsyncEvent(Kernel::KReadableEvent** out_vsync_event, u64
|
||||
return VI::ResultNotFound;
|
||||
}
|
||||
|
||||
return display->GetVSyncEvent(out_vsync_event);
|
||||
*out_vsync_event = display->GetVSyncEvent();
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
VI::Display* Nvnflinger::FindDisplay(u64 display_id) {
|
||||
|
||||
@@ -54,8 +54,8 @@ public:
|
||||
|
||||
class IClkrstSession final : public ServiceFramework<IClkrstSession> {
|
||||
public:
|
||||
explicit IClkrstSession(Core::System& system_, DeviceCode deivce_code_)
|
||||
: ServiceFramework{system_, "IClkrstSession"}, deivce_code(deivce_code_) {
|
||||
explicit IClkrstSession(Core::System& system_, DeviceCode device_code_)
|
||||
: ServiceFramework{system_, "IClkrstSession"}, device_code(device_code_) {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "SetClockEnabled"},
|
||||
@@ -93,7 +93,7 @@ private:
|
||||
rb.Push<u32>(clock_rate);
|
||||
}
|
||||
|
||||
DeviceCode deivce_code;
|
||||
DeviceCode device_code;
|
||||
u32 clock_rate{};
|
||||
};
|
||||
|
||||
@@ -118,9 +118,9 @@ private:
|
||||
void OpenSession(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto device_code = static_cast<DeviceCode>(rp.Pop<u32>());
|
||||
const auto unkonwn_input = rp.Pop<u32>();
|
||||
const auto unknown_input = rp.Pop<u32>();
|
||||
|
||||
LOG_DEBUG(Service_PCV, "called, device_code={}, input={}", device_code, unkonwn_input);
|
||||
LOG_DEBUG(Service_PCV, "called, device_code={}, input={}", device_code, unknown_input);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
|
||||
@@ -256,8 +256,13 @@ Result ServerManager::WaitAndProcessImpl() {
|
||||
|
||||
// Wait for a signal.
|
||||
s32 out_index{-1};
|
||||
R_TRY(Kernel::KSynchronizationObject::Wait(m_system.Kernel(), &out_index, wait_objs.data(),
|
||||
num_objs, -1));
|
||||
R_TRY_CATCH(Kernel::KSynchronizationObject::Wait(m_system.Kernel(), &out_index,
|
||||
wait_objs.data(), num_objs, -1)) {
|
||||
R_CATCH(Kernel::ResultSessionClosed) {
|
||||
// On session closed, index is updated and we don't want to return an error.
|
||||
}
|
||||
}
|
||||
R_END_TRY_CATCH;
|
||||
ASSERT(out_index >= 0 && out_index < num_objs);
|
||||
|
||||
// Set the output index.
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/set/set_cal.h"
|
||||
#include "core/hle/service/set/factory_settings_server.h"
|
||||
|
||||
namespace Service::Set {
|
||||
|
||||
SET_CAL::SET_CAL(Core::System& system_) : ServiceFramework{system_, "set:cal"} {
|
||||
IFactorySettingsServer::IFactorySettingsServer(Core::System& system_)
|
||||
: ServiceFramework{system_, "set:cal"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "GetBluetoothBdAddress"},
|
||||
@@ -57,6 +58,6 @@ SET_CAL::SET_CAL(Core::System& system_) : ServiceFramework{system_, "set:cal"} {
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
SET_CAL::~SET_CAL() = default;
|
||||
IFactorySettingsServer::~IFactorySettingsServer() = default;
|
||||
|
||||
} // namespace Service::Set
|
||||
@@ -11,10 +11,10 @@ class System;
|
||||
|
||||
namespace Service::Set {
|
||||
|
||||
class SET_FD final : public ServiceFramework<SET_FD> {
|
||||
class IFactorySettingsServer final : public ServiceFramework<IFactorySettingsServer> {
|
||||
public:
|
||||
explicit SET_FD(Core::System& system_);
|
||||
~SET_FD() override;
|
||||
explicit IFactorySettingsServer(Core::System& system_);
|
||||
~IFactorySettingsServer() override;
|
||||
};
|
||||
|
||||
} // namespace Service::Set
|
||||
@@ -1,11 +1,12 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/set/set_fd.h"
|
||||
#include "core/hle/service/set/firmware_debug_settings_server.h"
|
||||
|
||||
namespace Service::Set {
|
||||
|
||||
SET_FD::SET_FD(Core::System& system_) : ServiceFramework{system_, "set:fd"} {
|
||||
IFirmwareDebugSettingsServer::IFirmwareDebugSettingsServer(Core::System& system_)
|
||||
: ServiceFramework{system_, "set:fd"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{2, nullptr, "SetSettingsItemValue"},
|
||||
@@ -23,6 +24,6 @@ SET_FD::SET_FD(Core::System& system_) : ServiceFramework{system_, "set:fd"} {
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
SET_FD::~SET_FD() = default;
|
||||
IFirmwareDebugSettingsServer::~IFirmwareDebugSettingsServer() = default;
|
||||
|
||||
} // namespace Service::Set
|
||||
@@ -11,10 +11,10 @@ class System;
|
||||
|
||||
namespace Service::Set {
|
||||
|
||||
class SET_CAL final : public ServiceFramework<SET_CAL> {
|
||||
class IFirmwareDebugSettingsServer final : public ServiceFramework<IFirmwareDebugSettingsServer> {
|
||||
public:
|
||||
explicit SET_CAL(Core::System& system_);
|
||||
~SET_CAL() override;
|
||||
explicit IFirmwareDebugSettingsServer(Core::System& system_);
|
||||
~IFirmwareDebugSettingsServer() override;
|
||||
};
|
||||
|
||||
} // namespace Service::Set
|
||||
@@ -2,21 +2,24 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/server_manager.h"
|
||||
#include "core/hle/service/set/set.h"
|
||||
#include "core/hle/service/set/set_cal.h"
|
||||
#include "core/hle/service/set/set_fd.h"
|
||||
#include "core/hle/service/set/set_sys.h"
|
||||
#include "core/hle/service/set/factory_settings_server.h"
|
||||
#include "core/hle/service/set/firmware_debug_settings_server.h"
|
||||
#include "core/hle/service/set/settings.h"
|
||||
#include "core/hle/service/set/settings_server.h"
|
||||
#include "core/hle/service/set/system_settings_server.h"
|
||||
|
||||
namespace Service::Set {
|
||||
|
||||
void LoopProcess(Core::System& system) {
|
||||
auto server_manager = std::make_unique<ServerManager>(system);
|
||||
|
||||
server_manager->RegisterNamedService("set", std::make_shared<SET>(system));
|
||||
server_manager->RegisterNamedService("set:cal", std::make_shared<SET_CAL>(system));
|
||||
server_manager->RegisterNamedService("set:fd", std::make_shared<SET_FD>(system));
|
||||
server_manager->RegisterNamedService("set:sys", std::make_shared<SET_SYS>(system));
|
||||
server_manager->RegisterNamedService("set", std::make_shared<ISettingsServer>(system));
|
||||
server_manager->RegisterNamedService("set:cal",
|
||||
std::make_shared<IFactorySettingsServer>(system));
|
||||
server_manager->RegisterNamedService("set:fd",
|
||||
std::make_shared<IFirmwareDebugSettingsServer>(system));
|
||||
server_manager->RegisterNamedService("set:sys",
|
||||
std::make_shared<ISystemSettingsServer>(system));
|
||||
ServerManager::RunServer(std::move(server_manager));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "common/logging/log.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/set/set.h"
|
||||
#include "core/hle/service/set/settings_server.h"
|
||||
|
||||
namespace Service::Set {
|
||||
namespace {
|
||||
@@ -58,13 +58,36 @@ LanguageCode GetLanguageCodeFromIndex(std::size_t index) {
|
||||
return available_language_codes.at(index);
|
||||
}
|
||||
|
||||
void SET::GetAvailableLanguageCodes(HLERequestContext& ctx) {
|
||||
ISettingsServer::ISettingsServer(Core::System& system_) : ServiceFramework{system_, "set"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &ISettingsServer::GetLanguageCode, "GetLanguageCode"},
|
||||
{1, &ISettingsServer::GetAvailableLanguageCodes, "GetAvailableLanguageCodes"},
|
||||
{2, &ISettingsServer::MakeLanguageCode, "MakeLanguageCode"},
|
||||
{3, &ISettingsServer::GetAvailableLanguageCodeCount, "GetAvailableLanguageCodeCount"},
|
||||
{4, &ISettingsServer::GetRegionCode, "GetRegionCode"},
|
||||
{5, &ISettingsServer::GetAvailableLanguageCodes2, "GetAvailableLanguageCodes2"},
|
||||
{6, &ISettingsServer::GetAvailableLanguageCodeCount2, "GetAvailableLanguageCodeCount2"},
|
||||
{7, &ISettingsServer::GetKeyCodeMap, "GetKeyCodeMap"},
|
||||
{8, &ISettingsServer::GetQuestFlag, "GetQuestFlag"},
|
||||
{9, &ISettingsServer::GetKeyCodeMap2, "GetKeyCodeMap2"},
|
||||
{10, nullptr, "GetFirmwareVersionForDebug"},
|
||||
{11, &ISettingsServer::GetDeviceNickName, "GetDeviceNickName"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
ISettingsServer::~ISettingsServer() = default;
|
||||
|
||||
void ISettingsServer::GetAvailableLanguageCodes(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_SET, "called");
|
||||
|
||||
GetAvailableLanguageCodesImpl(ctx, PRE_4_0_0_MAX_ENTRIES);
|
||||
}
|
||||
|
||||
void SET::MakeLanguageCode(HLERequestContext& ctx) {
|
||||
void ISettingsServer::MakeLanguageCode(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto index = rp.Pop<u32>();
|
||||
|
||||
@@ -80,25 +103,25 @@ void SET::MakeLanguageCode(HLERequestContext& ctx) {
|
||||
rb.PushEnum(available_language_codes[index]);
|
||||
}
|
||||
|
||||
void SET::GetAvailableLanguageCodes2(HLERequestContext& ctx) {
|
||||
void ISettingsServer::GetAvailableLanguageCodes2(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_SET, "called");
|
||||
|
||||
GetAvailableLanguageCodesImpl(ctx, POST_4_0_0_MAX_ENTRIES);
|
||||
}
|
||||
|
||||
void SET::GetAvailableLanguageCodeCount(HLERequestContext& ctx) {
|
||||
void ISettingsServer::GetAvailableLanguageCodeCount(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_SET, "called");
|
||||
|
||||
PushResponseLanguageCode(ctx, PRE_4_0_0_MAX_ENTRIES);
|
||||
}
|
||||
|
||||
void SET::GetAvailableLanguageCodeCount2(HLERequestContext& ctx) {
|
||||
void ISettingsServer::GetAvailableLanguageCodeCount2(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_SET, "called");
|
||||
|
||||
PushResponseLanguageCode(ctx, POST_4_0_0_MAX_ENTRIES);
|
||||
}
|
||||
|
||||
void SET::GetQuestFlag(HLERequestContext& ctx) {
|
||||
void ISettingsServer::GetQuestFlag(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_SET, "called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
@@ -106,7 +129,7 @@ void SET::GetQuestFlag(HLERequestContext& ctx) {
|
||||
rb.Push(static_cast<s32>(Settings::values.quest_flag.GetValue()));
|
||||
}
|
||||
|
||||
void SET::GetLanguageCode(HLERequestContext& ctx) {
|
||||
void ISettingsServer::GetLanguageCode(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_SET, "called {}", Settings::values.language_index.GetValue());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
@@ -115,7 +138,7 @@ void SET::GetLanguageCode(HLERequestContext& ctx) {
|
||||
available_language_codes[static_cast<s32>(Settings::values.language_index.GetValue())]);
|
||||
}
|
||||
|
||||
void SET::GetRegionCode(HLERequestContext& ctx) {
|
||||
void ISettingsServer::GetRegionCode(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_SET, "called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
@@ -123,44 +146,21 @@ void SET::GetRegionCode(HLERequestContext& ctx) {
|
||||
rb.Push(static_cast<u32>(Settings::values.region_index.GetValue()));
|
||||
}
|
||||
|
||||
void SET::GetKeyCodeMap(HLERequestContext& ctx) {
|
||||
void ISettingsServer::GetKeyCodeMap(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_SET, "Called {}", ctx.Description());
|
||||
GetKeyCodeMapImpl(ctx);
|
||||
}
|
||||
|
||||
void SET::GetKeyCodeMap2(HLERequestContext& ctx) {
|
||||
void ISettingsServer::GetKeyCodeMap2(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_SET, "Called {}", ctx.Description());
|
||||
GetKeyCodeMapImpl(ctx);
|
||||
}
|
||||
|
||||
void SET::GetDeviceNickName(HLERequestContext& ctx) {
|
||||
void ISettingsServer::GetDeviceNickName(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_SET, "called");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
ctx.WriteBuffer(Settings::values.device_name.GetValue());
|
||||
}
|
||||
|
||||
SET::SET(Core::System& system_) : ServiceFramework{system_, "set"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &SET::GetLanguageCode, "GetLanguageCode"},
|
||||
{1, &SET::GetAvailableLanguageCodes, "GetAvailableLanguageCodes"},
|
||||
{2, &SET::MakeLanguageCode, "MakeLanguageCode"},
|
||||
{3, &SET::GetAvailableLanguageCodeCount, "GetAvailableLanguageCodeCount"},
|
||||
{4, &SET::GetRegionCode, "GetRegionCode"},
|
||||
{5, &SET::GetAvailableLanguageCodes2, "GetAvailableLanguageCodes2"},
|
||||
{6, &SET::GetAvailableLanguageCodeCount2, "GetAvailableLanguageCodeCount2"},
|
||||
{7, &SET::GetKeyCodeMap, "GetKeyCodeMap"},
|
||||
{8, &SET::GetQuestFlag, "GetQuestFlag"},
|
||||
{9, &SET::GetKeyCodeMap2, "GetKeyCodeMap2"},
|
||||
{10, nullptr, "GetFirmwareVersionForDebug"},
|
||||
{11, &SET::GetDeviceNickName, "GetDeviceNickName"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
SET::~SET() = default;
|
||||
|
||||
} // namespace Service::Set
|
||||
@@ -73,10 +73,10 @@ static constexpr std::array<std::pair<LanguageCode, KeyboardLayout>, 18> languag
|
||||
|
||||
LanguageCode GetLanguageCodeFromIndex(std::size_t idx);
|
||||
|
||||
class SET final : public ServiceFramework<SET> {
|
||||
class ISettingsServer final : public ServiceFramework<ISettingsServer> {
|
||||
public:
|
||||
explicit SET(Core::System& system_);
|
||||
~SET() override;
|
||||
explicit ISettingsServer(Core::System& system_);
|
||||
~ISettingsServer() override;
|
||||
|
||||
private:
|
||||
void GetLanguageCode(HLERequestContext& ctx);
|
||||
@@ -28,7 +28,7 @@ SystemSettings DefaultSystemSettings() {
|
||||
.cmu_mode = CmuMode::None,
|
||||
.tv_underscan = {},
|
||||
.tv_gama = 1.0f,
|
||||
.constrast_ratio = 0.5f,
|
||||
.contrast_ratio = 0.5f,
|
||||
};
|
||||
|
||||
settings.initial_launch_settings_packed = {
|
||||
|
||||
@@ -208,7 +208,7 @@ struct TvSettings {
|
||||
CmuMode cmu_mode;
|
||||
u32 tv_underscan;
|
||||
f32 tv_gama;
|
||||
f32 constrast_ratio;
|
||||
f32 contrast_ratio;
|
||||
};
|
||||
static_assert(sizeof(TvSettings) == 0x20, "TvSettings is an invalid size");
|
||||
|
||||
@@ -341,7 +341,7 @@ struct SystemSettings {
|
||||
std::array<u8, 0x3C> reserved_09934;
|
||||
|
||||
// nn::settings::system::ErrorReportSharePermission
|
||||
ErrorReportSharePermission error_report_share_permssion;
|
||||
ErrorReportSharePermission error_report_share_permission;
|
||||
|
||||
std::array<u8, 0x3C> reserved_09974;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -47,10 +47,10 @@ static_assert(sizeof(FirmwareVersionFormat) == 0x100, "FirmwareVersionFormat is
|
||||
Result GetFirmwareVersionImpl(FirmwareVersionFormat& out_firmware, Core::System& system,
|
||||
GetFirmwareVersionType type);
|
||||
|
||||
class SET_SYS final : public ServiceFramework<SET_SYS> {
|
||||
class ISystemSettingsServer final : public ServiceFramework<ISystemSettingsServer> {
|
||||
public:
|
||||
explicit SET_SYS(Core::System& system_);
|
||||
~SET_SYS() override;
|
||||
explicit ISystemSettingsServer(Core::System& system_);
|
||||
~ISystemSettingsServer() override;
|
||||
|
||||
Result GetSettingsItemValue(std::vector<u8>& out_value, const std::string& category,
|
||||
const std::string& name);
|
||||
@@ -71,18 +71,7 @@ size_t Display::GetNumLayers() const {
|
||||
return std::ranges::count_if(layers, [](auto& l) { return l->IsOpen(); });
|
||||
}
|
||||
|
||||
Result Display::GetVSyncEvent(Kernel::KReadableEvent** out_vsync_event) {
|
||||
if (got_vsync_event) {
|
||||
return ResultPermissionDenied;
|
||||
}
|
||||
|
||||
got_vsync_event = true;
|
||||
|
||||
*out_vsync_event = GetVSyncEventUnchecked();
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Kernel::KReadableEvent* Display::GetVSyncEventUnchecked() {
|
||||
Kernel::KReadableEvent* Display::GetVSyncEvent() {
|
||||
return &vsync_event->GetReadableEvent();
|
||||
}
|
||||
|
||||
|
||||
@@ -74,16 +74,8 @@ public:
|
||||
|
||||
std::size_t GetNumLayers() const;
|
||||
|
||||
/**
|
||||
* Gets the internal vsync event.
|
||||
*
|
||||
* @returns The internal Vsync event if it has not yet been retrieved,
|
||||
* VI::ResultPermissionDenied otherwise.
|
||||
*/
|
||||
[[nodiscard]] Result GetVSyncEvent(Kernel::KReadableEvent** out_vsync_event);
|
||||
|
||||
/// Gets the internal vsync event.
|
||||
Kernel::KReadableEvent* GetVSyncEventUnchecked();
|
||||
Kernel::KReadableEvent* GetVSyncEvent();
|
||||
|
||||
/// Signals the internal vsync event.
|
||||
void SignalVSyncEvent();
|
||||
@@ -104,7 +96,6 @@ public:
|
||||
/// Resets the display for a new connection.
|
||||
void Reset() {
|
||||
layers.clear();
|
||||
got_vsync_event = false;
|
||||
}
|
||||
|
||||
/// Attempts to find a layer with the given ID.
|
||||
@@ -133,7 +124,6 @@ private:
|
||||
|
||||
std::vector<std::unique_ptr<Layer>> layers;
|
||||
Kernel::KEvent* vsync_event{};
|
||||
bool got_vsync_event{false};
|
||||
};
|
||||
|
||||
} // namespace Service::VI
|
||||
|
||||
@@ -343,8 +343,8 @@ private:
|
||||
|
||||
class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> {
|
||||
public:
|
||||
explicit IManagerDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_)
|
||||
: ServiceFramework{system_, "IManagerDisplayService"}, nv_flinger{nv_flinger_} {
|
||||
explicit IManagerDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger_)
|
||||
: ServiceFramework{system_, "IManagerDisplayService"}, nvnflinger{nvnflinger_} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{200, nullptr, "AllocateProcessHeapBlock"},
|
||||
@@ -440,7 +440,7 @@ private:
|
||||
IPC::RequestParser rp{ctx};
|
||||
const u64 display = rp.Pop<u64>();
|
||||
|
||||
const Result rc = nv_flinger.CloseDisplay(display) ? ResultSuccess : ResultUnknown;
|
||||
const Result rc = nvnflinger.CloseDisplay(display) ? ResultSuccess : ResultUnknown;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(rc);
|
||||
@@ -457,7 +457,7 @@ private:
|
||||
"(STUBBED) called. unknown=0x{:08X}, display=0x{:016X}, aruid=0x{:016X}",
|
||||
unknown, display, aruid);
|
||||
|
||||
const auto layer_id = nv_flinger.CreateLayer(display);
|
||||
const auto layer_id = nvnflinger.CreateLayer(display);
|
||||
if (!layer_id) {
|
||||
LOG_ERROR(Service_VI, "Layer not found! display=0x{:016X}", display);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
@@ -494,14 +494,14 @@ private:
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
Nvnflinger::Nvnflinger& nv_flinger;
|
||||
Nvnflinger::Nvnflinger& nvnflinger;
|
||||
};
|
||||
|
||||
class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> {
|
||||
public:
|
||||
IApplicationDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,
|
||||
IApplicationDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger_,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_)
|
||||
: ServiceFramework{system_, "IApplicationDisplayService"}, nv_flinger{nv_flinger_},
|
||||
: ServiceFramework{system_, "IApplicationDisplayService"}, nvnflinger{nvnflinger_},
|
||||
hos_binder_driver_server{hos_binder_driver_server_} {
|
||||
|
||||
static const FunctionInfo functions[] = {
|
||||
@@ -564,7 +564,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<ISystemDisplayService>(system, nv_flinger);
|
||||
rb.PushIpcInterface<ISystemDisplayService>(system, nvnflinger);
|
||||
}
|
||||
|
||||
void GetManagerDisplayService(HLERequestContext& ctx) {
|
||||
@@ -572,7 +572,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<IManagerDisplayService>(system, nv_flinger);
|
||||
rb.PushIpcInterface<IManagerDisplayService>(system, nvnflinger);
|
||||
}
|
||||
|
||||
void GetIndirectDisplayTransactionService(HLERequestContext& ctx) {
|
||||
@@ -607,7 +607,7 @@ private:
|
||||
|
||||
ASSERT_MSG(name == "Default", "Non-default displays aren't supported yet");
|
||||
|
||||
const auto display_id = nv_flinger.OpenDisplay(name);
|
||||
const auto display_id = nvnflinger.OpenDisplay(name);
|
||||
if (!display_id) {
|
||||
LOG_ERROR(Service_VI, "Display not found! display_name={}", name);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
@@ -624,7 +624,7 @@ private:
|
||||
IPC::RequestParser rp{ctx};
|
||||
const u64 display_id = rp.Pop<u64>();
|
||||
|
||||
const Result rc = nv_flinger.CloseDisplay(display_id) ? ResultSuccess : ResultUnknown;
|
||||
const Result rc = nvnflinger.CloseDisplay(display_id) ? ResultSuccess : ResultUnknown;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(rc);
|
||||
@@ -703,7 +703,7 @@ private:
|
||||
|
||||
LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}, aruid=0x{:016X}", layer_id, aruid);
|
||||
|
||||
const auto display_id = nv_flinger.OpenDisplay(display_name);
|
||||
const auto display_id = nvnflinger.OpenDisplay(display_name);
|
||||
if (!display_id) {
|
||||
LOG_ERROR(Service_VI, "Layer not found! layer_id={}", layer_id);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
@@ -711,7 +711,7 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
const auto buffer_queue_id = nv_flinger.FindBufferQueueId(*display_id, layer_id);
|
||||
const auto buffer_queue_id = nvnflinger.FindBufferQueueId(*display_id, layer_id);
|
||||
if (!buffer_queue_id) {
|
||||
LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", *display_id);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
@@ -719,7 +719,7 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
nv_flinger.OpenLayer(layer_id);
|
||||
nvnflinger.OpenLayer(layer_id);
|
||||
|
||||
android::OutputParcel parcel;
|
||||
parcel.WriteInterface(NativeWindow{*buffer_queue_id});
|
||||
@@ -737,7 +737,7 @@ private:
|
||||
|
||||
LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}", layer_id);
|
||||
|
||||
nv_flinger.CloseLayer(layer_id);
|
||||
nvnflinger.CloseLayer(layer_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -753,7 +753,7 @@ private:
|
||||
|
||||
// TODO(Subv): What's the difference between a Stray and a Managed layer?
|
||||
|
||||
const auto layer_id = nv_flinger.CreateLayer(display_id);
|
||||
const auto layer_id = nvnflinger.CreateLayer(display_id);
|
||||
if (!layer_id) {
|
||||
LOG_ERROR(Service_VI, "Layer not found! display_id={}", display_id);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
@@ -761,7 +761,7 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
const auto buffer_queue_id = nv_flinger.FindBufferQueueId(display_id, *layer_id);
|
||||
const auto buffer_queue_id = nvnflinger.FindBufferQueueId(display_id, *layer_id);
|
||||
if (!buffer_queue_id) {
|
||||
LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", display_id);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
@@ -785,7 +785,7 @@ private:
|
||||
const u64 layer_id = rp.Pop<u64>();
|
||||
|
||||
LOG_WARNING(Service_VI, "(STUBBED) called. layer_id=0x{:016X}", layer_id);
|
||||
nv_flinger.DestroyLayer(layer_id);
|
||||
nvnflinger.DestroyLayer(layer_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -798,7 +798,7 @@ private:
|
||||
LOG_DEBUG(Service_VI, "called. display_id={}", display_id);
|
||||
|
||||
Kernel::KReadableEvent* vsync_event{};
|
||||
const auto result = nv_flinger.FindVsyncEvent(&vsync_event, display_id);
|
||||
const auto result = nvnflinger.FindVsyncEvent(&vsync_event, display_id);
|
||||
if (result != ResultSuccess) {
|
||||
if (result == ResultNotFound) {
|
||||
LOG_ERROR(Service_VI, "Vsync event was not found for display_id={}", display_id);
|
||||
@@ -808,6 +808,12 @@ private:
|
||||
rb.Push(result);
|
||||
return;
|
||||
}
|
||||
if (vsync_event_fetched) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(VI::ResultPermissionDenied);
|
||||
return;
|
||||
}
|
||||
vsync_event_fetched = true;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -899,8 +905,9 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
Nvnflinger::Nvnflinger& nv_flinger;
|
||||
Nvnflinger::Nvnflinger& nvnflinger;
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server;
|
||||
bool vsync_event_fetched{false};
|
||||
};
|
||||
|
||||
static bool IsValidServiceAccess(Permission permission, Policy policy) {
|
||||
@@ -916,7 +923,7 @@ static bool IsValidServiceAccess(Permission permission, Policy policy) {
|
||||
}
|
||||
|
||||
void detail::GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system,
|
||||
Nvnflinger::Nvnflinger& nv_flinger,
|
||||
Nvnflinger::Nvnflinger& nvnflinger,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server,
|
||||
Permission permission) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
@@ -931,19 +938,19 @@ void detail::GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system,
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<IApplicationDisplayService>(system, nv_flinger, hos_binder_driver_server);
|
||||
rb.PushIpcInterface<IApplicationDisplayService>(system, nvnflinger, hos_binder_driver_server);
|
||||
}
|
||||
|
||||
void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nv_flinger,
|
||||
void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) {
|
||||
auto server_manager = std::make_unique<ServerManager>(system);
|
||||
|
||||
server_manager->RegisterNamedService(
|
||||
"vi:m", std::make_shared<VI_M>(system, nv_flinger, hos_binder_driver_server));
|
||||
"vi:m", std::make_shared<VI_M>(system, nvnflinger, hos_binder_driver_server));
|
||||
server_manager->RegisterNamedService(
|
||||
"vi:s", std::make_shared<VI_S>(system, nv_flinger, hos_binder_driver_server));
|
||||
"vi:s", std::make_shared<VI_S>(system, nvnflinger, hos_binder_driver_server));
|
||||
server_manager->RegisterNamedService(
|
||||
"vi:u", std::make_shared<VI_U>(system, nv_flinger, hos_binder_driver_server));
|
||||
"vi:u", std::make_shared<VI_U>(system, nvnflinger, hos_binder_driver_server));
|
||||
ServerManager::RunServer(std::move(server_manager));
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ void GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system,
|
||||
Permission permission);
|
||||
} // namespace detail
|
||||
|
||||
void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nv_flinger,
|
||||
void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
|
||||
|
||||
} // namespace Service::VI
|
||||
|
||||
@@ -216,20 +216,6 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect
|
||||
LOG_DEBUG(Loader, "loaded module {} @ {:#X}", module, load_addr);
|
||||
}
|
||||
|
||||
// Find the RomFS by searching for a ".romfs" file in this directory
|
||||
const auto& files = dir->GetFiles();
|
||||
const auto romfs_iter =
|
||||
std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& f) {
|
||||
return f->GetName().find(".romfs") != std::string::npos;
|
||||
});
|
||||
|
||||
// Register the RomFS if a ".romfs" file was found
|
||||
if (romfs_iter != files.end() && *romfs_iter != nullptr) {
|
||||
romfs = *romfs_iter;
|
||||
system.GetFileSystemController().RegisterRomFS(std::make_unique<FileSys::RomFSFactory>(
|
||||
*this, system.GetContentProvider(), system.GetFileSystemController()));
|
||||
}
|
||||
|
||||
is_loaded = true;
|
||||
return {ResultStatus::Success,
|
||||
LoadParameters{metadata.GetMainThreadPriority(), metadata.GetMainThreadStackSize()}};
|
||||
|
||||
@@ -74,8 +74,10 @@ AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::KProcess& process, Core::S
|
||||
return load_result;
|
||||
}
|
||||
|
||||
system.GetFileSystemController().RegisterRomFS(std::make_unique<FileSys::RomFSFactory>(
|
||||
*this, system.GetContentProvider(), system.GetFileSystemController()));
|
||||
system.GetFileSystemController().RegisterProcess(
|
||||
process.GetProcessId(), nca->GetTitleId(),
|
||||
std::make_shared<FileSys::RomFSFactory>(*this, system.GetContentProvider(),
|
||||
system.GetFileSystemController()));
|
||||
|
||||
is_loaded = true;
|
||||
return load_result;
|
||||
|
||||
@@ -276,8 +276,10 @@ AppLoader_NRO::LoadResult AppLoader_NRO::Load(Kernel::KProcess& process, Core::S
|
||||
}
|
||||
|
||||
if (romfs != nullptr) {
|
||||
system.GetFileSystemController().RegisterRomFS(std::make_unique<FileSys::RomFSFactory>(
|
||||
*this, system.GetContentProvider(), system.GetFileSystemController()));
|
||||
system.GetFileSystemController().RegisterProcess(
|
||||
process.GetProcessId(), {},
|
||||
std::make_unique<FileSys::RomFSFactory>(*this, system.GetContentProvider(),
|
||||
system.GetFileSystemController()));
|
||||
}
|
||||
|
||||
is_loaded = true;
|
||||
|
||||
@@ -111,7 +111,8 @@ AppLoader_NSP::LoadResult AppLoader_NSP::Load(Kernel::KProcess& process, Core::S
|
||||
|
||||
FileSys::VirtualFile update_raw;
|
||||
if (ReadUpdateRaw(update_raw) == ResultStatus::Success && update_raw != nullptr) {
|
||||
system.GetFileSystemController().SetPackedUpdate(std::move(update_raw));
|
||||
system.GetFileSystemController().SetPackedUpdate(process.GetProcessId(),
|
||||
std::move(update_raw));
|
||||
}
|
||||
|
||||
is_loaded = true;
|
||||
|
||||
@@ -78,7 +78,8 @@ AppLoader_XCI::LoadResult AppLoader_XCI::Load(Kernel::KProcess& process, Core::S
|
||||
|
||||
FileSys::VirtualFile update_raw;
|
||||
if (ReadUpdateRaw(update_raw) == ResultStatus::Success && update_raw != nullptr) {
|
||||
system.GetFileSystemController().SetPackedUpdate(std::move(update_raw));
|
||||
system.GetFileSystemController().SetPackedUpdate(process.GetProcessId(),
|
||||
std::move(update_raw));
|
||||
}
|
||||
|
||||
is_loaded = true;
|
||||
|
||||
@@ -36,6 +36,30 @@ add_library(hid_core STATIC
|
||||
irsensor/processor_base.h
|
||||
irsensor/tera_plugin_processor.cpp
|
||||
irsensor/tera_plugin_processor.h
|
||||
resources/abstracted_pad/abstract_battery_handler.cpp
|
||||
resources/abstracted_pad/abstract_battery_handler.h
|
||||
resources/abstracted_pad/abstract_button_handler.cpp
|
||||
resources/abstracted_pad/abstract_button_handler.h
|
||||
resources/abstracted_pad/abstract_ir_sensor_handler.cpp
|
||||
resources/abstracted_pad/abstract_ir_sensor_handler.h
|
||||
resources/abstracted_pad/abstract_led_handler.cpp
|
||||
resources/abstracted_pad/abstract_led_handler.h
|
||||
resources/abstracted_pad/abstract_mcu_handler.cpp
|
||||
resources/abstracted_pad/abstract_mcu_handler.h
|
||||
resources/abstracted_pad/abstract_nfc_handler.cpp
|
||||
resources/abstracted_pad/abstract_nfc_handler.h
|
||||
resources/abstracted_pad/abstract_pad.cpp
|
||||
resources/abstracted_pad/abstract_pad.h
|
||||
resources/abstracted_pad/abstract_pad_holder.cpp
|
||||
resources/abstracted_pad/abstract_pad_holder.h
|
||||
resources/abstracted_pad/abstract_palma_handler.cpp
|
||||
resources/abstracted_pad/abstract_palma_handler.h
|
||||
resources/abstracted_pad/abstract_properties_handler.cpp
|
||||
resources/abstracted_pad/abstract_properties_handler.h
|
||||
resources/abstracted_pad/abstract_sixaxis_handler.cpp
|
||||
resources/abstracted_pad/abstract_sixaxis_handler.h
|
||||
resources/abstracted_pad/abstract_vibration_handler.cpp
|
||||
resources/abstracted_pad/abstract_vibration_handler.h
|
||||
resources/debug_pad/debug_pad.cpp
|
||||
resources/debug_pad/debug_pad.h
|
||||
resources/debug_pad/debug_pad_types.h
|
||||
@@ -56,6 +80,8 @@ add_library(hid_core STATIC
|
||||
resources/npad/npad_resource.cpp
|
||||
resources/npad/npad_resource.h
|
||||
resources/npad/npad_types.h
|
||||
resources/npad/npad_vibration.cpp
|
||||
resources/npad/npad_vibration.h
|
||||
resources/palma/palma.cpp
|
||||
resources/palma/palma.h
|
||||
resources/six_axis/console_six_axis.cpp
|
||||
@@ -78,6 +104,14 @@ add_library(hid_core STATIC
|
||||
resources/touch_screen/touch_types.h
|
||||
resources/unique_pad/unique_pad.cpp
|
||||
resources/unique_pad/unique_pad.h
|
||||
resources/vibration/gc_vibration_device.h
|
||||
resources/vibration/gc_vibration_device.cpp
|
||||
resources/vibration/n64_vibration_device.h
|
||||
resources/vibration/n64_vibration_device.cpp
|
||||
resources/vibration/vibration_base.h
|
||||
resources/vibration/vibration_base.cpp
|
||||
resources/vibration/vibration_device.h
|
||||
resources/vibration/vibration_device.cpp
|
||||
resources/applet_resource.cpp
|
||||
resources/applet_resource.h
|
||||
resources/controller_base.cpp
|
||||
|
||||
@@ -27,7 +27,7 @@ EmulatedController::~EmulatedController() = default;
|
||||
NpadStyleIndex EmulatedController::MapSettingsTypeToNPad(Settings::ControllerType type) {
|
||||
switch (type) {
|
||||
case Settings::ControllerType::ProController:
|
||||
return NpadStyleIndex::ProController;
|
||||
return NpadStyleIndex::Fullkey;
|
||||
case Settings::ControllerType::DualJoyconDetached:
|
||||
return NpadStyleIndex::JoyconDual;
|
||||
case Settings::ControllerType::LeftJoycon:
|
||||
@@ -49,13 +49,13 @@ NpadStyleIndex EmulatedController::MapSettingsTypeToNPad(Settings::ControllerTyp
|
||||
case Settings::ControllerType::SegaGenesis:
|
||||
return NpadStyleIndex::SegaGenesis;
|
||||
default:
|
||||
return NpadStyleIndex::ProController;
|
||||
return NpadStyleIndex::Fullkey;
|
||||
}
|
||||
}
|
||||
|
||||
Settings::ControllerType EmulatedController::MapNPadToSettingsType(NpadStyleIndex type) {
|
||||
switch (type) {
|
||||
case NpadStyleIndex::ProController:
|
||||
case NpadStyleIndex::Fullkey:
|
||||
return Settings::ControllerType::ProController;
|
||||
case NpadStyleIndex::JoyconDual:
|
||||
return Settings::ControllerType::DualJoyconDetached;
|
||||
@@ -106,7 +106,7 @@ void EmulatedController::ReloadFromSettings() {
|
||||
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
|
||||
original_npad_type = npad_type;
|
||||
} else {
|
||||
SetNpadStyleIndex(NpadStyleIndex::ProController);
|
||||
SetNpadStyleIndex(NpadStyleIndex::Fullkey);
|
||||
original_npad_type = npad_type;
|
||||
}
|
||||
|
||||
@@ -1073,7 +1073,7 @@ void EmulatedController::SetColors(const Common::Input::CallbackStatus& callback
|
||||
.body = GetNpadColor(controller.color_values[index].body),
|
||||
.button = GetNpadColor(controller.color_values[index].buttons),
|
||||
};
|
||||
if (npad_type == NpadStyleIndex::ProController) {
|
||||
if (npad_type == NpadStyleIndex::Fullkey) {
|
||||
controller.colors_state.left = {
|
||||
.body = GetNpadColor(controller.color_values[index].left_grip),
|
||||
.button = GetNpadColor(controller.color_values[index].buttons),
|
||||
@@ -1356,7 +1356,7 @@ bool EmulatedController::HasNfc() const {
|
||||
switch (npad_type) {
|
||||
case NpadStyleIndex::JoyconRight:
|
||||
case NpadStyleIndex::JoyconDual:
|
||||
case NpadStyleIndex::ProController:
|
||||
case NpadStyleIndex::Fullkey:
|
||||
case NpadStyleIndex::Handheld:
|
||||
break;
|
||||
default:
|
||||
@@ -1548,7 +1548,7 @@ void EmulatedController::SetSupportedNpadStyleTag(NpadStyleTag supported_styles)
|
||||
// Fallback Fullkey controllers to Pro controllers
|
||||
if (IsControllerFullkey() && supported_style_tag.fullkey) {
|
||||
LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type);
|
||||
SetNpadStyleIndex(NpadStyleIndex::ProController);
|
||||
SetNpadStyleIndex(NpadStyleIndex::Fullkey);
|
||||
Connect();
|
||||
return;
|
||||
}
|
||||
@@ -1556,13 +1556,13 @@ void EmulatedController::SetSupportedNpadStyleTag(NpadStyleTag supported_styles)
|
||||
// Fallback Dual joycon controllers to Pro controllers
|
||||
if (npad_type == NpadStyleIndex::JoyconDual && supported_style_tag.fullkey) {
|
||||
LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type);
|
||||
SetNpadStyleIndex(NpadStyleIndex::ProController);
|
||||
SetNpadStyleIndex(NpadStyleIndex::Fullkey);
|
||||
Connect();
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback Pro controllers to Dual joycon
|
||||
if (npad_type == NpadStyleIndex::ProController && supported_style_tag.joycon_dual) {
|
||||
if (npad_type == NpadStyleIndex::Fullkey && supported_style_tag.joycon_dual) {
|
||||
LOG_WARNING(Service_HID, "Reconnecting controller type {} as Dual Joycons", npad_type);
|
||||
SetNpadStyleIndex(NpadStyleIndex::JoyconDual);
|
||||
Connect();
|
||||
@@ -1577,7 +1577,7 @@ bool EmulatedController::IsControllerFullkey(bool use_temporary_value) const {
|
||||
std::scoped_lock lock{mutex};
|
||||
const auto type = is_configuring && use_temporary_value ? tmp_npad_type : npad_type;
|
||||
switch (type) {
|
||||
case NpadStyleIndex::ProController:
|
||||
case NpadStyleIndex::Fullkey:
|
||||
case NpadStyleIndex::GameCube:
|
||||
case NpadStyleIndex::NES:
|
||||
case NpadStyleIndex::SNES:
|
||||
@@ -1593,7 +1593,7 @@ bool EmulatedController::IsControllerSupported(bool use_temporary_value) const {
|
||||
std::scoped_lock lock{mutex};
|
||||
const auto type = is_configuring && use_temporary_value ? tmp_npad_type : npad_type;
|
||||
switch (type) {
|
||||
case NpadStyleIndex::ProController:
|
||||
case NpadStyleIndex::Fullkey:
|
||||
return supported_style_tag.fullkey.As<bool>();
|
||||
case NpadStyleIndex::Handheld:
|
||||
return supported_style_tag.handheld.As<bool>();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user