display_server_macos_base.h 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**************************************************************************/
  2. /* display_server_macos_base.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #pragma once
  31. #include "core/input/input.h"
  32. #include "servers/display_server.h"
  33. #define FontVariation __FontVariation
  34. #import <AppKit/AppKit.h>
  35. #undef FontVariation
  36. class DisplayServerMacOSBase : public DisplayServer {
  37. GDSOFTCLASS(DisplayServerMacOSBase, DisplayServer)
  38. id tts = nullptr;
  39. struct LayoutInfo {
  40. String name;
  41. String code;
  42. };
  43. mutable Vector<LayoutInfo> kbd_layouts;
  44. mutable int current_layout = 0;
  45. mutable bool keyboard_layout_dirty = true;
  46. protected:
  47. _THREAD_SAFE_CLASS_
  48. void initialize_tts() const;
  49. void _update_keyboard_layouts() const;
  50. static void _keyboard_layout_changed(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef user_info);
  51. public:
  52. virtual void clipboard_set(const String &p_text) override;
  53. virtual String clipboard_get() const override;
  54. virtual Ref<Image> clipboard_get_image() const override;
  55. virtual bool clipboard_has() const override;
  56. virtual bool clipboard_has_image() const override;
  57. virtual int keyboard_get_layout_count() const override;
  58. virtual int keyboard_get_current_layout() const override;
  59. virtual void keyboard_set_current_layout(int p_index) override;
  60. virtual String keyboard_get_layout_language(int p_index) const override;
  61. virtual String keyboard_get_layout_name(int p_index) const override;
  62. virtual Key keyboard_get_keycode_from_physical(Key p_keycode) const override;
  63. virtual Key keyboard_get_label_from_physical(Key p_keycode) const override;
  64. virtual void show_emoji_and_symbol_picker() const override;
  65. virtual bool tts_is_speaking() const override;
  66. virtual bool tts_is_paused() const override;
  67. virtual TypedArray<Dictionary> tts_get_voices() const override;
  68. virtual void tts_speak(const String &p_text, const String &p_voice, int p_volume = 50, float p_pitch = 1.f, float p_rate = 1.f, int p_utterance_id = 0, bool p_interrupt = false) override;
  69. virtual void tts_pause() override;
  70. virtual void tts_resume() override;
  71. virtual void tts_stop() override;
  72. DisplayServerMacOSBase();
  73. ~DisplayServerMacOSBase();
  74. };