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>
This commit is contained in:
Isaac Marovitz 2023-06-09 11:11:53 +01:00 committed by GitHub
parent 86de288142
commit 2bf4555591
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 9 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

@ -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

@ -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

@ -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>";