diff --git a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/InitialCursorPosition.cs b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/InitialCursorPosition.cs new file mode 100644 index 0000000000..8e5fea7c6f --- /dev/null +++ b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/InitialCursorPosition.cs @@ -0,0 +1,18 @@ +namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard +{ + /// + /// Identifies the initial position of the cursor displayed in the area. + /// + internal enum InitialCursorPosition : uint + { + /// + /// Position the cursor at the beginning of the text + /// + Start, + + /// + /// Position the cursor at the end of the text + /// + End + } +} diff --git a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/InputFormMode.cs b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/InputFormMode.cs new file mode 100644 index 0000000000..80cfae6d4d --- /dev/null +++ b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/InputFormMode.cs @@ -0,0 +1,18 @@ +namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard +{ + /// + /// Identifies the text entry mode. + /// + internal enum InputFormMode : uint + { + /// + /// Displays the text entry area as a single-line field. + /// + SingleLine, + + /// + /// Displays the text entry area as a multi-line field. + /// + MultiLine + } +} diff --git a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/InvalidCharFlags.cs b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/InvalidCharFlags.cs new file mode 100644 index 0000000000..d7b25efccd --- /dev/null +++ b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/InvalidCharFlags.cs @@ -0,0 +1,56 @@ +using System; + +namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard +{ + /// + /// Identifies prohibited character sets. + /// + [Flags] + internal enum InvalidCharFlags : uint + { + /// + /// No characters are prohibited. + /// + None = 0 << 1, + + /// + /// Prohibits spaces. + /// + Space = 1 << 1, + + /// + /// Prohibits the at (@) symbol. + /// + AtSymbol = 1 << 2, + + /// + /// Prohibits the percent (%) symbol. + /// + Percent = 1 << 3, + + /// + /// Prohibits the forward slash (/) symbol. + /// + ForwardSlash = 1 << 4, + + /// + /// Prohibits the backward slash (\) symbol. + /// + BackSlash = 1 << 5, + + /// + /// Prohibits numbers. + /// + Numbers = 1 << 6, + + /// + /// Prohibits characters outside of those allowed in download codes. + /// + DownloadCode = 1 << 7, + + /// + /// Prohibits characters outside of those allowed in Mii Nicknames. + /// + Username = 1 << 8 + } +} diff --git a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/KeyboardMode.cs b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/KeyboardMode.cs new file mode 100644 index 0000000000..6cfd99cdfb --- /dev/null +++ b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/KeyboardMode.cs @@ -0,0 +1,28 @@ +namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard +{ + /// + /// Identifies the variant of keyboard displayed on screen. + /// + internal enum KeyboardMode : uint + { + /// + /// A full alpha-numeric keyboard. + /// + Default, + + /// + /// Number pad. + /// + NumbersOnly, + + /// + /// QWERTY (and variants) keyboard only. + /// + LettersOnly, + + /// + /// Unknown keyboard variant. + /// + Unknown + } +} diff --git a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/PasswordMode.cs b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/PasswordMode.cs new file mode 100644 index 0000000000..ac20a46096 --- /dev/null +++ b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/PasswordMode.cs @@ -0,0 +1,18 @@ +namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard +{ + /// + /// Identifies the display mode of text in a password field. + /// + internal enum PasswordMode : uint + { + /// + /// Display input characters. + /// + Disabled, + + /// + /// Hide input characters. + /// + Enabled + } +} diff --git a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs index 8eed33f9e3..c95b79df00 100644 --- a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs +++ b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs @@ -1,5 +1,4 @@ -using Ryujinx.Common.Logging; -using Ryujinx.HLE.HOS.Applets.SoftwareKeyboard; +using Ryujinx.HLE.HOS.Applets.SoftwareKeyboard; using Ryujinx.HLE.HOS.Services.Am.AppletAE; using System; using System.IO; @@ -43,7 +42,11 @@ namespace Ryujinx.HLE.HOS.Applets var transferMemory = _normalSession.Pop(); _keyboardConfig = ReadStruct(keyboardConfig); - _encoding = _keyboardConfig.UseUtf8 ? Encoding.UTF8 : Encoding.Unicode; + + if (_keyboardConfig.UseUtf8) + { + _encoding = Encoding.UTF8; + } _state = SoftwareKeyboardState.Ready; @@ -90,7 +93,17 @@ namespace Ryujinx.HLE.HOS.Applets } // Does the application want to validate the text itself? - if (!_keyboardConfig.CheckText) + if (_keyboardConfig.CheckText) + { + // The application needs to validate the response, so we + // submit it to the interactive output buffer, and poll it + // for validation. Once validated, the application will submit + // back a validation status, which is handled in OnInteractiveDataPushIn. + _state = SoftwareKeyboardState.ValidationPending; + + _interactiveSession.Push(BuildResponse(_textValue, true)); + } + else { // If the application doesn't need to validate the response, // we push the data to the non-interactive output buffer @@ -101,16 +114,6 @@ namespace Ryujinx.HLE.HOS.Applets AppletStateChanged?.Invoke(this, null); } - else - { - // The application needs to validate the response, so we - // submit it to the interactive output buffer, and poll it - // for validation. Once validated, the application will submit - // back a validation status, which is handled in OnInteractiveDataPushIn. - _state = SoftwareKeyboardState.ValidationPending; - - _interactiveSession.Push(BuildResponse(_textValue, true)); - } } private void OnInteractiveData(object sender, EventArgs e) diff --git a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardConfig.cs b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardConfig.cs index 92ab6060a8..fd462382bc 100644 --- a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardConfig.cs +++ b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardConfig.cs @@ -3,121 +3,15 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard { /// - /// + /// A structure that defines the configuration options of the software keyboard. /// - internal enum KeyboardMode : uint - { - /// - /// Normal keyboard. - /// - Default, - - /// - /// Number pad. The buttons at the bottom left/right are only available when they're set in the config by leftButtonText / rightButtonText. - /// - NumbersOnly, - - /// - /// QWERTY (and variants) keyboard only. - /// - LettersOnly - } - - /// - /// - /// - internal enum InvalidCharFlags : uint - { - None = 0 << 1, - - Space = 1 << 1, - - AtSymbol = 1 << 2, - - Percent = 1 << 3, - - ForwardSlash = 1 << 4, - - BackSlash = 1 << 5, - - Numbers = 1 << 6, - - DownloadCode = 1 << 7, - - Username = 1 << 8 - - } - - /// - /// - /// - internal enum PasswordMode : uint - { - /// - /// - /// - Disabled, - - /// - /// - /// - Enabled - } - - /// - /// - /// - internal enum InputFormMode : uint - { - /// - /// - /// - SingleLine, - - /// - /// - /// - MultiLine - } - - /// - /// - /// - internal enum InitialCursorPosition : uint - { - /// - /// - /// - Start, - - /// - /// - /// - End - } - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] struct SoftwareKeyboardConfig { - /// - /// - /// - const int SubmitTextLength = 8; - - /// - /// - /// - const int HeaderTextLength = 64; - - /// - /// - /// - const int SubtitleTextLength = 128; - - /// - /// - /// - const int GuideTextLength = 256; + private const int SubmitTextLength = 8; + private const int HeaderTextLength = 64; + private const int SubtitleTextLength = 128; + private const int GuideTextLength = 256; /// /// Type of keyboard. @@ -125,115 +19,118 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard public KeyboardMode Mode; /// - /// + /// The string displayed in the Submit button. /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = SubmitTextLength + 1)] public string SubmitText; /// - /// + /// The character displayed in the left button of the numeric keyboard. + /// This is ignored when Mode is not set to NumbersOnly. /// public char LeftOptionalSymbolKey; /// - /// + /// The character displayed in the right button of the numeric keyboard. + /// This is ignored when Mode is not set to NumbersOnly. /// public char RightOptionalSymbolKey; /// - /// + /// When set, predictive typing is enabled making use of the system dictionary, + /// and any custom user dictionary. /// [MarshalAs(UnmanagedType.I1)] public bool PredictionEnabled; /// - /// + /// Specifies prohibited characters that cannot be input into the text entry area. /// public InvalidCharFlags InvalidCharFlag; /// - /// + /// The initial position of the text cursor displayed in the text entry area. /// public InitialCursorPosition InitialCursorPosition; /// - /// + /// The string displayed in the header area of the keyboard. /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = HeaderTextLength + 1)] public string HeaderText; /// - /// + /// The string displayed in the subtitle area of the keyboard. /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = SubtitleTextLength + 1)] public string SubtitleText; /// - /// + /// The placeholder string displayed in the text entry area when no text is entered. /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = GuideTextLength + 1)] public string GuideText; /// - /// When non-zero, specifies the max string length. When the input is too long, swkbd will stop accepting more input until text is deleted via the B button (Backspace). + /// When non-zero, specifies the maximum allowed length of the string entered into the text entry area. /// public int StringLengthMax; /// - /// When non-zero, specifies the minimum string length. + /// When non-zero, specifies the minimum allowed length of the string entered into the text entry area. /// public int StringLengthMin; /// - /// + /// When enabled, hides input characters as dots in the text entry area. /// public PasswordMode PasswordMode; /// - /// + /// Specifies whether the text entry area is displayed as a single-line entry, or a multi-line entry field. /// public InputFormMode InputFormMode; /// - /// + /// When set, enables or disables the return key. This value is ignored when single-line entry is specified as the InputFormMode. /// [MarshalAs(UnmanagedType.I1)] public bool UseNewLine; /// - /// When set, the software keyboard will return a string UTF-8 encoded, rather than UTF-16. + /// When set, the software keyboard will return a UTF-8 encoded string, rather than UTF-16. /// [MarshalAs(UnmanagedType.I1)] public bool UseUtf8; /// - /// + /// When set, the software keyboard will blur the game application rendered behind the keyboard. /// [MarshalAs(UnmanagedType.I1)] public bool UseBlurBackground; /// - /// + /// Offset into the work buffer of the initial text when the keyboard is first displayed. /// public int InitialStringOffset; /// - /// + /// Length of the initial text. /// public int InitialStringLength; /// - /// + /// Offset into the work buffer of the custom user dictionary. /// public int CustomDictionaryOffset; /// - /// + /// Number of entries in the custom user dictionary. /// public int CustomDictionaryCount; /// - /// When set, the application will validate the entered text whilst the swkbd is still on screen. + /// When set, the text entered will be validated on the application side after the keyboard has been submitted. /// [MarshalAs(UnmanagedType.I1)] public bool CheckText; diff --git a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardState.cs b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardState.cs index 42a2831ec9..072682480c 100644 --- a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardState.cs +++ b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardState.cs @@ -1,5 +1,8 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard { + /// + /// Identifies the software keyboard state. + /// internal enum SoftwareKeyboardState { ///