keyboard.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2017 Citra 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. class KeyButtonList;
  9. /**
  10. * A button device factory representing a keyboard. It receives keyboard events and forward them
  11. * to all button devices it created.
  12. */
  13. class Keyboard final : public Input::Factory<Input::ButtonDevice> {
  14. public:
  15. Keyboard();
  16. /**
  17. * Creates a button device from a keyboard key
  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. /**
  23. * Sets the status of all buttons bound with the key to pressed
  24. * @param key_code the code of the key to press
  25. */
  26. void PressKey(int key_code);
  27. /**
  28. * Sets the status of all buttons bound with the key to released
  29. * @param key_code the code of the key to release
  30. */
  31. void ReleaseKey(int key_code);
  32. private:
  33. std::shared_ptr<KeyButtonList> key_button_list;
  34. };
  35. } // namespace InputCommon