gc_poller.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. } // namespace InputCommon