diff options
Diffstat (limited to '')
| -rw-r--r-- | platform/bb10/audio_driver_bb10.cpp | 37 | ||||
| -rw-r--r-- | platform/bb10/audio_driver_bb10.h | 20 | ||||
| -rw-r--r-- | platform/bb10/export/export.cpp | 555 | ||||
| -rw-r--r-- | platform/bb10/godot_bb10.cpp | 7 | ||||
| -rw-r--r-- | platform/bb10/os_bb10.cpp | 307 | ||||
| -rw-r--r-- | platform/bb10/os_bb10.h | 47 | ||||
| -rw-r--r-- | platform/bb10/payment_service.cpp | 36 | ||||
| -rw-r--r-- | platform/bb10/payment_service.h | 8 |
8 files changed, 472 insertions, 545 deletions
diff --git a/platform/bb10/audio_driver_bb10.cpp b/platform/bb10/audio_driver_bb10.cpp index 7b5c0800a..7218e8a38 100644 --- a/platform/bb10/audio_driver_bb10.cpp +++ b/platform/bb10/audio_driver_bb10.cpp @@ -34,11 +34,11 @@ Error AudioDriverBB10::init() { return init(NULL); }; -Error AudioDriverBB10::init(const char* p_name) { +Error AudioDriverBB10::init(const char *p_name) { - active=false; - thread_exited=false; - exit_thread=false; + active = false; + thread_exited = false; + exit_thread = false; pcm_open = false; samples_in = NULL; samples_out = NULL; @@ -46,11 +46,11 @@ Error AudioDriverBB10::init(const char* p_name) { mix_rate = 44100; output_format = OUTPUT_STEREO; - char* dev_name; + char *dev_name; if (p_name == NULL) { dev_name = "pcmPreferred"; } else { - dev_name = (char *) p_name; + dev_name = (char *)p_name; } printf("******** reconnecting to device %s\n", dev_name); int ret = snd_pcm_open_name(&pcm_handle, dev_name, SND_PCM_OPEN_PLAYBACK); @@ -58,7 +58,7 @@ Error AudioDriverBB10::init(const char* p_name) { pcm_open = true; snd_pcm_channel_info_t cinfo; - zeromem(&cinfo, sizeof (cinfo)); + zeromem(&cinfo, sizeof(cinfo)); cinfo.channel = SND_PCM_CHANNEL_PLAYBACK; snd_pcm_plugin_info(pcm_handle, &cinfo); @@ -117,9 +117,9 @@ Error AudioDriverBB10::init(const char* p_name) { return OK; }; -void AudioDriverBB10::thread_func(void* p_udata) { +void AudioDriverBB10::thread_func(void *p_udata) { - AudioDriverBB10* ad = (AudioDriverBB10*)p_udata; + AudioDriverBB10 *ad = (AudioDriverBB10 *)p_udata; int channels = (ad->output_format == OUTPUT_MONO ? 1 : 2); int frame_count = ad->sample_buf_count / channels; @@ -127,10 +127,9 @@ void AudioDriverBB10::thread_func(void* p_udata) { while (!ad->exit_thread) { - if (!ad->active) { - for (int i=0; i < ad->sample_buf_count; i++) { + for (int i = 0; i < ad->sample_buf_count; i++) { ad->samples_out[i] = 0; }; @@ -142,20 +141,19 @@ void AudioDriverBB10::thread_func(void* p_udata) { ad->unlock(); - for(int i=0;i<frame_count*channels;i++) { + for (int i = 0; i < frame_count * channels; i++) { - ad->samples_out[i]=ad->samples_in[i]>>16; + ad->samples_out[i] = ad->samples_in[i] >> 16; } }; - int todo = bytes_out; int total = 0; while (todo) { - uint8_t* src = (uint8_t*)ad->samples_out; - int wrote = snd_pcm_plugin_write(ad->pcm_handle, (void*)(src + total), todo); + uint8_t *src = (uint8_t *)ad->samples_out; + int wrote = snd_pcm_plugin_write(ad->pcm_handle, (void *)(src + total), todo); if (wrote < 0) { // error? break; @@ -179,7 +177,7 @@ void AudioDriverBB10::thread_func(void* p_udata) { break; }; if (status.status == SND_PCM_STATUS_READY || - status.status == SND_PCM_STATUS_UNDERRUN) { + status.status == SND_PCM_STATUS_UNDERRUN) { snd_pcm_plugin_prepare(ad->pcm_handle, SND_PCM_CHANNEL_PLAYBACK); } else { break; @@ -188,9 +186,9 @@ void AudioDriverBB10::thread_func(void* p_udata) { }; }; - snd_pcm_plugin_flush (ad->pcm_handle, SND_PCM_CHANNEL_PLAYBACK); + snd_pcm_plugin_flush(ad->pcm_handle, SND_PCM_CHANNEL_PLAYBACK); - ad->thread_exited=true; + ad->thread_exited = true; printf("**************** audio thread exit\n"); }; @@ -251,4 +249,3 @@ AudioDriverBB10::~AudioDriverBB10() { memdelete(mutex); mutex = NULL; }; - diff --git a/platform/bb10/audio_driver_bb10.h b/platform/bb10/audio_driver_bb10.h index 738bcf261..be6aabc50 100644 --- a/platform/bb10/audio_driver_bb10.h +++ b/platform/bb10/audio_driver_bb10.h @@ -28,23 +28,23 @@ /*************************************************************************/ #include "servers/audio/audio_server_sw.h" -#include "core/os/thread.h" #include "core/os/mutex.h" +#include "core/os/thread.h" #include <sys/asoundlib.h> class AudioDriverBB10 : public AudioDriverSW { - Thread* thread; - Mutex* mutex; + Thread *thread; + Mutex *mutex; - snd_pcm_t* pcm_handle; + snd_pcm_t *pcm_handle; - int32_t* samples_in; - int16_t* samples_out; + int32_t *samples_in; + int16_t *samples_out; int sample_buf_count; - static void thread_func(void* p_udata); + static void thread_func(void *p_udata); int mix_rate; OutputFormat output_format; @@ -58,13 +58,12 @@ class AudioDriverBB10 : public AudioDriverSW { bool pcm_open; public: - - const char* get_name() const { + const char *get_name() const { return "BB10"; }; virtual Error init(); - virtual Error init(const char* p_name); + virtual Error init(const char *p_name); virtual void start(); virtual int get_mix_rate() const; virtual OutputFormat get_output_format() const; @@ -75,4 +74,3 @@ public: AudioDriverBB10(); ~AudioDriverBB10(); }; - diff --git a/platform/bb10/export/export.cpp b/platform/bb10/export/export.cpp index 620646eb6..7968ecadf 100644 --- a/platform/bb10/export/export.cpp +++ b/platform/bb10/export/export.cpp @@ -26,24 +26,24 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "export.h" -#include "editor/editor_settings.h" #include "editor/editor_import_export.h" #include "editor/editor_node.h" -#include "io/zip_io.h" -#include "io/marshalls.h" +#include "editor/editor_settings.h" #include "globals.h" +#include "io/marshalls.h" +#include "io/xml_parser.h" +#include "io/zip_io.h" #include "os/file_access.h" #include "os/os.h" #include "platform/bb10/logo.h" -#include "io/xml_parser.h" +#include "version.h" #define MAX_DEVICES 5 class EditorExportPlatformBB10 : public EditorExportPlatform { - OBJ_TYPE( EditorExportPlatformBB10,EditorExportPlatform ); + OBJ_TYPE(EditorExportPlatformBB10, EditorExportPlatform); String custom_package; @@ -57,8 +57,6 @@ class EditorExportPlatformBB10 : public EditorExportPlatform { String author_id; String icon; - - struct Device { int index; @@ -74,206 +72,198 @@ class EditorExportPlatformBB10 : public EditorExportPlatform { volatile bool quit_request; - static void _device_poll_thread(void *ud); - void _fix_descriptor(Vector<uint8_t>& p_manifest); -protected: + void _fix_descriptor(Vector<uint8_t> &p_manifest); - bool _set(const StringName& p_name, const Variant& p_value); - bool _get(const StringName& p_name,Variant &r_ret) const; - void _get_property_list( List<PropertyInfo> *p_list) const; +protected: + bool _set(const StringName &p_name, const Variant &p_value); + bool _get(const StringName &p_name, Variant &r_ret) const; + void _get_property_list(List<PropertyInfo> *p_list) const; public: - virtual String get_name() const { return "BlackBerry 10"; } virtual ImageCompression get_image_compression() const { return IMAGE_COMPRESSION_ETC1; } virtual Ref<Texture> get_logo() const { return logo; } - virtual bool poll_devices(); virtual int get_device_count() const; virtual String get_device_name(int p_device) const; virtual String get_device_info(int p_device) const; - virtual Error run(int p_device,int p_flags=0); + virtual Error run(int p_device, int p_flags = 0); virtual bool requires_password(bool p_debug) const { return !p_debug; } virtual String get_binary_extension() const { return "bar"; } - virtual Error export_project(const String& p_path,bool p_debug,int p_flags=0); + virtual Error export_project(const String &p_path, bool p_debug, int p_flags = 0); - virtual bool can_export(String *r_error=NULL) const; + virtual bool can_export(String *r_error = NULL) const; EditorExportPlatformBB10(); ~EditorExportPlatformBB10(); }; -bool EditorExportPlatformBB10::_set(const StringName& p_name, const Variant& p_value) { +bool EditorExportPlatformBB10::_set(const StringName &p_name, const Variant &p_value) { - String n=p_name; + String n = p_name; - if (n=="version/code") - version_code=p_value; - else if (n=="version/name") - version_name=p_value; - else if (n=="package/unique_name") - package=p_value; - else if (n=="package/category") - category=p_value; - else if (n=="package/name") - name=p_value; - else if (n=="package/description") - description=p_value; - else if (n=="package/icon") - icon=p_value; - else if (n=="package/custom_template") - custom_package=p_value; - else if (n=="release/author") - author_name=p_value; - else if (n=="release/author_id") - author_id=p_value; + if (n == "version/code") + version_code = p_value; + else if (n == "version/name") + version_name = p_value; + else if (n == "package/unique_name") + package = p_value; + else if (n == "package/category") + category = p_value; + else if (n == "package/name") + name = p_value; + else if (n == "package/description") + description = p_value; + else if (n == "package/icon") + icon = p_value; + else if (n == "package/custom_template") + custom_package = p_value; + else if (n == "release/author") + author_name = p_value; + else if (n == "release/author_id") + author_id = p_value; else return false; return true; } -bool EditorExportPlatformBB10::_get(const StringName& p_name,Variant &r_ret) const{ +bool EditorExportPlatformBB10::_get(const StringName &p_name, Variant &r_ret) const { - String n=p_name; + String n = p_name; - if (n=="version/code") - r_ret=version_code; - else if (n=="version/name") - r_ret=version_name; - else if (n=="package/unique_name") - r_ret=package; - else if (n=="package/category") - r_ret=category; - else if (n=="package/name") - r_ret=name; - else if (n=="package/description") - r_ret=description; - else if (n=="package/icon") - r_ret=icon; - else if (n=="package/custom_template") - r_ret=custom_package; - else if (n=="release/author") - r_ret=author_name; - else if (n=="release/author_id") - r_ret=author_id; + if (n == "version/code") + r_ret = version_code; + else if (n == "version/name") + r_ret = version_name; + else if (n == "package/unique_name") + r_ret = package; + else if (n == "package/category") + r_ret = category; + else if (n == "package/name") + r_ret = name; + else if (n == "package/description") + r_ret = description; + else if (n == "package/icon") + r_ret = icon; + else if (n == "package/custom_template") + r_ret = custom_package; + else if (n == "release/author") + r_ret = author_name; + else if (n == "release/author_id") + r_ret = author_id; else return false; return true; } -void EditorExportPlatformBB10::_get_property_list( List<PropertyInfo> *p_list) const{ +void EditorExportPlatformBB10::_get_property_list(List<PropertyInfo> *p_list) const { - p_list->push_back( PropertyInfo( Variant::INT, "version/code", PROPERTY_HINT_RANGE,"1,65535,1")); - p_list->push_back( PropertyInfo( Variant::STRING, "version/name") ); - p_list->push_back( PropertyInfo( Variant::STRING, "package/unique_name") ); - p_list->push_back( PropertyInfo( Variant::STRING, "package/category") ); - p_list->push_back( PropertyInfo( Variant::STRING, "package/name") ); - p_list->push_back( PropertyInfo( Variant::STRING, "package/description",PROPERTY_HINT_MULTILINE_TEXT) ); - p_list->push_back( PropertyInfo( Variant::STRING, "package/icon",PROPERTY_HINT_FILE,"png") ); - p_list->push_back( PropertyInfo( Variant::STRING, "package/custom_template", PROPERTY_HINT_GLOBAL_FILE,"zip")); - p_list->push_back( PropertyInfo( Variant::STRING, "release/author") ); - p_list->push_back( PropertyInfo( Variant::STRING, "release/author_id") ); + p_list->push_back(PropertyInfo(Variant::INT, "version/code", PROPERTY_HINT_RANGE, "1,65535,1")); + p_list->push_back(PropertyInfo(Variant::STRING, "version/name")); + p_list->push_back(PropertyInfo(Variant::STRING, "package/unique_name")); + p_list->push_back(PropertyInfo(Variant::STRING, "package/category")); + p_list->push_back(PropertyInfo(Variant::STRING, "package/name")); + p_list->push_back(PropertyInfo(Variant::STRING, "package/description", PROPERTY_HINT_MULTILINE_TEXT)); + p_list->push_back(PropertyInfo(Variant::STRING, "package/icon", PROPERTY_HINT_FILE, "png")); + p_list->push_back(PropertyInfo(Variant::STRING, "package/custom_template", PROPERTY_HINT_GLOBAL_FILE, "zip")); + p_list->push_back(PropertyInfo(Variant::STRING, "release/author")); + p_list->push_back(PropertyInfo(Variant::STRING, "release/author_id")); //p_list->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Copy,Single Exec.,Pack (.pck),Bundles (Optical)")); - } -void EditorExportPlatformBB10::_fix_descriptor(Vector<uint8_t>& p_descriptor) { +void EditorExportPlatformBB10::_fix_descriptor(Vector<uint8_t> &p_descriptor) { - String fpath = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp_bar-settings.xml"); + String fpath = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp_bar-settings.xml"); { - FileAccessRef f = FileAccess::open(fpath,FileAccess::WRITE); - f->store_buffer(p_descriptor.ptr(),p_descriptor.size()); + FileAccessRef f = FileAccess::open(fpath, FileAccess::WRITE); + f->store_buffer(p_descriptor.ptr(), p_descriptor.size()); } - Ref<XMLParser> parser = memnew( XMLParser ); + Ref<XMLParser> parser = memnew(XMLParser); Error err = parser->open(fpath); - ERR_FAIL_COND(err!=OK); + ERR_FAIL_COND(err != OK); String txt; err = parser->read(); Vector<String> depth; - while(err!=ERR_FILE_EOF) { + while (err != ERR_FILE_EOF) { - ERR_FAIL_COND(err!=OK); + ERR_FAIL_COND(err != OK); - switch(parser->get_node_type()) { + switch (parser->get_node_type()) { case XMLParser::NODE_NONE: { print_line("???"); } break; case XMLParser::NODE_ELEMENT: { - String e="<"; - e+=parser->get_node_name(); - for(int i=0;i<parser->get_attribute_count();i++) { - e+=" "; - e+=parser->get_attribute_name(i)+"=\""; - e+=parser->get_attribute_value(i)+"\" "; + String e = "<"; + e += parser->get_node_name(); + for (int i = 0; i < parser->get_attribute_count(); i++) { + e += " "; + e += parser->get_attribute_name(i) + "=\""; + e += parser->get_attribute_value(i) + "\" "; } - - if (parser->is_empty()) { - e+="/"; + e += "/"; } else { depth.push_back(parser->get_node_name()); } - e+=">"; - txt+=e; + e += ">"; + txt += e; } break; case XMLParser::NODE_ELEMENT_END: { - txt+="</"+parser->get_node_name()+">"; - if (depth.size() && depth[depth.size()-1]==parser->get_node_name()) { - depth.resize(depth.size()-1); + txt += "</" + parser->get_node_name() + ">"; + if (depth.size() && depth[depth.size() - 1] == parser->get_node_name()) { + depth.resize(depth.size() - 1); } - } break; case XMLParser::NODE_TEXT: { - if (depth.size()==2 && depth[0]=="qnx" && depth[1]=="id") { + if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "id") { - txt+=package; - } else if (depth.size()==2 && depth[0]=="qnx" && depth[1]=="name") { + txt += package; + } else if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "name") { String aname; - if (this->name!="") { - aname=this->name; + if (this->name != "") { + aname = this->name; } else { aname = Globals::get_singleton()->get("application/name"); - } - if (aname=="") { - aname=_MKSTR(VERSION_NAME); + if (aname == "") { + aname = _MKSTR(VERSION_NAME); } - txt+=aname; + txt += aname; - } else if (depth.size()==2 && depth[0]=="qnx" && depth[1]=="versionNumber") { - txt+=itos(version_code); - } else if (depth.size()==2 && depth[0]=="qnx" && depth[1]=="description") { - txt+=description; - } else if (depth.size()==2 && depth[0]=="qnx" && depth[1]=="author") { - txt+=author_name; - } else if (depth.size()==2 && depth[0]=="qnx" && depth[1]=="authorId") { - txt+=author_id; - } else if (depth.size()==2 && depth[0]=="qnx" && depth[1]=="category") { - txt+=category; + } else if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "versionNumber") { + txt += itos(version_code); + } else if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "description") { + txt += description; + } else if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "author") { + txt += author_name; + } else if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "authorId") { + txt += author_id; + } else if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "category") { + txt += category; } else { - txt+=parser->get_node_data(); + txt += parser->get_node_data(); } } break; case XMLParser::NODE_COMMENT: { - txt+="<!--"+parser->get_node_name()+"-->"; + txt += "<!--" + parser->get_node_name() + "-->"; } break; case XMLParser::NODE_CDATA: { //ignore @@ -281,72 +271,65 @@ void EditorExportPlatformBB10::_fix_descriptor(Vector<uint8_t>& p_descriptor) { } break; case XMLParser::NODE_UNKNOWN: { //ignore - txt+="<"+parser->get_node_name()+">"; + txt += "<" + parser->get_node_name() + ">"; } break; } err = parser->read(); } - CharString cs = txt.utf8(); p_descriptor.resize(cs.length()); - for(int i=0;i<cs.length();i++) - p_descriptor[i]=cs[i]; - + for (int i = 0; i < cs.length(); i++) + p_descriptor[i] = cs[i]; } +Error EditorExportPlatformBB10::export_project(const String &p_path, bool p_debug, int p_flags) { + EditorProgress ep("export", "Exporting for BlackBerry 10", 104); -Error EditorExportPlatformBB10::export_project(const String& p_path, bool p_debug, int p_flags) { - + String src_template = custom_package; - EditorProgress ep("export","Exporting for BlackBerry 10",104); - - String src_template=custom_package; - - if (src_template=="") { + if (src_template == "") { String err; src_template = find_export_template("bb10.zip", &err); - if (src_template=="") { + if (src_template == "") { EditorNode::add_io_error(err); return ERR_FILE_NOT_FOUND; } } - FileAccess *src_f=NULL; + FileAccess *src_f = NULL; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); - ep.step("Creating FileSystem for BAR",0); + ep.step("Creating FileSystem for BAR", 0); unzFile pkg = unzOpen2(src_template.utf8().get_data(), &io); if (!pkg) { - EditorNode::add_io_error("Could not find template zip to export:\n"+src_template); + EditorNode::add_io_error("Could not find template zip to export:\n" + src_template); return ERR_FILE_NOT_FOUND; } DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); da->change_dir(EditorSettings::get_singleton()->get_settings_path()); - - if (da->change_dir("tmp")!=OK) { + if (da->change_dir("tmp") != OK) { da->make_dir("tmp"); - if (da->change_dir("tmp")!=OK) + if (da->change_dir("tmp") != OK) return ERR_CANT_CREATE; } - if (da->change_dir("bb10_export")!=OK) { + if (da->change_dir("bb10_export") != OK) { da->make_dir("bb10_export"); - if (da->change_dir("bb10_export")!=OK) { + if (da->change_dir("bb10_export") != OK) { return ERR_CANT_CREATE; } } - String bar_dir = da->get_current_dir(); if (bar_dir.ends_with("/")) { - bar_dir=bar_dir.substr(0,bar_dir.length()-1); + bar_dir = bar_dir.substr(0, bar_dir.length() - 1); } //THIS IS SUPER, SUPER DANGEROUS!!!! @@ -358,8 +341,8 @@ Error EditorExportPlatformBB10::export_project(const String& p_path, bool p_debu bool berr = bar_dir.ends_with("bb10_export"); if (berr) { if (da->list_dir_begin()) { - EditorNode::add_io_error("Can't ensure that dir is empty:\n"+bar_dir); - ERR_FAIL_COND_V(berr,FAILED); + EditorNode::add_io_error("Can't ensure that dir is empty:\n" + bar_dir); + ERR_FAIL_COND_V(berr, FAILED); }; String f = da->get_next(); @@ -371,8 +354,8 @@ Error EditorExportPlatformBB10::export_project(const String& p_path, bool p_debu }; Error err = da->remove(bar_dir + "/" + f); if (err != OK) { - EditorNode::add_io_error("Can't ensure that dir is empty:\n"+bar_dir); - ERR_FAIL_COND_V(err!=OK,err); + EditorNode::add_io_error("Can't ensure that dir is empty:\n" + bar_dir); + ERR_FAIL_COND_V(err != OK, err); }; f = da->get_next(); }; @@ -384,99 +367,93 @@ Error EditorExportPlatformBB10::export_project(const String& p_path, bool p_debu ERR_FAIL_V(ERR_OMFG_THIS_IS_VERY_VERY_BAD); } - ERR_FAIL_COND_V(!pkg, ERR_CANT_OPEN); int ret = unzGoToFirstFile(pkg); - - - while(ret==UNZ_OK) { + while (ret == UNZ_OK) { //get filename unz_file_info info; char fname[16384]; - ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0); + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); - String file=fname; + String file = fname; Vector<uint8_t> data; data.resize(info.uncompressed_size); //read unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg,data.ptr(),data.size()); + unzReadCurrentFile(pkg, data.ptr(), data.size()); unzCloseCurrentFile(pkg); //write - if (file=="bar-descriptor.xml") { + if (file == "bar-descriptor.xml") { _fix_descriptor(data); } - if (file=="icon.png") { - bool found=false; + if (file == "icon.png") { + bool found = false; - if (this->icon!="" && this->icon.ends_with(".png")) { + if (this->icon != "" && this->icon.ends_with(".png")) { - FileAccess *f = FileAccess::open(this->icon,FileAccess::READ); + FileAccess *f = FileAccess::open(this->icon, FileAccess::READ); if (f) { data.resize(f->get_len()); - f->get_buffer(data.ptr(),data.size()); + f->get_buffer(data.ptr(), data.size()); memdelete(f); - found=true; + found = true; } - } if (!found) { String appicon = Globals::get_singleton()->get("application/icon"); - if (appicon!="" && appicon.ends_with(".png")) { - FileAccess*f = FileAccess::open(appicon,FileAccess::READ); + if (appicon != "" && appicon.ends_with(".png")) { + FileAccess *f = FileAccess::open(appicon, FileAccess::READ); if (f) { data.resize(f->get_len()); - f->get_buffer(data.ptr(),data.size()); + f->get_buffer(data.ptr(), data.size()); memdelete(f); } } } } - if (file.find("/")) { da->make_dir_recursive(file.get_base_dir()); } - FileAccessRef wf = FileAccess::open(bar_dir.plus_file(file),FileAccess::WRITE); - wf->store_buffer(data.ptr(),data.size()); + FileAccessRef wf = FileAccess::open(bar_dir.plus_file(file), FileAccess::WRITE); + wf->store_buffer(data.ptr(), data.size()); ret = unzGoToNextFile(pkg); } - ep.step("Adding Files..",2); + ep.step("Adding Files..", 2); - FileAccess* dst = FileAccess::open(bar_dir+"/data.pck", FileAccess::WRITE); + FileAccess *dst = FileAccess::open(bar_dir + "/data.pck", FileAccess::WRITE); if (!dst) { - EditorNode::add_io_error("Can't copy executable file to:\n "+p_path); + EditorNode::add_io_error("Can't copy executable file to:\n " + p_path); return ERR_FILE_CANT_WRITE; } save_pack(dst, false, 1024); dst->close(); memdelete(dst); - ep.step("Creating BAR Package..",104); - - String bb_packager=EditorSettings::get_singleton()->get("blackberry/host_tools"); - bb_packager=bb_packager.plus_file("blackberry-nativepackager"); - if (OS::get_singleton()->get_name()=="Windows") - bb_packager+=".bat"; + ep.step("Creating BAR Package..", 104); + String bb_packager = EditorSettings::get_singleton()->get("blackberry/host_tools"); + bb_packager = bb_packager.plus_file("blackberry-nativepackager"); + if (OS::get_singleton()->get_name() == "Windows") + bb_packager += ".bat"; if (!FileAccess::exists(bb_packager)) { - EditorNode::add_io_error("Can't find packager:\n"+bb_packager); + EditorNode::add_io_error("Can't find packager:\n" + bb_packager); return ERR_CANT_OPEN; } @@ -485,7 +462,7 @@ Error EditorExportPlatformBB10::export_project(const String& p_path, bool p_debu args.push_back(p_path); if (p_debug) { - String debug_token=EditorSettings::get_singleton()->get("blackberry/debug_token"); + String debug_token = EditorSettings::get_singleton()->get("blackberry/debug_token"); if (!FileAccess::exists(debug_token)) { EditorNode::add_io_error("Debug token not found!"); } else { @@ -504,74 +481,71 @@ Error EditorExportPlatformBB10::export_project(const String& p_path, bool p_debu int ec; - Error err = OS::get_singleton()->execute(bb_packager,args,true,NULL,NULL,&ec); + Error err = OS::get_singleton()->execute(bb_packager, args, true, NULL, NULL, &ec); - if (err!=OK) + if (err != OK) return err; - if (ec!=0) + if (ec != 0) return ERR_CANT_CREATE; return OK; - } bool EditorExportPlatformBB10::poll_devices() { - bool dc=devices_changed; - devices_changed=false; + bool dc = devices_changed; + devices_changed = false; return dc; } int EditorExportPlatformBB10::get_device_count() const { device_lock->lock(); - int dc=devices.size(); + int dc = devices.size(); device_lock->unlock(); return dc; - } String EditorExportPlatformBB10::get_device_name(int p_device) const { - ERR_FAIL_INDEX_V(p_device,devices.size(),""); + ERR_FAIL_INDEX_V(p_device, devices.size(), ""); device_lock->lock(); - String s=devices[p_device].name; + String s = devices[p_device].name; device_lock->unlock(); return s; } String EditorExportPlatformBB10::get_device_info(int p_device) const { - ERR_FAIL_INDEX_V(p_device,devices.size(),""); + ERR_FAIL_INDEX_V(p_device, devices.size(), ""); device_lock->lock(); - String s=devices[p_device].description; + String s = devices[p_device].description; device_lock->unlock(); return s; } void EditorExportPlatformBB10::_device_poll_thread(void *ud) { - EditorExportPlatformBB10 *ea=(EditorExportPlatformBB10 *)ud; + EditorExportPlatformBB10 *ea = (EditorExportPlatformBB10 *)ud; - while(!ea->quit_request) { + while (!ea->quit_request) { - String bb_deploy=EditorSettings::get_singleton()->get("blackberry/host_tools"); - bb_deploy=bb_deploy.plus_file("blackberry-deploy"); - bool windows = OS::get_singleton()->get_name()=="Windows"; + String bb_deploy = EditorSettings::get_singleton()->get("blackberry/host_tools"); + bb_deploy = bb_deploy.plus_file("blackberry-deploy"); + bool windows = OS::get_singleton()->get_name() == "Windows"; if (windows) - bb_deploy+=".bat"; + bb_deploy += ".bat"; if (FileAccess::exists(bb_deploy)) { Vector<Device> devices; + for (int i = 0; i < MAX_DEVICES; i++) { - for (int i=0;i<MAX_DEVICES;i++) { - - String host = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/host"); - if (host==String()) + String host = EditorSettings::get_singleton()->get("blackberry/device_" + itos(i + 1) + "/host"); + if (host == String()) continue; - String pass = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/password"); - if (pass==String()) + String pass = EditorSettings::get_singleton()->get("blackberry/device_" + itos(i + 1) + "/password"); + if (pass == String()) continue; List<String> args; @@ -580,57 +554,53 @@ void EditorExportPlatformBB10::_device_poll_thread(void *ud) { args.push_back("-password"); args.push_back(pass); - int ec; String dp; - Error err = OS::get_singleton()->execute(bb_deploy,args,true,NULL,&dp,&ec); + Error err = OS::get_singleton()->execute(bb_deploy, args, true, NULL, &dp, &ec); - if (err==OK && ec==0) { + if (err == OK && ec == 0) { Device dev; - dev.index=i; + dev.index = i; String descr; - Vector<String> ls=dp.split("\n"); + Vector<String> ls = dp.split("\n"); - for(int i=0;i<ls.size();i++) { + for (int i = 0; i < ls.size(); i++) { String l = ls[i].strip_edges(); if (l.begins_with("modelfullname::")) { - dev.name=l.get_slice("::",1); - descr+="Model: "+dev.name+"\n"; + dev.name = l.get_slice("::", 1); + descr += "Model: " + dev.name + "\n"; } if (l.begins_with("modelnumber::")) { - String s = l.get_slice("::",1); - dev.name+=" ("+s+")"; - descr+="Model Number: "+s+"\n"; + String s = l.get_slice("::", 1); + dev.name += " (" + s + ")"; + descr += "Model Number: " + s + "\n"; } if (l.begins_with("scmbundle::")) - descr+="OS Version: "+l.get_slice("::",1)+"\n"; + descr += "OS Version: " + l.get_slice("::", 1) + "\n"; if (l.begins_with("[n]debug_token_expiration::")) - descr+="Debug Token Expires:: "+l.get_slice("::",1)+"\n"; - + descr += "Debug Token Expires:: " + l.get_slice("::", 1) + "\n"; } - dev.description=descr; + dev.description = descr; devices.push_back(dev); } - } - bool changed=false; - + bool changed = false; ea->device_lock->lock(); - if (ea->devices.size()!=devices.size()) { - changed=true; + if (ea->devices.size() != devices.size()) { + changed = true; } else { - for(int i=0;i<ea->devices.size();i++) { + for (int i = 0; i < ea->devices.size(); i++) { - if (ea->devices[i].index!=devices[i].index) { - changed=true; + if (ea->devices[i].index != devices[i].index) { + changed = true; break; } } @@ -638,50 +608,46 @@ void EditorExportPlatformBB10::_device_poll_thread(void *ud) { if (changed) { - ea->devices=devices; - ea->devices_changed=true; + ea->devices = devices; + ea->devices_changed = true; } ea->device_lock->unlock(); } - uint64_t wait = 3000000; uint64_t time = OS::get_singleton()->get_ticks_usec(); - while(OS::get_singleton()->get_ticks_usec() - time < wait ) { + while (OS::get_singleton()->get_ticks_usec() - time < wait) { OS::get_singleton()->delay_usec(1000); if (ea->quit_request) break; } } - } Error EditorExportPlatformBB10::run(int p_device, int p_flags) { - ERR_FAIL_INDEX_V(p_device,devices.size(),ERR_INVALID_PARAMETER); + ERR_FAIL_INDEX_V(p_device, devices.size(), ERR_INVALID_PARAMETER); - String bb_deploy=EditorSettings::get_singleton()->get("blackberry/host_tools"); - bb_deploy=bb_deploy.plus_file("blackberry-deploy"); - if (OS::get_singleton()->get_name()=="Windows") - bb_deploy+=".bat"; + String bb_deploy = EditorSettings::get_singleton()->get("blackberry/host_tools"); + bb_deploy = bb_deploy.plus_file("blackberry-deploy"); + if (OS::get_singleton()->get_name() == "Windows") + bb_deploy += ".bat"; if (!FileAccess::exists(bb_deploy)) { - EditorNode::add_io_error("Blackberry Deploy not found:\n"+bb_deploy); + EditorNode::add_io_error("Blackberry Deploy not found:\n" + bb_deploy); return ERR_FILE_NOT_FOUND; } - device_lock->lock(); - - EditorProgress ep("run","Running on "+devices[p_device].name,3); + EditorProgress ep("run", "Running on " + devices[p_device].name, 3); //export_temp - ep.step("Exporting APK",0); + ep.step("Exporting APK", 0); - String export_to=EditorSettings::get_singleton()->get_settings_path().plus_file("/tmp/tmpexport.bar"); - Error err = export_project(export_to,true,p_flags); + String export_to = EditorSettings::get_singleton()->get_settings_path().plus_file("/tmp/tmpexport.bar"); + Error err = export_project(export_to, true, p_flags); if (err) { device_lock->unlock(); return err; @@ -707,23 +673,23 @@ Error EditorExportPlatformBB10::run(int p_device, int p_flags) { print_line("Installing into device (please wait..): "+devices[p_device].name); #endif - ep.step("Installing to Device (please wait..)..",2); + ep.step("Installing to Device (please wait..)..", 2); List<String> args; args.clear(); args.push_back("-installApp"); args.push_back("-launchApp"); args.push_back("-device"); - String host = EditorSettings::get_singleton()->get("blackberry/device_"+itos(p_device+1)+"/host"); - String pass = EditorSettings::get_singleton()->get("blackberry/device_"+itos(p_device+1)+"/password"); + String host = EditorSettings::get_singleton()->get("blackberry/device_" + itos(p_device + 1) + "/host"); + String pass = EditorSettings::get_singleton()->get("blackberry/device_" + itos(p_device + 1) + "/password"); args.push_back(host); args.push_back("-password"); args.push_back(pass); args.push_back(export_to); int rv; - err = OS::get_singleton()->execute(bb_deploy,args,true,NULL,NULL,&rv); - if (err || rv!=0) { + err = OS::get_singleton()->execute(bb_deploy, args, true, NULL, NULL, &rv); + if (err || rv != 0) { EditorNode::add_io_error("Could not install to device."); device_lock->unlock(); return ERR_CANT_CREATE; @@ -731,99 +697,90 @@ Error EditorExportPlatformBB10::run(int p_device, int p_flags) { device_lock->unlock(); return OK; - - } - EditorExportPlatformBB10::EditorExportPlatformBB10() { - version_code=1; - version_name="1.0"; - package="com.godot.noname"; - category="core.games"; - name=""; - author_name="Cert. Name"; - author_id="Cert. ID"; - description="Game made with Godot Engine"; + version_code = 1; + version_name = "1.0"; + package = "com.godot.noname"; + category = "core.games"; + name = ""; + author_name = "Cert. Name"; + author_id = "Cert. ID"; + description = "Game made with Godot Engine"; device_lock = Mutex::create(); - quit_request=false; + quit_request = false; - device_thread=Thread::create(_device_poll_thread,this); - devices_changed=true; + device_thread = Thread::create(_device_poll_thread, this); + devices_changed = true; - Image img( _bb10_logo ); - logo = Ref<ImageTexture>( memnew( ImageTexture )); + Image img(_bb10_logo); + logo = Ref<ImageTexture>(memnew(ImageTexture)); logo->create_from_image(img); } bool EditorExportPlatformBB10::can_export(String *r_error) const { - bool valid=true; - String bb_deploy=EditorSettings::get_singleton()->get("blackberry/host_tools"); + bool valid = true; + String bb_deploy = EditorSettings::get_singleton()->get("blackberry/host_tools"); String err; if (!FileAccess::exists(bb_deploy.plus_file("blackberry-deploy"))) { - valid=false; - err+="Blackberry host tools not configured in editor settings.\n"; + valid = false; + err += "Blackberry host tools not configured in editor settings.\n"; } if (!exists_export_template("bb10.zip")) { - valid=false; - err+="No export template found.\nDownload and install export templates.\n"; + valid = false; + err += "No export template found.\nDownload and install export templates.\n"; } - String debug_token=EditorSettings::get_singleton()->get("blackberry/debug_token"); + String debug_token = EditorSettings::get_singleton()->get("blackberry/debug_token"); if (!FileAccess::exists(debug_token)) { - valid=false; - err+="No debug token set, will not be able to test on device.\n"; + valid = false; + err += "No debug token set, will not be able to test on device.\n"; } - - if (custom_package!="" && !FileAccess::exists(custom_package)) { - valid=false; - err+="Custom release package not found.\n"; + if (custom_package != "" && !FileAccess::exists(custom_package)) { + valid = false; + err += "Custom release package not found.\n"; } if (r_error) - *r_error=err; + *r_error = err; return valid; } - EditorExportPlatformBB10::~EditorExportPlatformBB10() { - quit_request=true; + quit_request = true; Thread::wait_to_finish(device_thread); memdelete(device_lock); memdelete(device_thread); } - void register_bb10_exporter() { - EDITOR_DEF("blackberry/host_tools",""); - EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"blackberry/host_tools",PROPERTY_HINT_GLOBAL_DIR)); - EDITOR_DEF("blackberry/debug_token",""); - EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"blackberry/debug_token",PROPERTY_HINT_GLOBAL_FILE,"bar")); - EDITOR_DEF("blackberry/device_1/host",""); - EDITOR_DEF("blackberry/device_1/password",""); - EDITOR_DEF("blackberry/device_2/host",""); - EDITOR_DEF("blackberry/device_2/password",""); - EDITOR_DEF("blackberry/device_3/host",""); - EDITOR_DEF("blackberry/device_3/password",""); - EDITOR_DEF("blackberry/device_4/host",""); - EDITOR_DEF("blackberry/device_4/password",""); - EDITOR_DEF("blackberry/device_5/host",""); - EDITOR_DEF("blackberry/device_5/password",""); + EDITOR_DEF("blackberry/host_tools", ""); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "blackberry/host_tools", PROPERTY_HINT_GLOBAL_DIR)); + EDITOR_DEF("blackberry/debug_token", ""); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "blackberry/debug_token", PROPERTY_HINT_GLOBAL_FILE, "bar")); + EDITOR_DEF("blackberry/device_1/host", ""); + EDITOR_DEF("blackberry/device_1/password", ""); + EDITOR_DEF("blackberry/device_2/host", ""); + EDITOR_DEF("blackberry/device_2/password", ""); + EDITOR_DEF("blackberry/device_3/host", ""); + EDITOR_DEF("blackberry/device_3/password", ""); + EDITOR_DEF("blackberry/device_4/host", ""); + EDITOR_DEF("blackberry/device_4/password", ""); + EDITOR_DEF("blackberry/device_5/host", ""); + EDITOR_DEF("blackberry/device_5/password", ""); - Ref<EditorExportPlatformBB10> exporter = Ref<EditorExportPlatformBB10>( memnew(EditorExportPlatformBB10) ); + Ref<EditorExportPlatformBB10> exporter = Ref<EditorExportPlatformBB10>(memnew(EditorExportPlatformBB10)); EditorImportExport::get_singleton()->add_export_platform(exporter); - - } - diff --git a/platform/bb10/godot_bb10.cpp b/platform/bb10/godot_bb10.cpp index 4b8270b49..e1826450a 100644 --- a/platform/bb10/godot_bb10.cpp +++ b/platform/bb10/godot_bb10.cpp @@ -31,12 +31,12 @@ #include <unistd.h> -int main(int argc, char* argv[]) { +int main(int argc, char *argv[]) { OSBB10 os; - Error err = Main::setup(argv[0],argc-1,&argv[1]); - if (err!=OK) + Error err = Main::setup(argv[0], argc - 1, &argv[1]); + if (err != OK) return 255; if (Main::start()) @@ -45,4 +45,3 @@ int main(int argc, char* argv[]) { return os.get_exit_code(); } - diff --git a/platform/bb10/os_bb10.cpp b/platform/bb10/os_bb10.cpp index ed40355eb..adf9c4e94 100644 --- a/platform/bb10/os_bb10.cpp +++ b/platform/bb10/os_bb10.cpp @@ -28,38 +28,38 @@ /*************************************************************************/ #include "os_bb10.h" +#include "core/os/dir_access.h" #include "drivers/gles2/rasterizer_gles2.h" #include "servers/visual/visual_server_raster.h" -#include "core/os/dir_access.h" +#include "bbutil.h" #include "core/globals.h" +#include "core/os/keyboard.h" #include "main/main.h" -#include "bbutil.h" -#include <stdlib.h> -#include <stdbool.h> #include <assert.h> -#include "core/os/keyboard.h" +#include <stdbool.h> +#include <stdlib.h> +#include "bps/accelerometer.h" +#include "bps/audiodevice.h" #include "bps/bps.h" -#include "bps/screen.h" #include "bps/navigator.h" -#include "bps/accelerometer.h" #include "bps/orientation.h" +#include "bps/screen.h" #include "bps/virtualkeyboard.h" -#include "bps/audiodevice.h" #ifdef BB10_SCORELOOP_ENABLED #include "modules/scoreloop/scoreloop_bb10.h" #endif static char launch_dir[512]; -char* launch_dir_ptr; +char *launch_dir_ptr; int OSBB10::get_video_driver_count() const { return 1; } -const char * OSBB10::get_video_driver_name(int p_driver) const { +const char *OSBB10::get_video_driver_name(int p_driver) const { return "GLES2"; } @@ -73,26 +73,26 @@ int OSBB10::get_audio_driver_count() const { return 1; } -const char * OSBB10::get_audio_driver_name(int p_driver) const { +const char *OSBB10::get_audio_driver_name(int p_driver) const { return "BB10"; } -void OSBB10::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) { +void OSBB10::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { data_dir = getenv("HOME"); //Create a screen context that will be used to create an EGL surface to to receive libscreen events - screen_create_context(&screen_cxt,0); + screen_create_context(&screen_cxt, 0); //Initialize BPS library bps_initialize(); //Use utility code to initialize EGL for 2D rendering with GL ES 1.1 enum RENDERING_API api = GL_ES_2; - #ifdef BB10_LGLES_OVERRIDE +#ifdef BB10_LGLES_OVERRIDE api = GL_ES_1; - #endif +#endif if (EXIT_SUCCESS != bbutil_init(screen_cxt, api)) { bbutil_terminate(); screen_destroy_context(screen_cxt); @@ -117,9 +117,9 @@ void OSBB10::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi virtualkeyboard_request_events(0); audiodevice_request_events(0); - #ifdef DEBUG_ENABLED +#ifdef DEBUG_ENABLED bps_set_verbosity(3); - #endif +#endif accel_supported = accelerometer_is_supported(); if (accel_supported) @@ -127,13 +127,13 @@ void OSBB10::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi pitch = 0; roll = 0; - #ifdef BB10_LGLES_OVERRIDE - rasterizer = memnew( RasterizerGLES1(false) ); - #else - rasterizer = memnew( RasterizerGLES2(false, false) ); - #endif +#ifdef BB10_LGLES_OVERRIDE + rasterizer = memnew(RasterizerGLES1(false)); +#else + rasterizer = memnew(RasterizerGLES2(false, false)); +#endif - visual_server = memnew( VisualServerRaster(rasterizer) ); + visual_server = memnew(VisualServerRaster(rasterizer)); visual_server->init(); visual_server->cursor_set_visible(false, 0); @@ -141,49 +141,48 @@ void OSBB10::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi audio_driver->set_singleton(); audio_driver->init(NULL); - sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerSW(sample_manager) ); - audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,false); + sample_manager = memnew(SampleManagerMallocSW); + audio_server = memnew(AudioServerSW(sample_manager)); + audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR, false); audio_server->init(); - spatial_sound_server = memnew( SpatialSoundServerSW ); + spatial_sound_server = memnew(SpatialSoundServerSW); spatial_sound_server->init(); - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); + spatial_sound_2d_server = memnew(SpatialSound2DServerSW); spatial_sound_2d_server->init(); // - physics_server = memnew( PhysicsServerSW ); + physics_server = memnew(PhysicsServerSW); physics_server->init(); - physics_2d_server = memnew( Physics2DServerSW ); + physics_2d_server = memnew(Physics2DServerSW); physics_2d_server->init(); - input = memnew( InputDefault ); + input = memnew(InputDefault); - #ifdef PAYMENT_SERVICE_ENABLED +#ifdef PAYMENT_SERVICE_ENABLED payment_service = memnew(PaymentService); Globals::get_singleton()->add_singleton(Globals::Singleton("InAppStore", payment_service)); - #endif - +#endif } -void OSBB10::set_main_loop( MainLoop * p_main_loop ) { +void OSBB10::set_main_loop(MainLoop *p_main_loop) { input->set_main_loop(p_main_loop); - main_loop=p_main_loop; + main_loop = p_main_loop; } void OSBB10::delete_main_loop() { - memdelete( main_loop ); + memdelete(main_loop); main_loop = NULL; } void OSBB10::finalize() { - if(main_loop) + if (main_loop) memdelete(main_loop); - main_loop=NULL; + main_loop = NULL; spatial_sound_server->finish(); memdelete(spatial_sound_server); @@ -191,8 +190,8 @@ void OSBB10::finalize() { memdelete(spatial_sound_2d_server); //if (debugger_connection_console) { -// memdelete(debugger_connection_console); -//} + // memdelete(debugger_connection_console); + //} memdelete(sample_manager); @@ -209,9 +208,9 @@ void OSBB10::finalize() { physics_2d_server->finish(); memdelete(physics_2d_server); - #ifdef PAYMENT_SERVICE_ENABLED +#ifdef PAYMENT_SERVICE_ENABLED memdelete(payment_service); - #endif +#endif memdelete(input); @@ -244,16 +243,14 @@ int OSBB10::get_mouse_button_state() const { return 0; } -void OSBB10::set_window_title(const String& p_title) { - - +void OSBB10::set_window_title(const String &p_title) { } //interesting byt not yet //void set_clipboard(const String& p_text); //String get_clipboard() const; -void OSBB10::set_video_mode(const VideoMode& p_video_mode,int p_screen) { +void OSBB10::set_video_mode(const VideoMode &p_video_mode, int p_screen) { default_videomode = p_video_mode; } @@ -262,7 +259,7 @@ OS::VideoMode OSBB10::get_video_mode(int p_screen) const { return default_videomode; } -void OSBB10::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const { +void OSBB10::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const { p_list->push_back(default_videomode); } @@ -297,128 +294,125 @@ void OSBB10::handle_screen_event(bps_event_t *event) { int pos[2]; switch (screen_val) { - case SCREEN_EVENT_MTOUCH_TOUCH: - case SCREEN_EVENT_MTOUCH_RELEASE: { + case SCREEN_EVENT_MTOUCH_TOUCH: + case SCREEN_EVENT_MTOUCH_RELEASE: { - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_POSITION, pos); + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_POSITION, pos); - InputEvent ievent; - ievent.type = InputEvent::SCREEN_TOUCH; - ievent.ID = ++last_id; - ievent.device = 0; - ievent.screen_touch.pressed = (screen_val == SCREEN_EVENT_MTOUCH_TOUCH); - ievent.screen_touch.x = pos[0]; - ievent.screen_touch.y = pos[1]; - Point2 mpos(ievent.screen_touch.x, ievent.screen_touch.y); + InputEvent ievent; + ievent.type = InputEvent::SCREEN_TOUCH; + ievent.ID = ++last_id; + ievent.device = 0; + ievent.screen_touch.pressed = (screen_val == SCREEN_EVENT_MTOUCH_TOUCH); + ievent.screen_touch.x = pos[0]; + ievent.screen_touch.y = pos[1]; + Point2 mpos(ievent.screen_touch.x, ievent.screen_touch.y); - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TOUCH_ID, &pos[0]); - ievent.screen_touch.index = pos[0]; + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TOUCH_ID, &pos[0]); + ievent.screen_touch.index = pos[0]; - last_touch_x[pos[0]] = ievent.screen_touch.x; - last_touch_y[pos[0]] = ievent.screen_touch.y; + last_touch_x[pos[0]] = ievent.screen_touch.x; + last_touch_y[pos[0]] = ievent.screen_touch.y; - input->parse_input_event( ievent ); + input->parse_input_event(ievent); - if (ievent.screen_touch.index == 0) { - - InputEvent ievent; - ievent.type = InputEvent::MOUSE_BUTTON; - ievent.ID = ++last_id; - ievent.device = 0; - ievent.mouse_button.pressed = (screen_val == SCREEN_EVENT_MTOUCH_TOUCH); - ievent.mouse_button.button_index = BUTTON_LEFT; - ievent.mouse_button.doubleclick = 0; - ievent.mouse_button.x = ievent.mouse_button.global_x = mpos.x; - ievent.mouse_button.y = ievent.mouse_button.global_y = mpos.y; - input->parse_input_event( ievent ); - }; + if (ievent.screen_touch.index == 0) { + InputEvent ievent; + ievent.type = InputEvent::MOUSE_BUTTON; + ievent.ID = ++last_id; + ievent.device = 0; + ievent.mouse_button.pressed = (screen_val == SCREEN_EVENT_MTOUCH_TOUCH); + ievent.mouse_button.button_index = BUTTON_LEFT; + ievent.mouse_button.doubleclick = 0; + ievent.mouse_button.x = ievent.mouse_button.global_x = mpos.x; + ievent.mouse_button.y = ievent.mouse_button.global_y = mpos.y; + input->parse_input_event(ievent); + }; - } break; - case SCREEN_EVENT_MTOUCH_MOVE: { + } break; + case SCREEN_EVENT_MTOUCH_MOVE: { - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_POSITION, pos); + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_POSITION, pos); - InputEvent ievent; - ievent.type = InputEvent::SCREEN_DRAG; - ievent.ID = ++last_id; - ievent.device = 0; - ievent.screen_drag.x = pos[0]; - ievent.screen_drag.y = pos[1]; + InputEvent ievent; + ievent.type = InputEvent::SCREEN_DRAG; + ievent.ID = ++last_id; + ievent.device = 0; + ievent.screen_drag.x = pos[0]; + ievent.screen_drag.y = pos[1]; - /* + /* screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_SOURCE_POSITION, pos); ievent.screen_drag.relative_x = ievent.screen_drag.x - pos[0]; ievent.screen_drag.relative_y = ievent.screen_drag.y - pos[1]; */ - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TOUCH_ID, &pos[0]); - ievent.screen_drag.index = pos[0]; + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TOUCH_ID, &pos[0]); + ievent.screen_drag.index = pos[0]; + + ievent.screen_drag.relative_x = ievent.screen_drag.x - last_touch_x[ievent.screen_drag.index]; + ievent.screen_drag.relative_y = ievent.screen_drag.y - last_touch_y[ievent.screen_drag.index]; + + last_touch_x[ievent.screen_drag.index] = ievent.screen_drag.x; + last_touch_y[ievent.screen_drag.index] = ievent.screen_drag.y; + Point2 mpos(ievent.screen_drag.x, ievent.screen_drag.y); + Point2 mrel(ievent.screen_drag.relative_x, ievent.screen_drag.relative_y); - ievent.screen_drag.relative_x = ievent.screen_drag.x - last_touch_x[ievent.screen_drag.index]; - ievent.screen_drag.relative_y = ievent.screen_drag.y - last_touch_y[ievent.screen_drag.index]; + input->parse_input_event(ievent); - last_touch_x[ievent.screen_drag.index] = ievent.screen_drag.x; - last_touch_y[ievent.screen_drag.index] = ievent.screen_drag.y; + if (ievent.screen_touch.index == 0) { - Point2 mpos(ievent.screen_drag.x, ievent.screen_drag.y); - Point2 mrel(ievent.screen_drag.relative_x, ievent.screen_drag.relative_y); + InputEvent ievent; + ievent.type = InputEvent::MOUSE_MOTION; + ievent.ID = ++last_id; + ievent.device = 0; + ievent.mouse_motion.x = ievent.mouse_motion.global_x = mpos.x; + ievent.mouse_motion.y = ievent.mouse_motion.global_y = mpos.y; + input->set_mouse_pos(Point2(ievent.mouse_motion.x, ievent.mouse_motion.y)); + ievent.mouse_motion.speed_x = input->get_mouse_speed().x; + ievent.mouse_motion.speed_y = input->get_mouse_speed().y; + ievent.mouse_motion.relative_x = mrel.x; + ievent.mouse_motion.relative_y = mrel.y; + ievent.mouse_motion.button_mask = 1; // pressed - input->parse_input_event( ievent ); + input->parse_input_event(ievent); + }; + } break; - if (ievent.screen_touch.index == 0) { + case SCREEN_EVENT_KEYBOARD: { InputEvent ievent; - ievent.type = InputEvent::MOUSE_MOTION; + ievent.type = InputEvent::KEY; ievent.ID = ++last_id; ievent.device = 0; - ievent.mouse_motion.x = ievent.mouse_motion.global_x = mpos.x; - ievent.mouse_motion.y = ievent.mouse_motion.global_y = mpos.y; - input->set_mouse_pos(Point2(ievent.mouse_motion.x,ievent.mouse_motion.y)); - ievent.mouse_motion.speed_x=input->get_mouse_speed().x; - ievent.mouse_motion.speed_y=input->get_mouse_speed().y; - ievent.mouse_motion.relative_x = mrel.x; - ievent.mouse_motion.relative_y = mrel.y; - ievent.mouse_motion.button_mask = 1; // pressed - - input->parse_input_event( ievent ); - }; - } break; - - case SCREEN_EVENT_KEYBOARD: { - - InputEvent ievent; - ievent.type = InputEvent::KEY; - ievent.ID = ++last_id; - ievent.device = 0; - int val = 0; - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_SCAN, &val); - ievent.key.scancode = val; - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_SYM, &val); - ievent.key.unicode = val; - if (val == 61448) { - ievent.key.scancode = KEY_BACKSPACE; - ievent.key.unicode = KEY_BACKSPACE; - }; - if (val == 61453) { - ievent.key.scancode = KEY_ENTER; - ievent.key.unicode = KEY_ENTER; - }; - - int flags; - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_FLAGS, &flags); - ievent.key.pressed = flags & 1; // bit 1 is pressed apparently + int val = 0; + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_SCAN, &val); + ievent.key.scancode = val; + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_SYM, &val); + ievent.key.unicode = val; + if (val == 61448) { + ievent.key.scancode = KEY_BACKSPACE; + ievent.key.unicode = KEY_BACKSPACE; + }; + if (val == 61453) { + ievent.key.scancode = KEY_ENTER; + ievent.key.unicode = KEY_ENTER; + }; - int mod; - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_MODIFIERS, &mod); + int flags; + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_FLAGS, &flags); + ievent.key.pressed = flags & 1; // bit 1 is pressed apparently - input->parse_input_event( ievent ); - } break; + int mod; + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_MODIFIERS, &mod); - default: - break; + input->parse_input_event(ievent); + } break; + default: + break; } }; @@ -438,8 +432,7 @@ void OSBB10::handle_accelerometer() { //input->set_accelerometer(Vector3(force_y, flip_accelerometer?force_x:(-force_x), force_z)); }; - -void OSBB10::_resize(bps_event_t* event) { +void OSBB10::_resize(bps_event_t *event) { int angle = navigator_event_get_orientation_angle(event); bbutil_rotate_screen_surface(angle); @@ -468,16 +461,16 @@ void OSBB10::process_events() { if (!event) break; - #ifdef BB10_SCORELOOP_ENABLED - ScoreloopBB10* sc = Globals::get_singleton()->get_singleton_object("Scoreloop")->cast_to<ScoreloopBB10>(); +#ifdef BB10_SCORELOOP_ENABLED + ScoreloopBB10 *sc = Globals::get_singleton()->get_singleton_object("Scoreloop")->cast_to<ScoreloopBB10>(); if (sc->handle_event(event)) continue; - #endif +#endif - #ifdef PAYMENT_SERVICE_ENABLED +#ifdef PAYMENT_SERVICE_ENABLED if (payment_service->handle_event(event)) continue; - #endif +#endif int domain = bps_event_get_domain(event); if (domain == screen_get_domain()) { @@ -492,7 +485,7 @@ void OSBB10::process_events() { bps_event_destroy(event); exit(0); return; - /* + /* } else if (bps_event_get_code(event) == NAVIGATOR_ORIENTATION_CHECK) { int angle = navigator_event_get_orientation_angle(event); @@ -523,7 +516,7 @@ void OSBB10::process_events() { }; } else if (domain == audiodevice_get_domain()) { - const char * audiodevice_path = audiodevice_event_get_path(event); + const char *audiodevice_path = audiodevice_event_get_path(event); printf("************* got audiodevice event, path %s\n", audiodevice_path); audio_driver->finish(); audio_driver->init(audiodevice_path); @@ -539,7 +532,7 @@ bool OSBB10::has_virtual_keyboard() const { return true; }; -void OSBB10::show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect) { +void OSBB10::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect) { virtualkeyboard_show(); }; @@ -570,11 +563,10 @@ void OSBB10::run() { }; */ - while (true) { process_events(); // get rid of pending events - if (Main::iteration()==true) + if (Main::iteration() == true) break; bbutil_swap(); //#ifdef DEBUG_ENABLED @@ -583,7 +575,6 @@ void OSBB10::run() { }; main_loop->finish(); - }; bool OSBB10::has_touchscreen_ui_hint() const { @@ -593,7 +584,7 @@ bool OSBB10::has_touchscreen_ui_hint() const { Error OSBB10::shell_open(String p_uri) { - char* msg = NULL; + char *msg = NULL; int ret = navigator_invoke(p_uri.utf8().get_data(), &msg); return ret == BPS_SUCCESS ? OK : FAILED; @@ -610,15 +601,14 @@ Size2 OSBB10::get_window_size() const { OSBB10::OSBB10() { - main_loop=NULL; - last_id=1; + main_loop = NULL; + last_id = 1; minimized = false; fullscreen = true; flip_accelerometer = true; fullscreen_mixer_volume = 1; fullscreen_stream_volume = 1; - printf("godot bb10!\n"); getcwd(launch_dir, sizeof(launch_dir)); printf("launch dir %s\n", launch_dir); @@ -627,7 +617,4 @@ OSBB10::OSBB10() { } OSBB10::~OSBB10() { - - } - diff --git a/platform/bb10/os_bb10.h b/platform/bb10/os_bb10.h index 801155098..0146d0d8e 100644 --- a/platform/bb10/os_bb10.h +++ b/platform/bb10/os_bb10.h @@ -29,22 +29,22 @@ #ifndef OS_BB10_H #define OS_BB10_H -#include "os/input.h" +#include "audio_driver_bb10.h" #include "drivers/unix/os_unix.h" -#include "os/main_loop.h" #include "main/input_default.h" +#include "os/input.h" +#include "os/main_loop.h" +#include "payment_service.h" +#include "servers/audio/audio_server_sw.h" #include "servers/physics/physics_server_sw.h" +#include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/spatial_sound/spatial_sound_server_sw.h" #include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" -#include "servers/audio/audio_server_sw.h" -#include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/visual/rasterizer.h" -#include "audio_driver_bb10.h" -#include "payment_service.h" +#include "bps/event.h" #include <screen/screen.h> #include <sys/platform.h> -#include "bps/event.h" #include <stdint.h> @@ -58,21 +58,21 @@ class OSBB10 : public OS_Unix { Rasterizer *rasterizer; VisualServer *visual_server; -// AudioDriverPSP audio_driver_psp; + // AudioDriverPSP audio_driver_psp; AudioServerSW *audio_server; SampleManagerMallocSW *sample_manager; SpatialSoundServerSW *spatial_sound_server; SpatialSound2DServerSW *spatial_sound_2d_server; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; - AudioDriverBB10* audio_driver; + AudioDriverBB10 *audio_driver; #ifdef PAYMENT_SERVICE_ENABLED - PaymentService* payment_service; + PaymentService *payment_service; #endif VideoMode default_videomode; - MainLoop * main_loop; + MainLoop *main_loop; void process_events(); @@ -93,48 +93,47 @@ class OSBB10 : public OS_Unix { String data_dir; InputDefault *input; -public: +public: // functions used by main to initialize/deintialize the OS virtual int get_video_driver_count() const; - virtual const char * get_video_driver_name(int p_driver) const; + virtual const char *get_video_driver_name(int p_driver) const; virtual VideoMode get_default_video_mode() const; virtual String get_data_dir() const; virtual int get_audio_driver_count() const; - virtual const char * get_audio_driver_name(int p_driver) const; + virtual const char *get_audio_driver_name(int p_driver) const; - virtual void initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver); + virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); - virtual void set_main_loop( MainLoop * p_main_loop ); + virtual void set_main_loop(MainLoop *p_main_loop); virtual void delete_main_loop(); virtual void finalize(); typedef int64_t ProcessID; - static OS* get_singleton(); + static OS *get_singleton(); virtual void set_mouse_show(bool p_show); virtual void set_mouse_grab(bool p_grab); virtual bool is_mouse_grab_enabled() const; virtual Point2 get_mouse_pos() const; virtual int get_mouse_button_state() const; - virtual void set_window_title(const String& p_title); + virtual void set_window_title(const String &p_title); //virtual void set_clipboard(const String& p_text); //virtual String get_clipboard() const; - virtual bool has_virtual_keyboard() const; - virtual void show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect); + virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect); virtual void hide_virtual_keyboard(); - virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0); - virtual VideoMode get_video_mode(int p_screen=0) const; - virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const; + virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0); + virtual VideoMode get_video_mode(int p_screen = 0) const; + virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const; virtual Size2 get_window_size() const; virtual String get_name(); @@ -152,8 +151,6 @@ public: OSBB10(); ~OSBB10(); - }; #endif - diff --git a/platform/bb10/payment_service.cpp b/platform/bb10/payment_service.cpp index 68c2fc668..4b0dc5679 100644 --- a/platform/bb10/payment_service.cpp +++ b/platform/bb10/payment_service.cpp @@ -31,18 +31,18 @@ #include "payment_service.h" #include "bbutil.h" -#include <string.h> #include <errno.h> +#include <string.h> #include <unistd.h> -extern char* launch_dir_ptr; +extern char *launch_dir_ptr; void PaymentService::_bind_methods() { - ObjectTypeDB::bind_method(_MD("request_product_info"),&PaymentService::request_product_info); - ObjectTypeDB::bind_method(_MD("purchase"),&PaymentService::purchase); + ObjectTypeDB::bind_method(_MD("request_product_info"), &PaymentService::request_product_info); + ObjectTypeDB::bind_method(_MD("purchase"), &PaymentService::purchase); - ObjectTypeDB::bind_method(_MD("get_pending_event_count"),&PaymentService::get_pending_event_count); - ObjectTypeDB::bind_method(_MD("pop_pending_event"),&PaymentService::pop_pending_event); + ObjectTypeDB::bind_method(_MD("get_pending_event_count"), &PaymentService::get_pending_event_count); + ObjectTypeDB::bind_method(_MD("pop_pending_event"), &PaymentService::pop_pending_event); }; Error PaymentService::request_product_info(Variant p_params) { @@ -55,16 +55,16 @@ Error PaymentService::purchase(Variant p_params) { Dictionary params = p_params; ERR_FAIL_COND_V((!params.has("product_id")) && (!params.has("product_sku")), ERR_INVALID_PARAMETER); - char* id = NULL; - char* sku = NULL; + char *id = NULL; + char *sku = NULL; - CharString p_id = params.has("product_id")?String(params["product_id"]).ascii():CharString(); - CharString p_sku = params.has("product_sku")?String(params["product_sku"]).ascii():CharString(); + CharString p_id = params.has("product_id") ? String(params["product_id"]).ascii() : CharString(); + CharString p_sku = params.has("product_sku") ? String(params["product_sku"]).ascii() : CharString(); unsigned int request_id; chdir(launch_dir_ptr); int ret = paymentservice_purchase_request(params.has("product_sku") ? NULL : p_id.get_data(), - params.has("product_sku") ? p_sku.get_data() : NULL, - NULL, NULL, NULL, NULL, get_window_group_id(), &request_id); + params.has("product_sku") ? p_sku.get_data() : NULL, + NULL, NULL, NULL, NULL, get_window_group_id(), &request_id); chdir("app/native"); if (ret != BPS_SUCCESS) { @@ -76,8 +76,7 @@ Error PaymentService::purchase(Variant p_params) { return OK; }; - -bool PaymentService::handle_event(bps_event_t* p_event) { +bool PaymentService::handle_event(bps_event_t *p_event) { if (bps_event_get_domain(p_event) != paymentservice_get_domain()) { return false; @@ -91,12 +90,12 @@ bool PaymentService::handle_event(bps_event_t* p_event) { res = bps_event_get_code(p_event); if (res == PURCHASE_RESPONSE) { dict["type"] = "purchase"; - const char* pid = paymentservice_event_get_digital_good_id(p_event, 0); - dict["product_id"] = String(pid?pid:""); + const char *pid = paymentservice_event_get_digital_good_id(p_event, 0); + dict["product_id"] = String(pid ? pid : ""); }; } else { - const char* desc = paymentservice_event_get_error_text(p_event); + const char *desc = paymentservice_event_get_error_text(p_event); if (strcmp(desc, "alreadyPurchased") == 0) { dict["result"] = "ok"; } else { @@ -142,9 +141,8 @@ PaymentService::PaymentService() { #endif }; -PaymentService::~PaymentService() { +PaymentService::~PaymentService(){ }; - #endif diff --git a/platform/bb10/payment_service.h b/platform/bb10/payment_service.h index 9c3bb04eb..d5c304a52 100644 --- a/platform/bb10/payment_service.h +++ b/platform/bb10/payment_service.h @@ -46,24 +46,18 @@ class PaymentService : public Object { List<Variant> pending_events; public: - Error request_product_info(Variant p_params); Error purchase(Variant p_params); int get_pending_event_count(); Variant pop_pending_event(); - bool handle_event(bps_event_t* p_event); + bool handle_event(bps_event_t *p_event); PaymentService(); ~PaymentService(); }; - - #endif - #endif - - |
