gc_poller.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. namespace InputCommon {
  8. /**
  9. * A button device factory representing a gcpad. It receives gcpad events and forward them
  10. * to all button devices it created.
  11. */
  12. class GCButtonFactory final : public Input::Factory<Input::ButtonDevice> {
  13. public:
  14. GCButtonFactory(std::shared_ptr<GCAdapter::Adapter> adapter_);
  15. /**
  16. * Creates a button device from a button press
  17. * @param params contains parameters for creating the device:
  18. * - "code": the code of the key to bind with the button
  19. */
  20. std::unique_ptr<Input::ButtonDevice> Create(const Common::ParamPackage& params) override;
  21. Common::ParamPackage GetNextInput();
  22. /// For device input configuration/polling
  23. void BeginConfiguration();
  24. void EndConfiguration();
  25. bool IsPolling() const {
  26. return polling;
  27. }
  28. private:
  29. std::shared_ptr<GCAdapter::Adapter> adapter;
  30. bool polling = false;
  31. };
  32. /// An analog device factory that creates analog devices from GC Adapter
  33. class GCAnalogFactory final : public Input::Factory<Input::AnalogDevice> {
  34. public:
  35. GCAnalogFactory(std::shared_ptr<GCAdapter::Adapter> adapter_);
  36. std::unique_ptr<Input::AnalogDevice> Create(const Common::ParamPackage& params) override;
  37. Common::ParamPackage GetNextInput();
  38. /// For device input configuration/polling
  39. void BeginConfiguration();
  40. void EndConfiguration();
  41. bool IsPolling() const {
  42. return polling;
  43. }
  44. private:
  45. std::shared_ptr<GCAdapter::Adapter> adapter;
  46. int analog_x_axis = -1;
  47. int analog_y_axis = -1;
  48. int controller_number = -1;
  49. bool polling = false;
  50. };
  51. } // namespace InputCommon