diff options
Diffstat (limited to 'platform/osx')
| -rw-r--r-- | platform/osx/audio_driver_osx.cpp | 7 | ||||
| -rw-r--r-- | platform/osx/export/export.cpp | 24 | ||||
| -rw-r--r-- | platform/osx/os_osx.h | 2 | ||||
| -rw-r--r-- | platform/osx/os_osx.mm | 108 |
4 files changed, 57 insertions, 84 deletions
diff --git a/platform/osx/audio_driver_osx.cpp b/platform/osx/audio_driver_osx.cpp index a4233b5264..dabc7989c0 100644 --- a/platform/osx/audio_driver_osx.cpp +++ b/platform/osx/audio_driver_osx.cpp @@ -60,13 +60,14 @@ Error AudioDriverOSX::initDevice() { zeromem(&desc, sizeof(desc)); desc.componentType = kAudioUnitType_Output; - desc.componentSubType = 0; /* !!! FIXME: ? */ - comp = AudioComponentFindNext(NULL, &desc); + desc.componentSubType = kAudioUnitSubType_HALOutput; desc.componentManufacturer = kAudioUnitManufacturer_Apple; + comp = AudioComponentFindNext(NULL, &desc); + ERR_FAIL_COND_V(comp == NULL, FAILED); + result = AudioComponentInstanceNew(comp, &audio_unit); ERR_FAIL_COND_V(result != noErr, FAILED); - ERR_FAIL_COND_V(comp == NULL, FAILED); result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_StreamFormat, scope, bus, &strdesc, sizeof(strdesc)); ERR_FAIL_COND_V(result != noErr, FAILED); diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index ca5535f771..03f424de8d 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -32,13 +32,13 @@ #include "editor/editor_export.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" -#include "global_config.h" #include "io/marshalls.h" #include "io/resource_saver.h" #include "io/zip_io.h" #include "os/file_access.h" #include "os/os.h" #include "platform/osx/logo.gen.h" +#include "project_settings.h" #include "string.h" #include "version.h" #include <sys/stat.h> @@ -64,6 +64,7 @@ protected: public: virtual String get_name() const { return "Mac OSX"; } + virtual String get_os_name() const { return "OSX"; } virtual Ref<Texture> get_logo() const { return logo; } #ifdef OSX_ENABLED @@ -75,6 +76,13 @@ public: virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const; + virtual void get_platform_features(List<String> *r_features) { + + r_features->push_back("pc"); + r_features->push_back("s3tc"); + r_features->push_back("OSX"); + } + EditorExportPlatformOSX(); ~EditorExportPlatformOSX(); }; @@ -275,8 +283,8 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p String pkg_name; if (p_preset->get("application/name") != "") pkg_name = p_preset->get("application/name"); // app_name - else if (String(GlobalConfig::get_singleton()->get("application/name")) != "") - pkg_name = String(GlobalConfig::get_singleton()->get("application/name")); + else if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") + pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name")); else pkg_name = "Unnamed"; @@ -345,7 +353,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p if (p_preset->get("application/icon") != "") iconpath = p_preset->get("application/icon"); else - iconpath = GlobalConfig::get_singleton()->get("application/config/icon"); + iconpath = ProjectSettings::get_singleton()->get("application/config/icon"); print_line("icon? " + iconpath); if (iconpath != "") { Ref<Image> icon; @@ -438,7 +446,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p /** When exporting for OSX from any other platform we don't have access to code signing or creating DMGs so we'll wrap the bundle into a zip file. - Should probably find a nicer way to have just one export method instead of duplicating the method like this but I would the code got very + Should probably find a nicer way to have just one export method instead of duplicating the method like this but I would the code got very messy with switches inside of it. **/ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { @@ -484,8 +492,8 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p String pkg_name; if (p_preset->get("application/name") != "") pkg_name = p_preset->get("application/name"); // app_name - else if (String(GlobalConfig::get_singleton()->get("application/config/name")) != "") - pkg_name = String(GlobalConfig::get_singleton()->get("application/config/name")); + else if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") + pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name")); else pkg_name = "Unnamed"; @@ -539,7 +547,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p if (p_preset->get("application/icon") != "") iconpath = p_preset->get("application/icon"); else - iconpath = GlobalConfig::get_singleton()->get("application/config/icon"); + iconpath = ProjectSettings::get_singleton()->get("application/config/icon"); print_line("icon? " + iconpath); if (iconpath != "") { Ref<Image> icon; diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index a3036b1a8a..44f4334786 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -210,6 +210,8 @@ public: virtual int get_power_seconds_left(); virtual int get_power_percent_left(); + virtual bool _check_internal_feature_support(const String &p_feature); + void run(); void set_mouse_mode(MouseMode p_mode); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 87c25a5356..82c1313326 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -80,6 +80,7 @@ static int mouse_y = 0; static int prev_mouse_x = 0; static int prev_mouse_y = 0; static int button_mask = 0; +static bool mouse_down_control = false; @interface GodotApplication : NSApplication @end @@ -285,41 +286,48 @@ static int button_mask = 0; //setModeCursor(window, window->cursorMode); } -- (void)mouseDown:(NSEvent *)event { - - button_mask |= BUTTON_MASK_LEFT; +static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) { + if (pressed) { + button_mask |= mask; + } else { + button_mask &= ~mask; + } Ref<InputEventMouseButton> mb; mb.instance(); get_key_modifier_state([event modifierFlags], mb); - mb->set_button_index(BUTTON_LEFT); - mb->set_pressed(true); + mb->set_button_index(index); + mb->set_pressed(pressed); mb->set_position(Vector2(mouse_x, mouse_y)); mb->set_global_position(Vector2(mouse_x, mouse_y)); mb->set_button_mask(button_mask); - mb->set_doubleclick([event clickCount] == 2); + if (index == BUTTON_LEFT && pressed) { + mb->set_doubleclick([event clickCount] == 2); + } OS_OSX::singleton->push_input(mb); } +- (void)mouseDown:(NSEvent *)event { + if (([event modifierFlags] & NSControlKeyMask)) { + mouse_down_control = true; + _mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, true); + } else { + mouse_down_control = false; + _mouseDownEvent(event, BUTTON_LEFT, BUTTON_MASK_LEFT, true); + } +} + - (void)mouseDragged:(NSEvent *)event { [self mouseMoved:event]; } - (void)mouseUp:(NSEvent *)event { - - button_mask &= ~BUTTON_MASK_LEFT; - Ref<InputEventMouseButton> mb; - mb.instance(); - - get_key_modifier_state([event modifierFlags], mb); - mb->set_button_index(BUTTON_LEFT); - mb->set_pressed(false); - mb->set_position(Vector2(mouse_x, mouse_y)); - mb->set_global_position(Vector2(mouse_x, mouse_y)); - mb->set_button_mask(button_mask); - mb->set_doubleclick([event clickCount] == 2); - OS_OSX::singleton->push_input(mb); + if (mouse_down_control) { + _mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, false); + } else { + _mouseDownEvent(event, BUTTON_LEFT, BUTTON_MASK_LEFT, false); + } } - (void)mouseMoved:(NSEvent *)event { @@ -347,20 +355,7 @@ static int button_mask = 0; } - (void)rightMouseDown:(NSEvent *)event { - - button_mask |= BUTTON_MASK_RIGHT; - - Ref<InputEventMouseButton> mb; - mb.instance(); - - get_key_modifier_state([event modifierFlags], mb); - mb->set_button_index(BUTTON_RIGHT); - mb->set_pressed(true); - mb->set_position(Vector2(mouse_x, mouse_y)); - mb->set_global_position(Vector2(mouse_x, mouse_y)); - mb->set_button_mask(button_mask); - mb->set_doubleclick([event clickCount] == 2); - OS_OSX::singleton->push_input(mb); + _mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, true); } - (void)rightMouseDragged:(NSEvent *)event { @@ -368,20 +363,7 @@ static int button_mask = 0; } - (void)rightMouseUp:(NSEvent *)event { - - button_mask &= ~BUTTON_MASK_RIGHT; - - Ref<InputEventMouseButton> mb; - mb.instance(); - - get_key_modifier_state([event modifierFlags], mb); - mb->set_button_index(BUTTON_RIGHT); - mb->set_pressed(false); - mb->set_position(Vector2(mouse_x, mouse_y)); - mb->set_global_position(Vector2(mouse_x, mouse_y)); - mb->set_button_mask(button_mask); - mb->set_doubleclick([event clickCount] == 2); - OS_OSX::singleton->push_input(mb); + _mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, false); } - (void)otherMouseDown:(NSEvent *)event { @@ -389,19 +371,7 @@ static int button_mask = 0; if ((int)[event buttonNumber] != 2) return; - button_mask |= BUTTON_MASK_MIDDLE; - - Ref<InputEventMouseButton> mb; - mb.instance(); - - get_key_modifier_state([event modifierFlags], mb); - mb->set_button_index(BUTTON_MIDDLE); - mb->set_pressed(true); - mb->set_position(Vector2(mouse_x, mouse_y)); - mb->set_global_position(Vector2(mouse_x, mouse_y)); - mb->set_button_mask(button_mask); - mb->set_doubleclick([event clickCount] == 2); - OS_OSX::singleton->push_input(mb); + _mouseDownEvent(event, BUTTON_MIDDLE, BUTTON_MASK_MIDDLE, true); } - (void)otherMouseDragged:(NSEvent *)event { @@ -413,19 +383,7 @@ static int button_mask = 0; if ((int)[event buttonNumber] != 2) return; - button_mask &= ~BUTTON_MASK_MIDDLE; - - Ref<InputEventMouseButton> mb; - mb.instance(); - - get_key_modifier_state([event modifierFlags], mb); - mb->set_button_index(BUTTON_MIDDLE); - mb->set_pressed(false); - mb->set_position(Vector2(mouse_x, mouse_y)); - mb->set_global_position(Vector2(mouse_x, mouse_y)); - mb->set_button_mask(button_mask); - mb->set_doubleclick([event clickCount] == 2); - OS_OSX::singleton->push_input(mb); + _mouseDownEvent(event, BUTTON_MIDDLE, BUTTON_MASK_MIDDLE, false); } - (void)mouseExited:(NSEvent *)event { @@ -1726,3 +1684,7 @@ OS_OSX::OS_OSX() { zoomed = false; display_scale = 1.0; } + +bool OS_OSX::_check_internal_feature_support(const String &p_feature) { + return p_feature == "pc" || p_feature == "s3tc"; +} |