💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.8 KiB

  1. /*
  2. * Copyright (C) 2021 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_INPUT_DEVICE_HPP
  20. #define ANTKEEPER_INPUT_DEVICE_HPP
  21. #include "event/event-dispatcher.hpp"
  22. #include <string>
  23. namespace input {
  24. /**
  25. * Base class for virtual devices which generate input events.
  26. */
  27. class device
  28. {
  29. public:
  30. device();
  31. virtual ~device() = default;
  32. void set_event_dispatcher(event_dispatcher* event_dispatcher);
  33. const event_dispatcher* get_event_dispatcher() const;
  34. event_dispatcher* get_event_dispatcher();
  35. /**
  36. * Sets the globally unique identifier (GUID) of this input device.
  37. *
  38. * @param guid GUID string.
  39. */
  40. void set_guid(const std::string& guid);
  41. /// Returns the globally unique identifier (GUID) of this input device.
  42. const std::string& get_guid() const;
  43. protected:
  44. event_dispatcher* event_dispatcher;
  45. private:
  46. std::string guid;
  47. };
  48. inline const event_dispatcher* device::get_event_dispatcher() const
  49. {
  50. return event_dispatcher;
  51. }
  52. inline event_dispatcher* device::get_event_dispatcher()
  53. {
  54. return event_dispatcher;
  55. }
  56. inline const std::string& device::get_guid() const
  57. {
  58. return guid;
  59. }
  60. } // namespace input
  61. #endif // ANTKEEPER_INPUT_DEVICE_HPP