Compare commits

...

4 Commits

Author SHA1 Message Date
27ee86f33b Exclude macOS from checking for changed files (#5270) 2023-06-09 15:35:24 +02:00
f7ec310231 Check if existing oldConfigPath is a Symlink (#5271) 2023-06-09 15:31:19 +02:00
e94d24f508 Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' (#5231)
* Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' check to avoid double lookup

* fix
2023-06-09 13:05:32 +02:00
2bf4555591 Swkbd Applet Fixes (#5236)
* Swkbd Applet Fixes

* Forgot a full stop

* Update src/Ryujinx.Ava/UI/Applet/SwkbdAppletDialog.axaml.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Update src/Ryujinx/Ui/Applet/SwkbdAppletDialog.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

---------

Co-authored-by: Ac_K <Acoustik666@gmail.com>
2023-06-09 12:11:53 +02:00
9 changed files with 57 additions and 28 deletions

View File

@ -545,7 +545,7 @@
"SwkbdMinRangeCharacters": "Must be {0}-{1} characters long",
"SoftwareKeyboard": "Software Keyboard",
"SoftwareKeyboardModeNumbersOnly": "Must be numbers only",
"SoftwareKeyboardModeAlphabet": "Must be alphabets only",
"SoftwareKeyboardModeAlphabet": "Must be non CJK-characters only",
"SoftwareKeyboardModeASCII": "Must be ASCII text only",
"DialogControllerAppletMessagePlayerRange": "Application requests {0} player(s) with:\n\nTYPES: {1}\n\nPLAYERS: {2}\n\n{3}Please open Settings and reconfigure Input now or press Close.",
"DialogControllerAppletMessage": "Application requests exactly {0} player(s) with:\n\nTYPES: {1}\n\nPLAYERS: {2}\n\n{3}Please open Settings and reconfigure Input now or press Close.",

View File

@ -741,7 +741,7 @@ namespace Ryujinx.Modules
var files = Directory.EnumerateFiles(HomeDir); // All files directly in base dir.
// Determine and exclude user files only when the updater is running, not when cleaning old files
if (_running)
if (_running && !OperatingSystem.IsMacOS())
{
// Compare the loose files in base directory against the loose files from the incoming update, and store foreign ones in a user list.
var oldFiles = Directory.EnumerateFiles(HomeDir, "*", SearchOption.TopDirectoryOnly).Select(Path.GetFileName);

View File

@ -146,7 +146,7 @@ namespace Ryujinx.Ava.UI.Controls
case KeyboardMode.Alphabet:
localeText = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.SoftwareKeyboardModeAlphabet);
validationInfoText = string.IsNullOrEmpty(validationInfoText) ? localeText : string.Join("\n", validationInfoText, localeText);
_checkInput = text => text.All(char.IsAsciiLetter);
_checkInput = text => text.All(value => !CJKCharacterValidation.IsCJK(value));
break;
case KeyboardMode.ASCII:
localeText = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.SoftwareKeyboardModeASCII);

View File

@ -96,7 +96,7 @@ namespace Ryujinx.Common.Configuration
if (OperatingSystem.IsMacOS() && Mode == LaunchMode.UserProfile)
{
string oldConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), DefaultBaseDir);
if (Path.Exists(oldConfigPath) && !Path.Exists(BaseDirPath))
if (Path.Exists(oldConfigPath) && !IsPathSymlink(oldConfigPath) && !Path.Exists(BaseDirPath))
{
CopyDirectory(oldConfigPath, BaseDirPath);
Directory.Delete(oldConfigPath, true);
@ -115,6 +115,14 @@ namespace Ryujinx.Common.Configuration
Directory.CreateDirectory(KeysDirPath = Path.Combine(BaseDirPath, KeysDir));
}
// Check if existing old baseDirPath is a symlink, to prevent possible errors.
// Should be removed, when the existance of the old directory isn't checked anymore.
private static bool IsPathSymlink(string path)
{
FileAttributes attributes = File.GetAttributes(path);
return (attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint;
}
private static void CopyDirectory(string sourceDir, string destinationDir)
{
var dir = new DirectoryInfo(sourceDir);

View File

@ -181,7 +181,7 @@ namespace Ryujinx.HLE.FileSystem
}
}
if (_locationEntries.ContainsKey(storageId) && _locationEntries[storageId]?.Count == 0)
if (_locationEntries.TryGetValue(storageId, out var locationEntriesItem) && locationEntriesItem?.Count == 0)
{
_locationEntries.Remove(storageId);
}
@ -347,9 +347,9 @@ namespace Ryujinx.HLE.FileSystem
{
lock (_lock)
{
if (_contentDictionary.ContainsKey((titleId, contentType)))
if (_contentDictionary.TryGetValue((titleId, contentType), out var contentDictionaryItem))
{
return UInt128Utils.FromHex(_contentDictionary[(titleId, contentType)]);
return UInt128Utils.FromHex(contentDictionaryItem);
}
}
@ -719,9 +719,9 @@ namespace Ryujinx.HLE.FileSystem
Nca nca = new Nca(_virtualFileSystem.KeySet, storage);
if (updateNcas.ContainsKey(nca.Header.TitleId))
if (updateNcas.TryGetValue(nca.Header.TitleId, out var updateNcasItem))
{
updateNcas[nca.Header.TitleId].Add((nca.Header.ContentType, entry.FullName));
updateNcasItem.Add((nca.Header.ContentType, entry.FullName));
}
else
{
@ -732,10 +732,8 @@ namespace Ryujinx.HLE.FileSystem
}
}
if (updateNcas.ContainsKey(SystemUpdateTitleId))
if (updateNcas.TryGetValue(SystemUpdateTitleId, out var ncaEntry))
{
var ncaEntry = updateNcas[SystemUpdateTitleId];
string metaPath = ncaEntry.Find(x => x.type == NcaContentType.Meta).path;
CnmtContentMetaEntry[] metaEntries = null;
@ -770,9 +768,9 @@ namespace Ryujinx.HLE.FileSystem
throw new FileNotFoundException("System update title was not found in the firmware package.");
}
if (updateNcas.ContainsKey(SystemVersionTitleId))
if (updateNcas.TryGetValue(SystemVersionTitleId, out var updateNcasItem))
{
string versionEntry = updateNcas[SystemVersionTitleId].Find(x => x.type != NcaContentType.Meta).path;
string versionEntry = updateNcasItem.Find(x => x.type != NcaContentType.Meta).path;
using (Stream ncaStream = GetZipStream(archive.GetEntry(versionEntry)))
{
@ -916,9 +914,9 @@ namespace Ryujinx.HLE.FileSystem
}
}
if (updateNcas.ContainsKey(nca.Header.TitleId))
if (updateNcas.TryGetValue(nca.Header.TitleId, out var updateNcasItem))
{
updateNcas[nca.Header.TitleId].Add((nca.Header.ContentType, entry.FullPath));
updateNcasItem.Add((nca.Header.ContentType, entry.FullPath));
}
else
{

View File

@ -0,0 +1,17 @@
using System.Text.RegularExpressions;
namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
{
public static partial class CJKCharacterValidation
{
public static bool IsCJK(char value)
{
Regex regex = CJKRegex();
return regex.IsMatch(value.ToString());
}
[GeneratedRegex("\\p{IsHangulJamo}|\\p{IsCJKRadicalsSupplement}|\\p{IsCJKSymbolsandPunctuation}|\\p{IsEnclosedCJKLettersandMonths}|\\p{IsCJKCompatibility}|\\p{IsCJKUnifiedIdeographsExtensionA}|\\p{IsCJKUnifiedIdeographs}|\\p{IsHangulSyllables}|\\p{IsCJKCompatibilityForms}")]
private static partial Regex CJKRegex();
}
}

View File

@ -6,22 +6,30 @@
public enum KeyboardMode : uint
{
/// <summary>
/// A full alpha-numeric keyboard.
/// All UTF-16 characters allowed.
/// </summary>
Default = 0,
/// <summary>
/// Number pad.
/// Only numbers allowed.
/// </summary>
NumbersOnly = 1,
/// <summary>
/// ASCII characters keyboard.
/// Only ASCII characters allowed.
/// </summary>
ASCII = 2,
FullLatin = 3,
Alphabet = 4,
/// <summary>
/// Synonymous with default.
/// </summary>
FullLatin = 3,
/// <summary>
/// All UTF-16 characters except CJK characters allowed.
/// </summary>
Alphabet = 4,
SimplifiedChinese = 5,
TraditionalChinese = 6,
Korean = 7,

View File

@ -338,12 +338,10 @@ namespace Ryujinx.Input.Motion.CemuHook
{
int slot = inputData.Shared.Slot;
if (_motionData.ContainsKey(clientId))
if (_motionData.TryGetValue(clientId, out var motionDataItem))
{
if (_motionData[clientId].ContainsKey(slot))
if (motionDataItem.TryGetValue(slot, out var previousData))
{
MotionInput previousData = _motionData[clientId][slot];
previousData.Update(accelerometer, gyroscrope, timestamp, cemuHookConfig.Sensitivity, (float)cemuHookConfig.GyroDeadzone);
}
else
@ -352,7 +350,7 @@ namespace Ryujinx.Input.Motion.CemuHook
input.Update(accelerometer, gyroscrope, timestamp, cemuHookConfig.Sensitivity, (float)cemuHookConfig.GyroDeadzone);
_motionData[clientId].Add(slot, input);
motionDataItem.Add(slot, input);
}
}
else

View File

@ -93,8 +93,8 @@ namespace Ryujinx.Ui.Applet
_checkInput = text => text.All(char.IsDigit);
break;
case KeyboardMode.Alphabet:
_validationInfoText += "<i>Must be alphabets only.</i>";
_checkInput = text => text.All(char.IsAsciiLetter);
_validationInfoText += "<i>Must be non CJK-characters only.</i>";
_checkInput = text => text.All(value => !CJKCharacterValidation.IsCJK(value));
break;
case KeyboardMode.ASCII:
_validationInfoText += "<i>Must be ASCII text only.</i>";