SoftwareKeyboardCalc.cs
1 using System.Runtime.InteropServices; 2 3 namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard 4 { 5 /// <summary> 6 /// A structure with configuration options of the software keyboard when starting a new input request in inline mode. 7 /// </summary> 8 [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)] 9 struct SoftwareKeyboardCalc 10 { 11 public const int InputTextLength = SoftwareKeyboardCalcEx.InputTextLength; 12 13 public uint Unknown; 14 15 /// <summary> 16 /// The size of the Calc struct, as reported by the process communicating with the applet. 17 /// </summary> 18 public ushort Size; 19 20 public byte Unknown1; 21 public byte Unknown2; 22 23 /// <summary> 24 /// Configuration flags. Each bit in the bitfield enabled a different operation of the keyboard 25 /// using the data provided with the Calc structure. 26 /// </summary> 27 public KeyboardCalcFlags Flags; 28 29 /// <summary> 30 /// The original parameters used when initializing the keyboard applet. 31 /// Flag: 0x1 32 /// </summary> 33 public SoftwareKeyboardInitialize Initialize; 34 35 /// <summary> 36 /// The audio volume used by the sound effects of the keyboard. 37 /// Flag: 0x2 38 /// </summary> 39 public float Volume; 40 41 /// <summary> 42 /// The initial position of the text cursor (caret) in the provided input text. 43 /// Flag: 0x10 44 /// </summary> 45 public int CursorPos; 46 47 /// <summary> 48 /// Appearance configurations for the on-screen keyboard. 49 /// </summary> 50 public SoftwareKeyboardAppear Appear; 51 52 /// <summary> 53 /// The initial input text to be used by the software keyboard. 54 /// Flag: 0x8 55 /// </summary> 56 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = InputTextLength + 1)] 57 public string InputText; 58 59 /// <summary> 60 /// When set, the strings communicated by software keyboard will be encoded as UTF-8 instead of UTF-16. 61 /// Flag: 0x20 62 /// </summary> 63 [MarshalAs(UnmanagedType.I1)] 64 public bool UseUtf8; 65 66 public byte Unknown3; 67 68 /// <summary> 69 /// [5.0.0+] Enable the backspace key in the software keyboard. 70 /// Flag: 0x8000 71 /// </summary> 72 [MarshalAs(UnmanagedType.I1)] 73 public bool BackspaceEnabled; 74 75 public short Unknown4; 76 public byte Unknown5; 77 78 /// <summary> 79 /// Flag: 0x200 80 /// </summary> 81 [MarshalAs(UnmanagedType.I1)] 82 public bool KeytopAsFloating; 83 84 /// <summary> 85 /// Flag: 0x100 86 /// </summary> 87 [MarshalAs(UnmanagedType.I1)] 88 public bool FooterScalable; 89 90 /// <summary> 91 /// Flag: 0x100 92 /// </summary> 93 [MarshalAs(UnmanagedType.I1)] 94 public bool AlphaEnabledInInputMode; 95 96 /// <summary> 97 /// Flag: 0x100 98 /// </summary> 99 public byte InputModeFadeType; 100 101 /// <summary> 102 /// When set, the software keyboard ignores touch input. 103 /// Flag: 0x200 104 /// </summary> 105 [MarshalAs(UnmanagedType.I1)] 106 public bool TouchDisabled; 107 108 /// <summary> 109 /// When set, the software keyboard ignores hardware keyboard commands. 110 /// Flag: 0x800 111 /// </summary> 112 [MarshalAs(UnmanagedType.I1)] 113 public bool HardwareKeyboardDisabled; 114 115 public uint Unknown6; 116 public uint Unknown7; 117 118 /// <summary> 119 /// Default value is 1.0. 120 /// Flag: 0x200 121 /// </summary> 122 public float KeytopScale0; 123 124 /// <summary> 125 /// Default value is 1.0. 126 /// Flag: 0x200 127 /// </summary> 128 public float KeytopScale1; 129 130 public float KeytopTranslate0; 131 public float KeytopTranslate1; 132 133 /// <summary> 134 /// Default value is 1.0. 135 /// Flag: 0x100 136 /// </summary> 137 public float KeytopBgAlpha; 138 139 /// <summary> 140 /// Default value is 1.0. 141 /// Flag: 0x100 142 /// </summary> 143 public float FooterBgAlpha; 144 145 /// <summary> 146 /// Default value is 1.0. 147 /// Flag: 0x200 148 /// </summary> 149 public float BalloonScale; 150 151 public float Unknown8; 152 public uint Unknown9; 153 public uint Unknown10; 154 public uint Unknown11; 155 156 /// <summary> 157 /// [5.0.0+] Enable sound effect. 158 /// Flag: Enable: 0x2000 159 /// Disable: 0x4000 160 /// </summary> 161 public byte SeGroup; 162 163 /// <summary> 164 /// [6.0.0+] Enables the Trigger field when Trigger is non-zero. 165 /// </summary> 166 public byte TriggerFlag; 167 168 /// <summary> 169 /// [6.0.0+] Always set to zero. 170 /// </summary> 171 public byte Trigger; 172 173 public byte Padding; 174 175 public SoftwareKeyboardCalcEx ToExtended() 176 { 177 SoftwareKeyboardCalcEx calc = new() 178 { 179 Unknown = Unknown, 180 Size = Size, 181 Unknown1 = Unknown1, 182 Unknown2 = Unknown2, 183 Flags = Flags, 184 Initialize = Initialize, 185 Volume = Volume, 186 CursorPos = CursorPos, 187 Appear = Appear.ToExtended(), 188 InputText = InputText, 189 UseUtf8 = UseUtf8, 190 Unknown3 = Unknown3, 191 BackspaceEnabled = BackspaceEnabled, 192 Unknown4 = Unknown4, 193 Unknown5 = Unknown5, 194 KeytopAsFloating = KeytopAsFloating, 195 FooterScalable = FooterScalable, 196 AlphaEnabledInInputMode = AlphaEnabledInInputMode, 197 InputModeFadeType = InputModeFadeType, 198 TouchDisabled = TouchDisabled, 199 HardwareKeyboardDisabled = HardwareKeyboardDisabled, 200 Unknown6 = Unknown6, 201 Unknown7 = Unknown7, 202 KeytopScale0 = KeytopScale0, 203 KeytopScale1 = KeytopScale1, 204 KeytopTranslate0 = KeytopTranslate0, 205 KeytopTranslate1 = KeytopTranslate1, 206 KeytopBgAlpha = KeytopBgAlpha, 207 FooterBgAlpha = FooterBgAlpha, 208 BalloonScale = BalloonScale, 209 Unknown8 = Unknown8, 210 Unknown9 = Unknown9, 211 Unknown10 = Unknown10, 212 Unknown11 = Unknown11, 213 SeGroup = SeGroup, 214 TriggerFlag = TriggerFlag, 215 Trigger = Trigger, 216 }; 217 218 return calc; 219 } 220 } 221 }