diff options
Diffstat (limited to 'platform')
| -rw-r--r-- | platform/iphone/os_iphone.cpp | 6 | ||||
| -rw-r--r-- | platform/isim/detect.py | 15 | ||||
| -rw-r--r-- | platform/osx/SCsub | 1 | ||||
| -rw-r--r-- | platform/osx/dir_access_osx.h | 92 | ||||
| -rw-r--r-- | platform/osx/dir_access_osx.mm | 350 | ||||
| -rw-r--r-- | platform/osx/os_osx.mm | 6 | ||||
| -rw-r--r-- | platform/windows/os_windows.cpp | 2 | ||||
| -rw-r--r-- | platform/windows/stream_peer_winsock.cpp | 8 | ||||
| -rw-r--r-- | platform/windows/stream_peer_winsock.h | 2 | ||||
| -rw-r--r-- | platform/x11/os_x11.cpp | 2 |
10 files changed, 475 insertions, 9 deletions
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index 93f4d00e0..0bc837866 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -226,6 +226,8 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_ queue_event(ev); }; + mouse_list.pressed[p_idx] = p_pressed; + if (p_use_as_mouse) { InputEvent ev; @@ -240,13 +242,13 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_ ev.mouse_button.x = ev.mouse_button.global_x = p_x; ev.mouse_button.y = ev.mouse_button.global_y = p_y; + //mouse_list.pressed[p_idx] = p_pressed; + input->set_mouse_pos(Point2(ev.mouse_motion.x,ev.mouse_motion.y)); ev.mouse_button.button_index = BUTTON_LEFT; ev.mouse_button.doubleclick = p_doubleclick; ev.mouse_button.pressed = p_pressed; - mouse_list.pressed[p_idx] = p_pressed; - queue_event(ev); }; }; diff --git a/platform/isim/detect.py b/platform/isim/detect.py index bd0fd2fea..0adbd9f41 100644 --- a/platform/isim/detect.py +++ b/platform/isim/detect.py @@ -21,8 +21,8 @@ def get_opts(): return [ ('ISIMPLATFORM', 'name of the iphone platform', 'iPhoneSimulator'), - ('ISIMPATH', 'the path to iphone toolchain', '/Applications/Xcode.app/Contents/Developer/Platforms/${ISIMPLATFORM}.platform'), - ('ISIMSDK', 'path to the iphone SDK', '$ISIMPATH/Developer/SDKs/${ISIMPLATFORM}.sdk'), + ('ISIMPATH', 'the path to iphone toolchain', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'), + ('ISIMSDK', 'path to the iphone SDK', '/Applications/Xcode.app/Contents/Developer/Platforms/${ISIMPLATFORM}.platform/Developer/SDKs/${ISIMPLATFORM}.sdk'), ('game_center', 'Support for game center', 'yes'), ('store_kit', 'Support for in-app store', 'yes'), ('ios_gles22_override', 'Force GLES2.0 on iOS', 'yes'), @@ -46,9 +46,10 @@ def configure(env): env['ENV']['PATH'] = env['ISIMPATH']+"/Developer/usr/bin/:"+env['ENV']['PATH'] - env['CC'] = '$ISIMPATH/Developer/usr/bin/gcc' - env['CXX'] = '$ISIMPATH/Developer/usr/bin/g++' - env['AR'] = 'ar' + env['CC'] = '$ISIMPATH/usr/bin/${ios_triple}clang' + env['CXX'] = '$ISIMPATH/usr/bin/${ios_triple}clang++' + env['AR'] = '$ISIMPATH/usr/bin/${ios_triple}ar' + env['RANLIB'] = '$ISIMPATH/usr/bin/${ios_triple}ranlib' import string env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -Wall -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $ISIMSDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"') @@ -97,4 +98,8 @@ def configure(env): env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate' env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-fexceptions']) + import methods + env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) + env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) + env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) diff --git a/platform/osx/SCsub b/platform/osx/SCsub index 4904636af..3785eb3fb 100644 --- a/platform/osx/SCsub +++ b/platform/osx/SCsub @@ -6,6 +6,7 @@ files = [ 'audio_driver_osx.cpp', 'sem_osx.cpp', # 'context_gl_osx.cpp', + 'dir_access_osx.mm', ] env.Program('#bin/godot',files) diff --git a/platform/osx/dir_access_osx.h b/platform/osx/dir_access_osx.h new file mode 100644 index 000000000..abd66cbba --- /dev/null +++ b/platform/osx/dir_access_osx.h @@ -0,0 +1,92 @@ +/*************************************************************************/ +/* dir_access_unix.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef DIR_ACCESS_OSX_H +#define DIR_ACCESS_OSX_H + +#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED) + +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <dirent.h> + +#include "os/dir_access.h" + + +/** + @author Juan Linietsky <reduzio@gmail.com> +*/ +class DirAccessOSX : public DirAccess { + + DIR *dir_stream; + + static DirAccess *create_fs(); + + String current_dir; + bool _cisdir; + bool _cishidden; + +public: + + virtual bool list_dir_begin(); ///< This starts dir listing + virtual String get_next(); + virtual bool current_is_dir() const; + virtual bool current_is_hidden() const; + + virtual void list_dir_end(); ///< + + virtual int get_drive_count(); + virtual String get_drive(int p_drive); + + virtual Error change_dir(String p_dir); ///< can be relative or absolute, return false on success + virtual String get_current_dir(); ///< return current dir location + virtual Error make_dir(String p_dir); + + virtual bool file_exists(String p_file); + virtual bool dir_exists(String p_dir); + + virtual uint64_t get_modified_time(String p_file); + + + + virtual Error rename(String p_from, String p_to); + virtual Error remove(String p_name); + + virtual size_t get_space_left(); + + + DirAccessOSX(); + ~DirAccessOSX(); + +}; + + + +#endif //UNIX ENABLED +#endif diff --git a/platform/osx/dir_access_osx.mm b/platform/osx/dir_access_osx.mm new file mode 100644 index 000000000..cc7db4492 --- /dev/null +++ b/platform/osx/dir_access_osx.mm @@ -0,0 +1,350 @@ +/*************************************************************************/ +/* dir_access_unix.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "dir_access_osx.h" + +#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED) + +#ifndef ANDROID_ENABLED +#include <sys/statvfs.h> +#endif + +#include <stdio.h> +#include "os/memory.h" +#include "print_string.h" +#include <errno.h> + +#include <Foundation/NSString.h> + +DirAccess *DirAccessOSX::create_fs() { + + return memnew( DirAccessOSX ); +} + +bool DirAccessOSX::list_dir_begin() { + + list_dir_end(); //close any previous dir opening! + + +// char real_current_dir_name[2048]; //is this enough?! + //getcwd(real_current_dir_name,2048); + //chdir(curent_path.utf8().get_data()); + dir_stream = opendir(current_dir.utf8().get_data()); + //chdir(real_current_dir_name); + if (!dir_stream) + return true; //error! + + return false; +} + +bool DirAccessOSX::file_exists(String p_file) { + + GLOBAL_LOCK_FUNCTION + + + if (p_file.is_rel_path()) + p_file=current_dir+"/"+p_file; + else + p_file=fix_path(p_file); + + struct stat flags; + bool success = (stat(p_file.utf8().get_data(),&flags)==0); + + if (success && S_ISDIR(flags.st_mode)) { + success=false; + } + + return success; + +} + +bool DirAccessOSX::dir_exists(String p_dir) { + + GLOBAL_LOCK_FUNCTION + + + if (p_dir.is_rel_path()) + p_dir=get_current_dir().plus_file(p_dir); + else + p_dir=fix_path(p_dir); + + struct stat flags; + bool success = (stat(p_dir.utf8().get_data(),&flags)==0); + + if (success && S_ISDIR(flags.st_mode)) + return true; + + return false; + +} + +uint64_t DirAccessOSX::get_modified_time(String p_file) { + + if (p_file.is_rel_path()) + p_file=current_dir+"/"+p_file; + else + p_file=fix_path(p_file); + + struct stat flags; + bool success = (stat(p_file.utf8().get_data(),&flags)==0); + + if (success) { + return flags.st_mtime; + } else { + + ERR_FAIL_V(0); + }; + return 0; +}; + + +String DirAccessOSX::get_next() { + + if (!dir_stream) + return ""; + dirent *entry; + + entry=readdir(dir_stream); + + if (entry==NULL) { + + list_dir_end(); + return ""; + } + + //typedef struct stat Stat; + struct stat flags; + + String fname; + NSString* nsstr = [[NSString stringWithUTF8String: entry->d_name] precomposedStringWithCanonicalMapping]; + + fname.parse_utf8([nsstr UTF8String]); + + //[nsstr autorelease]; + + String f=current_dir+"/"+fname; + + if (stat(f.utf8().get_data(),&flags)==0) { + + if (S_ISDIR(flags.st_mode)) { + + _cisdir=true; + + } else { + + _cisdir=false; + } + + } else { + + _cisdir=false; + + } + + _cishidden=(fname!="." && fname!=".." && fname.begins_with(".")); + + + + return fname; + +} + +bool DirAccessOSX::current_is_dir() const { + + return _cisdir; +} + +bool DirAccessOSX::current_is_hidden() const { + + return _cishidden; +} + + +void DirAccessOSX::list_dir_end() { + + if (dir_stream) + closedir(dir_stream); + dir_stream=0; + _cisdir=false; +} + +int DirAccessOSX::get_drive_count() { + + return 0; +} +String DirAccessOSX::get_drive(int p_drive) { + + return ""; +} + +Error DirAccessOSX::make_dir(String p_dir) { + + GLOBAL_LOCK_FUNCTION + + p_dir=fix_path(p_dir); + + char real_current_dir_name[2048]; + getcwd(real_current_dir_name,2048); + chdir(current_dir.utf8().get_data()); //ascii since this may be unicode or wathever the host os wants + + bool success=(mkdir(p_dir.utf8().get_data(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)==0); + int err = errno; + + chdir(real_current_dir_name); + + if (success) { + return OK; + }; + + if (err == EEXIST) { + return ERR_ALREADY_EXISTS; + }; + + return ERR_CANT_CREATE; +} + + +Error DirAccessOSX::change_dir(String p_dir) { + + GLOBAL_LOCK_FUNCTION + p_dir=fix_path(p_dir); + + + char real_current_dir_name[2048]; + getcwd(real_current_dir_name,2048); + String prev_dir; + if (prev_dir.parse_utf8(real_current_dir_name)) + prev_dir=real_current_dir_name; //no utf8, maybe latin? + + chdir(current_dir.utf8().get_data()); //ascii since this may be unicode or wathever the host os wants + bool worked=(chdir(p_dir.utf8().get_data())==0); // we can only give this utf8 +#ifndef IPHONE_ENABLED + String base = _get_root_path(); + if (base!="") { + + getcwd(real_current_dir_name,2048); + String new_dir; + new_dir.parse_utf8(real_current_dir_name); + if (!new_dir.begins_with(base)) + worked=false; + } +#endif + if (worked) { + + getcwd(real_current_dir_name,2048); + if (current_dir.parse_utf8(real_current_dir_name)) + current_dir=real_current_dir_name; //no utf8, maybe latin? + } + + chdir(prev_dir.utf8().get_data()); + return worked?OK:ERR_INVALID_PARAMETER; + +} + +String DirAccessOSX::get_current_dir() { + + String base = _get_root_path(); + if (base!="") { + + String bd = current_dir.replace_first(base,""); + if (bd.begins_with("/")) + return _get_root_string()+bd.substr(1,bd.length()); + else + return _get_root_string()+bd; + + } + return current_dir; +} + +Error DirAccessOSX::rename(String p_path,String p_new_path) { + + if (p_path.is_rel_path()) + p_path=get_current_dir().plus_file(p_path); + else + p_path=fix_path(p_path); + + if (p_new_path.is_rel_path()) + p_new_path=get_current_dir().plus_file(p_new_path); + else + p_new_path=fix_path(p_new_path); + + return ::rename(p_path.utf8().get_data(),p_new_path.utf8().get_data())==0?OK:FAILED; +} +Error DirAccessOSX::remove(String p_path) { + + p_path=fix_path(p_path); + + struct stat flags; + if ((stat(p_path.utf8().get_data(),&flags)!=0)) + return FAILED; + + if (S_ISDIR(flags.st_mode)) + return ::rmdir(p_path.utf8().get_data())==0?OK:FAILED; + else + return ::unlink(p_path.utf8().get_data())==0?OK:FAILED; +} + + +size_t DirAccessOSX::get_space_left() { + +#ifndef NO_STATVFS + struct statvfs vfs; + if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) { + + return -1; + }; + + return vfs.f_bfree * vfs.f_bsize; +#else +#warning THIS IS BROKEN + return 0; +#endif +}; + + + +DirAccessOSX::DirAccessOSX() { + + dir_stream=0; + current_dir="."; + _cisdir=false; + + /* determine drive count */ + + change_dir(current_dir); + +} + + +DirAccessOSX::~DirAccessOSX() { + + list_dir_end(); +} + + +#endif //posix_enabled diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 4990d04ab..5a06d4b0e 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -47,6 +47,7 @@ #include "servers/visual/visual_server_wrap_mt.h" #include "main/main.h" #include "os/keyboard.h" +#include "dir_access_osx.h" #include <sys/types.h> #include <sys/stat.h> @@ -849,6 +850,11 @@ OS::VideoMode OS_OSX::get_default_video_mode() const { void OS_OSX::initialize_core() { OS_Unix::initialize_core(); + + DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_RESOURCES); + DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_USERDATA); + DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_FILESYSTEM); + SemaphoreOSX::make_default(); } diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 1fb8e6dbd..49ce1d3b9 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -148,7 +148,7 @@ const char * OS_Windows::get_video_driver_name(int p_driver) const { OS::VideoMode OS_Windows::get_default_video_mode() const { - return VideoMode(800,600,false); + return VideoMode(1280,720,false); } int OS_Windows::get_audio_driver_count() const { diff --git a/platform/windows/stream_peer_winsock.cpp b/platform/windows/stream_peer_winsock.cpp index e8245c92e..5bc3e3410 100644 --- a/platform/windows/stream_peer_winsock.cpp +++ b/platform/windows/stream_peer_winsock.cpp @@ -342,6 +342,14 @@ void StreamPeerWinsock::set_nodelay(bool p_enabled) { setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(int)); } +int StreamPeerWinsock::get_available_bytes() const { + + unsigned long len; + int ret = ioctlsocket(sockfd,FIONREAD,&len); + ERR_FAIL_COND_V(ret==-1,0) + return len; + +} IP_Address StreamPeerWinsock::get_connected_host() const { diff --git a/platform/windows/stream_peer_winsock.h b/platform/windows/stream_peer_winsock.h index 373b502d2..5dd836aa0 100644 --- a/platform/windows/stream_peer_winsock.h +++ b/platform/windows/stream_peer_winsock.h @@ -66,6 +66,8 @@ public: virtual Error get_data(uint8_t* p_buffer, int p_bytes); virtual Error get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_received); + virtual int get_available_bytes() const; + void set_socket(int p_sockfd, IP_Address p_host, int p_port); virtual IP_Address get_connected_host() const; diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 4f1b475d0..13dc1069a 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -82,7 +82,7 @@ const char * OS_X11::get_video_driver_name(int p_driver) const { } OS::VideoMode OS_X11::get_default_video_mode() const { - return OS::VideoMode(800,600,false); + return OS::VideoMode(1280,720,false); } int OS_X11::get_audio_driver_count() const { |
