HeadlessDynamicTextInputHandler.cs
1 using Ryujinx.HLE.UI; 2 using System.Threading; 3 using System.Threading.Tasks; 4 5 namespace Ryujinx.Headless.SDL2 6 { 7 /// <summary> 8 /// Headless text processing class, right now there is no way to forward the input to it. 9 /// </summary> 10 internal class HeadlessDynamicTextInputHandler : IDynamicTextInputHandler 11 { 12 private bool _canProcessInput; 13 14 public event DynamicTextChangedHandler TextChangedEvent; 15 public event KeyPressedHandler KeyPressedEvent { add { } remove { } } 16 public event KeyReleasedHandler KeyReleasedEvent { add { } remove { } } 17 18 public bool TextProcessingEnabled 19 { 20 get 21 { 22 return Volatile.Read(ref _canProcessInput); 23 } 24 25 set 26 { 27 Volatile.Write(ref _canProcessInput, value); 28 29 // Launch a task to update the text. 30 Task.Run(() => 31 { 32 Thread.Sleep(100); 33 TextChangedEvent?.Invoke("Ryujinx", 7, 7, false); 34 }); 35 } 36 } 37 38 public HeadlessDynamicTextInputHandler() 39 { 40 // Start with input processing turned off so the text box won't accumulate text 41 // if the user is playing on the keyboard. 42 _canProcessInput = false; 43 } 44 45 public void SetText(string text, int cursorBegin) { } 46 47 public void SetText(string text, int cursorBegin, int cursorEnd) { } 48 49 public void Dispose() { } 50 } 51 }