TouchScreenManager.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using Ryujinx.HLE;
  2. using Ryujinx.HLE.HOS.Services.Hid;
  3. using System;
  4. namespace Ryujinx.Input.HLE
  5. {
  6. public class TouchScreenManager : IDisposable
  7. {
  8. private readonly IMouse _mouse;
  9. private Switch _device;
  10. public TouchScreenManager(IMouse mouse)
  11. {
  12. _mouse = mouse;
  13. }
  14. public void Initialize(Switch device)
  15. {
  16. _device = device;
  17. }
  18. public bool Update(bool isFocused, float aspectRatio = 0)
  19. {
  20. if (!isFocused)
  21. {
  22. _device.Hid.Touchscreen.Update();
  23. return false;
  24. }
  25. if (aspectRatio > 0)
  26. {
  27. var snapshot = IMouse.GetMouseStateSnapshot(_mouse);
  28. var touchPosition = IMouse.GetTouchPosition(snapshot.Position, _mouse.ClientSize, aspectRatio);
  29. TouchPoint currentPoint = new TouchPoint
  30. {
  31. X = (uint)touchPosition.X,
  32. Y = (uint)touchPosition.Y,
  33. // Placeholder values till more data is acquired
  34. DiameterX = 10,
  35. DiameterY = 10,
  36. Angle = 90
  37. };
  38. _device.Hid.Touchscreen.Update(currentPoint);
  39. return true;
  40. }
  41. return false;
  42. }
  43. public void Dispose() { }
  44. }
  45. }