input_converter.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright 2021 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included
  4. #pragma once
  5. namespace Input {
  6. struct CallbackStatus;
  7. };
  8. namespace Core::HID {
  9. /**
  10. * Converts raw input data into a valid battery status.
  11. *
  12. * @param Supported callbacks: Analog, Battery, Trigger.
  13. * @return A valid BatteryStatus object.
  14. */
  15. Input::BatteryStatus TransformToBattery(const Input::CallbackStatus& callback);
  16. /**
  17. * Converts raw input data into a valid button status. Applies invert properties to the output.
  18. *
  19. * @param Supported callbacks: Analog, Button, Trigger.
  20. * @return A valid TouchStatus object.
  21. */
  22. Input::ButtonStatus TransformToButton(const Input::CallbackStatus& callback);
  23. /**
  24. * Converts raw input data into a valid motion status.
  25. *
  26. * @param Supported callbacks: Motion.
  27. * @return A valid TouchStatus object.
  28. */
  29. Input::MotionStatus TransformToMotion(const Input::CallbackStatus& callback);
  30. /**
  31. * Converts raw input data into a valid stick status. Applies offset, deadzone, range and invert
  32. * properties to the output.
  33. *
  34. * @param Supported callbacks: Stick.
  35. * @return A valid StickStatus object.
  36. */
  37. Input::StickStatus TransformToStick(const Input::CallbackStatus& callback);
  38. /**
  39. * Converts raw input data into a valid touch status.
  40. *
  41. * @param Supported callbacks: Touch.
  42. * @return A valid TouchStatus object.
  43. */
  44. Input::TouchStatus TransformToTouch(const Input::CallbackStatus& callback);
  45. /**
  46. * Converts raw input data into a valid trigger status. Applies offset, deadzone, range and
  47. * invert properties to the output. Button status uses the threshold property if necessary.
  48. *
  49. * @param Supported callbacks: Analog, Button, Trigger.
  50. * @return A valid TriggerStatus object.
  51. */
  52. Input::TriggerStatus TransformToTrigger(const Input::CallbackStatus& callback);
  53. /**
  54. * Converts raw analog data into a valid analog value
  55. * @param An analog object containing raw data and properties, bool that determines if the value
  56. * needs to be clamped between -1.0f and 1.0f.
  57. */
  58. void SanitizeAnalog(Input::AnalogStatus& analog, bool clamp_value);
  59. /**
  60. * Converts raw stick data into a valid stick value
  61. * @param Two analog objects containing raw data and properties, bool that determines if the value
  62. * needs to be clamped into the unit circle.
  63. */
  64. void SanitizeStick(Input::AnalogStatus& analog_x, Input::AnalogStatus& analog_y, bool clamp_value);
  65. } // namespace Core::HID