gc_poller.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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/gcadapter/gc_adapter.h"
  8. namespace InputCommon {
  9. /**
  10. * A button device factory representing a gcpad. It receives gcpad events and forward them
  11. * to all button devices it created.
  12. */
  13. class GCButtonFactory final : public Input::Factory<Input::ButtonDevice> {
  14. public:
  15. explicit GCButtonFactory(std::shared_ptr<GCAdapter::Adapter> adapter_);
  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<GCAdapter::Adapter> adapter;
  31. bool polling = false;
  32. };
  33. /// An analog device factory that creates analog devices from GC Adapter
  34. class GCAnalogFactory final : public Input::Factory<Input::AnalogDevice> {
  35. public:
  36. explicit GCAnalogFactory(std::shared_ptr<GCAdapter::Adapter> adapter_);
  37. std::unique_ptr<Input::AnalogDevice> Create(const Common::ParamPackage& params) override;
  38. Common::ParamPackage GetNextInput();
  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<GCAdapter::Adapter> adapter;
  47. int analog_x_axis = -1;
  48. int analog_y_axis = -1;
  49. int controller_number = -1;
  50. bool polling = false;
  51. };
  52. /// A vibration device factory creates vibration devices from GC Adapter
  53. class GCVibrationFactory final : public Input::Factory<Input::VibrationDevice> {
  54. public:
  55. explicit GCVibrationFactory(std::shared_ptr<GCAdapter::Adapter> adapter_);
  56. std::unique_ptr<Input::VibrationDevice> Create(const Common::ParamPackage& params) override;
  57. private:
  58. std::shared_ptr<GCAdapter::Adapter> adapter;
  59. };
  60. } // namespace InputCommon