mouse_poller.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // Copyright 2020 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <memory>
  6. #include "core/frontend/input.h"
  7. #include "input_common/mouse/mouse_input.h"
  8. namespace InputCommon {
  9. /**
  10. * A button device factory representing a mouse. It receives mouse events and forward them
  11. * to all button devices it created.
  12. */
  13. class MouseButtonFactory final : public Input::Factory<Input::ButtonDevice> {
  14. public:
  15. explicit MouseButtonFactory(std::shared_ptr<MouseInput::Mouse> mouse_input_);
  16. /**
  17. * Creates a button device from a button press
  18. * @param params contains parameters for creating the device:
  19. * - "code": the code of the key to bind with the button
  20. */
  21. std::unique_ptr<Input::ButtonDevice> Create(const Common::ParamPackage& params) override;
  22. Common::ParamPackage GetNextInput() const;
  23. /// For device input configuration/polling
  24. void BeginConfiguration();
  25. void EndConfiguration();
  26. bool IsPolling() const {
  27. return polling;
  28. }
  29. private:
  30. std::shared_ptr<MouseInput::Mouse> mouse_input;
  31. bool polling = false;
  32. };
  33. /// An analog device factory that creates analog devices from mouse
  34. class MouseAnalogFactory final : public Input::Factory<Input::AnalogDevice> {
  35. public:
  36. explicit MouseAnalogFactory(std::shared_ptr<MouseInput::Mouse> mouse_input_);
  37. std::unique_ptr<Input::AnalogDevice> Create(const Common::ParamPackage& params) override;
  38. Common::ParamPackage GetNextInput() const;
  39. /// For device input configuration/polling
  40. void BeginConfiguration();
  41. void EndConfiguration();
  42. bool IsPolling() const {
  43. return polling;
  44. }
  45. private:
  46. std::shared_ptr<MouseInput::Mouse> mouse_input;
  47. bool polling = false;
  48. };
  49. /// A motion device factory that creates motion devices from mouse
  50. class MouseMotionFactory final : public Input::Factory<Input::MotionDevice> {
  51. public:
  52. explicit MouseMotionFactory(std::shared_ptr<MouseInput::Mouse> mouse_input_);
  53. std::unique_ptr<Input::MotionDevice> Create(const Common::ParamPackage& params) override;
  54. Common::ParamPackage GetNextInput() const;
  55. /// For device input configuration/polling
  56. void BeginConfiguration();
  57. void EndConfiguration();
  58. bool IsPolling() const {
  59. return polling;
  60. }
  61. private:
  62. std::shared_ptr<MouseInput::Mouse> mouse_input;
  63. bool polling = false;
  64. };
  65. /// An touch device factory that creates touch devices from mouse
  66. class MouseTouchFactory final : public Input::Factory<Input::TouchDevice> {
  67. public:
  68. explicit MouseTouchFactory(std::shared_ptr<MouseInput::Mouse> mouse_input_);
  69. std::unique_ptr<Input::TouchDevice> Create(const Common::ParamPackage& params) override;
  70. Common::ParamPackage GetNextInput() const;
  71. /// For device input configuration/polling
  72. void BeginConfiguration();
  73. void EndConfiguration();
  74. bool IsPolling() const {
  75. return polling;
  76. }
  77. private:
  78. std::shared_ptr<MouseInput::Mouse> mouse_input;
  79. bool polling = false;
  80. };
  81. } // namespace InputCommon